diff --git a/xxl-job-admin/src/main/resources/templates/jobgroup/jobgroup.index.ftl b/xxl-job-admin/src/main/resources/templates/jobgroup/jobgroup.index.ftl
index 1f05ac3a..1060d454 100644
--- a/xxl-job-admin/src/main/resources/templates/jobgroup/jobgroup.index.ftl
+++ b/xxl-job-admin/src/main/resources/templates/jobgroup/jobgroup.index.ftl
@@ -121,7 +121,7 @@
@@ -169,7 +169,7 @@
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java
index 8901d374..c57fa6fb 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-frameless/src/main/java/com/xuxueli/executor/sample/frameless/jobhandler/HttpJobHandler.java
@@ -3,13 +3,11 @@ package com.xuxueli.executor.sample.frameless.jobhandler;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.log.XxlJobLogger;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
-import java.util.concurrent.TimeUnit;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
/**
* 跨平台Http任务
@@ -27,34 +25,60 @@ public class HttpJobHandler extends IJobHandler {
return FAIL;
}
- // httpclient
- HttpClient httpClient = null;
+ // request
+ HttpURLConnection connection = null;
+ BufferedReader bufferedReader = null;
try {
- httpClient = new HttpClient();
- httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
- httpClient.start(); // Start HttpClient
-
- // request
- Request request = httpClient.newRequest(param);
- request.method(HttpMethod.GET);
- request.timeout(5000, TimeUnit.MILLISECONDS);
-
- // invoke
- ContentResponse response = request.send();
- if (response.getStatus() != HttpStatus.OK_200) {
- XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus());
- return FAIL;
+ // connection
+ URL realUrl = new URL(param);
+ connection = (HttpURLConnection) realUrl.openConnection();
+
+ // connection setting
+ connection.setRequestMethod("GET");
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ connection.setUseCaches(false);
+ connection.setReadTimeout(5 * 1000);
+ connection.setConnectTimeout(3 * 1000);
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
+ connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
+
+ // do connection
+ connection.connect();
+
+ //Map> map = connection.getHeaderFields();
+
+ // valid StatusCode
+ int statusCode = connection.getResponseCode();
+ if (statusCode != 200) {
+ throw new RuntimeException("Http Request StatusCode("+ statusCode +") Invalid.");
+ }
+
+ // result
+ bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ StringBuilder result = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ result.append(line);
}
+ String responseMsg = result.toString();
- String responseMsg = response.getContentAsString();
XxlJobLogger.log(responseMsg);
return SUCCESS;
} catch (Exception e) {
XxlJobLogger.log(e);
return FAIL;
} finally {
- if (httpClient != null) {
- httpClient.stop();
+ try {
+ if (bufferedReader != null) {
+ bufferedReader.close();
+ }
+ if (connection != null) {
+ connection.disconnect();
+ }
+ } catch (Exception e2) {
+ XxlJobLogger.log(e2);
}
}
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java
index a4fa6b97..ae410e98 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/HttpJobHandler.java
@@ -3,13 +3,11 @@ package com.xuxueli.executor.sample.jfinal.jobhandler;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.log.XxlJobLogger;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
-import java.util.concurrent.TimeUnit;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
/**
* 跨平台Http任务
@@ -18,46 +16,66 @@ import java.util.concurrent.TimeUnit;
*/
public class HttpJobHandler extends IJobHandler {
- @Override
- public ReturnT execute(String param) throws Exception {
-
- // valid
- if (param==null || param.trim().length()==0) {
- XxlJobLogger.log("URL Empty");
- return FAIL;
- }
-
- // httpclient
- HttpClient httpClient = null;
- try {
- httpClient = new HttpClient();
- httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
- httpClient.start(); // Start HttpClient
-
- // request
- Request request = httpClient.newRequest(param);
- request.method(HttpMethod.GET);
- request.timeout(5000, TimeUnit.MILLISECONDS);
-
- // invoke
- ContentResponse response = request.send();
- if (response.getStatus() != HttpStatus.OK_200) {
- XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus());
- return FAIL;
- }
-
- String responseMsg = response.getContentAsString();
- XxlJobLogger.log(responseMsg);
- return SUCCESS;
- } catch (Exception e) {
- XxlJobLogger.log(e);
- return FAIL;
- } finally {
- if (httpClient != null) {
- httpClient.stop();
- }
- }
-
- }
+ @Override
+ public ReturnT execute(String param) throws Exception {
+
+ // request
+ HttpURLConnection connection = null;
+ BufferedReader bufferedReader = null;
+ try {
+ // connection
+ URL realUrl = new URL(param);
+ connection = (HttpURLConnection) realUrl.openConnection();
+
+ // connection setting
+ connection.setRequestMethod("GET");
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ connection.setUseCaches(false);
+ connection.setReadTimeout(5 * 1000);
+ connection.setConnectTimeout(3 * 1000);
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
+ connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
+
+ // do connection
+ connection.connect();
+
+ //Map> map = connection.getHeaderFields();
+
+ // valid StatusCode
+ int statusCode = connection.getResponseCode();
+ if (statusCode != 200) {
+ throw new RuntimeException("Http Request StatusCode(" + statusCode + ") Invalid.");
+ }
+
+ // result
+ bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ StringBuilder result = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ result.append(line);
+ }
+ String responseMsg = result.toString();
+
+ XxlJobLogger.log(responseMsg);
+ return SUCCESS;
+ } catch (Exception e) {
+ XxlJobLogger.log(e);
+ return FAIL;
+ } finally {
+ try {
+ if (bufferedReader != null) {
+ bufferedReader.close();
+ }
+ if (connection != null) {
+ connection.disconnect();
+ }
+ } catch (Exception e2) {
+ XxlJobLogger.log(e2);
+ }
+ }
+
+ }
}
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java
index 615bbd88..434fc95f 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java
@@ -4,64 +4,82 @@ import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
import org.nutz.ioc.loader.annotation.IocBean;
-import java.util.concurrent.TimeUnit;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
/**
* 跨平台Http任务
*
* @author xuxueli 2018-09-16 03:48:34
*/
-@JobHandler(value="httpJobHandler")
+@JobHandler(value = "httpJobHandler")
@IocBean
public class HttpJobHandler extends IJobHandler {
- @Override
- public ReturnT execute(String param) throws Exception {
+ @Override
+ public ReturnT execute(String param) throws Exception {
- // valid
- if (param==null || param.trim().length()==0) {
- XxlJobLogger.log("URL Empty");
- return FAIL;
- }
+ // request
+ HttpURLConnection connection = null;
+ BufferedReader bufferedReader = null;
+ try {
+ // connection
+ URL realUrl = new URL(param);
+ connection = (HttpURLConnection) realUrl.openConnection();
- // httpclient
- HttpClient httpClient = null;
- try {
- httpClient = new HttpClient();
- httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
- httpClient.start(); // Start HttpClient
+ // connection setting
+ connection.setRequestMethod("GET");
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ connection.setUseCaches(false);
+ connection.setReadTimeout(5 * 1000);
+ connection.setConnectTimeout(3 * 1000);
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
+ connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
- // request
- Request request = httpClient.newRequest(param);
- request.method(HttpMethod.GET);
- request.timeout(5000, TimeUnit.MILLISECONDS);
+ // do connection
+ connection.connect();
- // invoke
- ContentResponse response = request.send();
- if (response.getStatus() != HttpStatus.OK_200) {
- XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus());
- return FAIL;
- }
+ //Map> map = connection.getHeaderFields();
- String responseMsg = response.getContentAsString();
- XxlJobLogger.log(responseMsg);
- return SUCCESS;
- } catch (Exception e) {
- XxlJobLogger.log(e);
- return FAIL;
- } finally {
- if (httpClient != null) {
- httpClient.stop();
- }
- }
+ // valid StatusCode
+ int statusCode = connection.getResponseCode();
+ if (statusCode != 200) {
+ throw new RuntimeException("Http Request StatusCode(" + statusCode + ") Invalid.");
+ }
- }
+ // result
+ bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ StringBuilder result = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ result.append(line);
+ }
+ String responseMsg = result.toString();
+
+ XxlJobLogger.log(responseMsg);
+ return SUCCESS;
+ } catch (Exception e) {
+ XxlJobLogger.log(e);
+ return FAIL;
+ } finally {
+ try {
+ if (bufferedReader != null) {
+ bufferedReader.close();
+ }
+ if (connection != null) {
+ connection.disconnect();
+ }
+ } catch (Exception e2) {
+ XxlJobLogger.log(e2);
+ }
+ }
+
+ }
}
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
index 61dbab1c..159c6bea 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
@@ -4,64 +4,82 @@ import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
import org.springframework.stereotype.Component;
-import java.util.concurrent.TimeUnit;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
/**
* 跨平台Http任务
*
* @author xuxueli 2018-09-16 03:48:34
*/
-@JobHandler(value="httpJobHandler")
+@JobHandler(value = "httpJobHandler")
@Component
public class HttpJobHandler extends IJobHandler {
- @Override
- public ReturnT execute(String param) throws Exception {
+ @Override
+ public ReturnT execute(String param) throws Exception {
- // valid
- if (param==null || param.trim().length()==0) {
- XxlJobLogger.log("URL Empty");
- return FAIL;
- }
+ // request
+ HttpURLConnection connection = null;
+ BufferedReader bufferedReader = null;
+ try {
+ // connection
+ URL realUrl = new URL(param);
+ connection = (HttpURLConnection) realUrl.openConnection();
- // httpclient
- HttpClient httpClient = null;
- try {
- httpClient = new HttpClient();
- httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
- httpClient.start(); // Start HttpClient
+ // connection setting
+ connection.setRequestMethod("GET");
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ connection.setUseCaches(false);
+ connection.setReadTimeout(5 * 1000);
+ connection.setConnectTimeout(3 * 1000);
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
+ connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
- // request
- Request request = httpClient.newRequest(param);
- request.method(HttpMethod.GET);
- request.timeout(5000, TimeUnit.MILLISECONDS);
+ // do connection
+ connection.connect();
- // invoke
- ContentResponse response = request.send();
- if (response.getStatus() != HttpStatus.OK_200) {
- XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus());
- return FAIL;
- }
+ //Map> map = connection.getHeaderFields();
- String responseMsg = response.getContentAsString();
- XxlJobLogger.log(responseMsg);
- return SUCCESS;
- } catch (Exception e) {
- XxlJobLogger.log(e);
- return FAIL;
- } finally {
- if (httpClient != null) {
- httpClient.stop();
- }
- }
+ // valid StatusCode
+ int statusCode = connection.getResponseCode();
+ if (statusCode != 200) {
+ throw new RuntimeException("Http Request StatusCode(" + statusCode + ") Invalid.");
+ }
- }
+ // result
+ bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ StringBuilder result = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ result.append(line);
+ }
+ String responseMsg = result.toString();
+
+ XxlJobLogger.log(responseMsg);
+ return SUCCESS;
+ } catch (Exception e) {
+ XxlJobLogger.log(e);
+ return FAIL;
+ } finally {
+ try {
+ if (bufferedReader != null) {
+ bufferedReader.close();
+ }
+ if (connection != null) {
+ connection.disconnect();
+ }
+ } catch (Exception e2) {
+ XxlJobLogger.log(e2);
+ }
+ }
+
+ }
}
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
index 61dbab1c..159c6bea 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/HttpJobHandler.java
@@ -4,64 +4,82 @@ import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import com.xxl.job.core.log.XxlJobLogger;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
import org.springframework.stereotype.Component;
-import java.util.concurrent.TimeUnit;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
/**
* 跨平台Http任务
*
* @author xuxueli 2018-09-16 03:48:34
*/
-@JobHandler(value="httpJobHandler")
+@JobHandler(value = "httpJobHandler")
@Component
public class HttpJobHandler extends IJobHandler {
- @Override
- public ReturnT execute(String param) throws Exception {
+ @Override
+ public ReturnT execute(String param) throws Exception {
- // valid
- if (param==null || param.trim().length()==0) {
- XxlJobLogger.log("URL Empty");
- return FAIL;
- }
+ // request
+ HttpURLConnection connection = null;
+ BufferedReader bufferedReader = null;
+ try {
+ // connection
+ URL realUrl = new URL(param);
+ connection = (HttpURLConnection) realUrl.openConnection();
- // httpclient
- HttpClient httpClient = null;
- try {
- httpClient = new HttpClient();
- httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
- httpClient.start(); // Start HttpClient
+ // connection setting
+ connection.setRequestMethod("GET");
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ connection.setUseCaches(false);
+ connection.setReadTimeout(5 * 1000);
+ connection.setConnectTimeout(3 * 1000);
+ connection.setRequestProperty("connection", "Keep-Alive");
+ connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
+ connection.setRequestProperty("Accept-Charset", "application/json;charset=UTF-8");
- // request
- Request request = httpClient.newRequest(param);
- request.method(HttpMethod.GET);
- request.timeout(5000, TimeUnit.MILLISECONDS);
+ // do connection
+ connection.connect();
- // invoke
- ContentResponse response = request.send();
- if (response.getStatus() != HttpStatus.OK_200) {
- XxlJobLogger.log("Http StatusCode({}) Invalid.", response.getStatus());
- return FAIL;
- }
+ //Map> map = connection.getHeaderFields();
- String responseMsg = response.getContentAsString();
- XxlJobLogger.log(responseMsg);
- return SUCCESS;
- } catch (Exception e) {
- XxlJobLogger.log(e);
- return FAIL;
- } finally {
- if (httpClient != null) {
- httpClient.stop();
- }
- }
+ // valid StatusCode
+ int statusCode = connection.getResponseCode();
+ if (statusCode != 200) {
+ throw new RuntimeException("Http Request StatusCode(" + statusCode + ") Invalid.");
+ }
- }
+ // result
+ bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ StringBuilder result = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ result.append(line);
+ }
+ String responseMsg = result.toString();
+
+ XxlJobLogger.log(responseMsg);
+ return SUCCESS;
+ } catch (Exception e) {
+ XxlJobLogger.log(e);
+ return FAIL;
+ } finally {
+ try {
+ if (bufferedReader != null) {
+ bufferedReader.close();
+ }
+ if (connection != null) {
+ connection.disconnect();
+ }
+ } catch (Exception e2) {
+ XxlJobLogger.log(e2);
+ }
+ }
+
+ }
}