Parcourir la source

- 组件化优化,移除对 spring 的依赖:非spring应用选用 "XxlJobExecutor" 、spring应用选用 "XxlJobSpringExecutor" 作为执行器组件;

xuxueli il y a 6 ans
Parent
révision
df2b9f7e0c

+ 8 - 6
doc/XXL-JOB官方文档.md Voir le fichier

1328
 - 2、底层通讯组件迁移至 xxl-rpc;
1328
 - 2、底层通讯组件迁移至 xxl-rpc;
1329
 - 3、IP获取逻辑优化,优先遍历网卡来获取可用IP;
1329
 - 3、IP获取逻辑优化,优先遍历网卡来获取可用IP;
1330
 - 4、任务新增的API服务接口返回任务ID,方便调用方实用;
1330
 - 4、任务新增的API服务接口返回任务ID,方便调用方实用;
1331
-- 5、新增无框架执行器Sample示例项目 "xxl-job-executor-sample-frameless"。不依赖第三方框架,只需main方法即可启动运行执行器;
1332
-- 6、[迭代中]任务状态与quartz解耦,降低quartz调度压力,仅NORMAL状态任务绑定quartz;
1333
-- 7、[迭代中]新增任务默认运行状态,任务更新时运行状态保持不变;
1334
-- 8、[迭代中]原生提供通用命令行任务Handler(Bean任务,"CommandJobHandler");业务方只需要提供命令行即可,可执行任意命令;
1335
-- 9、[迭代中]cron在线生成工具,如 "cronboot/cron.qqe2";
1336
-- 10、[迭代中]docker镜像,并且推送docker镜像到中央仓库,更进一步实现产品开箱即用;
1331
+- 5、组件化优化,移除对 spring 的依赖:非spring应用选用 "XxlJobExecutor" 、spring应用选用 "XxlJobSpringExecutor" 作为执行器组件; 
1332
+- 6、新增无框架执行器Sample示例项目 "xxl-job-executor-sample-frameless"。不依赖第三方框架,只需main方法即可启动运行执行器;
1333
+- 7、任务RollingLog展示逻辑优化,修复超时任务无法查看的问题;
1334
+- 8、[迭代中]任务状态与quartz解耦,降低quartz调度压力,仅NORMAL状态任务绑定quartz;
1335
+- 9、[迭代中]新增任务默认运行状态,任务更新时运行状态保持不变;
1336
+- 10、[迭代中]原生提供通用命令行任务Handler(Bean任务,"CommandJobHandler");业务方只需要提供命令行即可,可执行任意命令;
1337
+- 11、[迭代中]cron在线生成工具,如 "cronboot/cron.qqe2";
1338
+- 12、[迭代中]docker镜像,并且推送docker镜像到中央仓库,更进一步实现产品开箱即用;
1337
 
1339
 
1338
 
1340
 
1339
 ### TODO LIST
1341
 ### TODO LIST

+ 2 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/core/trigger/XxlJobTrigger.java Voir le fichier

13
 import com.xxl.job.core.biz.model.TriggerParam;
13
 import com.xxl.job.core.biz.model.TriggerParam;
14
 import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
14
 import com.xxl.job.core.enums.ExecutorBlockStrategyEnum;
15
 import com.xxl.rpc.util.IpUtil;
15
 import com.xxl.rpc.util.IpUtil;
16
+import com.xxl.rpc.util.ThrowableUtil;
16
 import org.apache.commons.collections4.CollectionUtils;
17
 import org.apache.commons.collections4.CollectionUtils;
17
 import org.apache.commons.lang3.StringUtils;
18
 import org.apache.commons.lang3.StringUtils;
18
 import org.slf4j.Logger;
19
 import org.slf4j.Logger;
190
             runResult = executorBiz.run(triggerParam);
191
             runResult = executorBiz.run(triggerParam);
191
         } catch (Exception e) {
192
         } catch (Exception e) {
192
             logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e);
193
             logger.error(">>>>>>>>>>> xxl-job trigger error, please check if the executor[{}] is running.", address, e);
193
-            runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ""+e );
194
+            runResult = new ReturnT<String>(ReturnT.FAIL_CODE, ThrowableUtil.toString(e));
194
         }
195
         }
195
 
196
 
196
         StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":");
197
         StringBuffer runResultSB = new StringBuffer(I18nUtil.getString("jobconf_trigger_run") + ":");

+ 1 - 1
xxl-job-admin/src/main/resources/static/js/joblog.detail.1.js Voir le fichier

1
 $(function() {
1
 $(function() {
2
 
2
 
3
     // trigger fail, end
3
     // trigger fail, end
4
-    if (triggerCode != 200) {
4
+    if ( !(triggerCode == 200 || handleCode != 0) ) {
5
         $('#logConsoleRunning').hide();
5
         $('#logConsoleRunning').hide();
6
         $('#logConsole').append('<span style="color: red;">'+ I18n.joblog_rolling_log_triggerfail +'</span>');
6
         $('#logConsole').append('<span style="color: red;">'+ I18n.joblog_rolling_log_triggerfail +'</span>');
7
         return;
7
         return;

+ 1 - 1
xxl-job-admin/src/main/resources/static/js/joblog.index.1.js Voir le fichier

179
 	                	"render": function ( data, type, row ) {
179
 	                	"render": function ( data, type, row ) {
180
 	                		// better support expression or string, not function
180
 	                		// better support expression or string, not function
181
 	                		return function () {
181
 	                		return function () {
182
-		                		if (row.triggerCode == 200){
182
+		                		if (row.triggerCode == 200 || row.handleCode != 0){
183
 		                			var temp = '<a href="javascript:;" class="logDetail" _id="'+ row.id +'">'+ I18n.joblog_rolling_log +'</a>';
183
 		                			var temp = '<a href="javascript:;" class="logDetail" _id="'+ row.id +'">'+ I18n.joblog_rolling_log +'</a>';
184
 		                			if(row.handleCode == 0){
184
 		                			if(row.handleCode == 0){
185
 		                				temp += '<br><a href="javascript:;" class="logKill" _id="'+ row.id +'" style="color: red;" >'+ I18n.joblog_kill_log +'</a>';
185
 		                				temp += '<br><a href="javascript:;" class="logKill" _id="'+ row.id +'" style="color: red;" >'+ I18n.joblog_kill_log +'</a>';

+ 8 - 7
xxl-job-core/pom.xml Voir le fichier

36
 			<version>${commons-exec.version}</version>
36
 			<version>${commons-exec.version}</version>
37
 		</dependency>
37
 		</dependency>
38
 
38
 
39
-		<!-- spring-context -->
40
-		<dependency>
41
-			<groupId>org.springframework</groupId>
42
-			<artifactId>spring-context</artifactId>
43
-			<version>${spring.version}</version>
44
-		</dependency>
45
-
46
 		<!-- jackson -->
39
 		<!-- jackson -->
47
 		<dependency>
40
 		<dependency>
48
 			<groupId>com.fasterxml.jackson.core</groupId>
41
 			<groupId>com.fasterxml.jackson.core</groupId>
50
 			<version>${jackson.version}</version>
43
 			<version>${jackson.version}</version>
51
 		</dependency>
44
 		</dependency>
52
 
45
 
46
+		<!-- spring-context -->
47
+		<dependency>
48
+			<groupId>org.springframework</groupId>
49
+			<artifactId>spring-context</artifactId>
50
+			<version>${spring.version}</version>
51
+			<scope>provided</scope>
52
+		</dependency>
53
+
53
 	</dependencies>
54
 	</dependencies>
54
 
55
 
55
 </project>
56
 </project>

+ 3 - 39
xxl-job-core/src/main/java/com/xxl/job/core/executor/XxlJobExecutor.java Voir le fichier

4
 import com.xxl.job.core.biz.ExecutorBiz;
4
 import com.xxl.job.core.biz.ExecutorBiz;
5
 import com.xxl.job.core.biz.impl.ExecutorBizImpl;
5
 import com.xxl.job.core.biz.impl.ExecutorBizImpl;
6
 import com.xxl.job.core.handler.IJobHandler;
6
 import com.xxl.job.core.handler.IJobHandler;
7
-import com.xxl.job.core.handler.annotation.JobHandler;
8
 import com.xxl.job.core.log.XxlJobFileAppender;
7
 import com.xxl.job.core.log.XxlJobFileAppender;
9
 import com.xxl.job.core.thread.ExecutorRegistryThread;
8
 import com.xxl.job.core.thread.ExecutorRegistryThread;
10
 import com.xxl.job.core.thread.JobLogFileCleanThread;
9
 import com.xxl.job.core.thread.JobLogFileCleanThread;
21
 import com.xxl.rpc.util.NetUtil;
20
 import com.xxl.rpc.util.NetUtil;
22
 import org.slf4j.Logger;
21
 import org.slf4j.Logger;
23
 import org.slf4j.LoggerFactory;
22
 import org.slf4j.LoggerFactory;
24
-import org.springframework.beans.BeansException;
25
-import org.springframework.context.ApplicationContext;
26
-import org.springframework.context.ApplicationContextAware;
27
 
23
 
28
 import java.util.*;
24
 import java.util.*;
29
 import java.util.concurrent.ConcurrentHashMap;
25
 import java.util.concurrent.ConcurrentHashMap;
31
 /**
27
 /**
32
  * Created by xuxueli on 2016/3/2 21:14.
28
  * Created by xuxueli on 2016/3/2 21:14.
33
  */
29
  */
34
-public class XxlJobExecutor implements ApplicationContextAware {
30
+public class XxlJobExecutor  {
35
     private static final Logger logger = LoggerFactory.getLogger(XxlJobExecutor.class);
31
     private static final Logger logger = LoggerFactory.getLogger(XxlJobExecutor.class);
36
 
32
 
37
     // ---------------------- param ----------------------
33
     // ---------------------- param ----------------------
65
         this.logRetentionDays = logRetentionDays;
61
         this.logRetentionDays = logRetentionDays;
66
     }
62
     }
67
 
63
 
68
-    // ---------------------- applicationContext ----------------------
69
-    private static ApplicationContext applicationContext;
70
-    @Override
71
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
72
-        this.applicationContext = applicationContext;
73
-    }
74
-    public static ApplicationContext getApplicationContext() {
75
-        return applicationContext;
76
-    }
77
-
78
 
64
 
79
     // ---------------------- start + stop ----------------------
65
     // ---------------------- start + stop ----------------------
80
     public void start() throws Exception {
66
     public void start() throws Exception {
82
         // init logpath
68
         // init logpath
83
         XxlJobFileAppender.initLogPath(logPath);
69
         XxlJobFileAppender.initLogPath(logPath);
84
 
70
 
85
-        // init JobHandler Repository
86
-        initJobHandlerRepository(applicationContext);
87
-
88
         // init admin-client
71
         // init admin-client
89
         initAdminBizList(adminAddresses, accessToken);
72
         initAdminBizList(adminAddresses, accessToken);
90
 
73
 
74
+
91
         // init JobLogFileCleanThread
75
         // init JobLogFileCleanThread
92
         JobLogFileCleanThread.getInstance().start(logRetentionDays);
76
         JobLogFileCleanThread.getInstance().start(logRetentionDays);
93
 
77
 
108
             jobThreadRepository.clear();
92
             jobThreadRepository.clear();
109
         }
93
         }
110
 
94
 
95
+
111
         // destory JobLogFileCleanThread
96
         // destory JobLogFileCleanThread
112
         JobLogFileCleanThread.getInstance().toStop();
97
         JobLogFileCleanThread.getInstance().toStop();
113
 
98
 
228
     public static IJobHandler loadJobHandler(String name){
213
     public static IJobHandler loadJobHandler(String name){
229
         return jobHandlerRepository.get(name);
214
         return jobHandlerRepository.get(name);
230
     }
215
     }
231
-    private void initJobHandlerRepository(ApplicationContext applicationContext){
232
-        if (applicationContext == null) {
233
-            return;
234
-        }
235
-
236
-        // init job handler action
237
-        Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHandler.class);
238
-
239
-        if (serviceBeanMap!=null && serviceBeanMap.size()>0) {
240
-            for (Object serviceBean : serviceBeanMap.values()) {
241
-                if (serviceBean instanceof IJobHandler){
242
-                    String name = serviceBean.getClass().getAnnotation(JobHandler.class).value();
243
-                    IJobHandler handler = (IJobHandler) serviceBean;
244
-                    if (loadJobHandler(name) != null) {
245
-                        throw new RuntimeException("xxl-job jobhandler naming conflicts.");
246
-                    }
247
-                    registJobHandler(name, handler);
248
-                }
249
-            }
250
-        }
251
-    }
252
 
216
 
253
 
217
 
254
     // ---------------------- job thread repository ----------------------
218
     // ---------------------- job thread repository ----------------------

+ 67 - 0
xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java Voir le fichier

1
+package com.xxl.job.core.executor.impl;
2
+
3
+import com.xxl.job.core.executor.XxlJobExecutor;
4
+import com.xxl.job.core.glue.GlueFactory;
5
+import com.xxl.job.core.handler.IJobHandler;
6
+import com.xxl.job.core.handler.annotation.JobHandler;
7
+import org.springframework.beans.BeansException;
8
+import org.springframework.context.ApplicationContext;
9
+import org.springframework.context.ApplicationContextAware;
10
+
11
+import java.util.Map;
12
+
13
+/**
14
+ * xxl-job executor (for spring)
15
+ *
16
+ * @author xuxueli 2018-11-01 09:24:52
17
+ */
18
+public class XxlJobSpringExecutor extends XxlJobExecutor implements ApplicationContextAware {
19
+
20
+
21
+    @Override
22
+    public void start() throws Exception {
23
+
24
+        // init JobHandler Repository
25
+        initJobHandlerRepository(applicationContext);
26
+
27
+        // refresh GlueFactory
28
+        GlueFactory.refreshInstance(1);
29
+
30
+
31
+        // super start
32
+        super.start();
33
+    }
34
+
35
+    private void initJobHandlerRepository(ApplicationContext applicationContext){
36
+        if (applicationContext == null) {
37
+            return;
38
+        }
39
+
40
+        // init job handler action
41
+        Map<String, Object> serviceBeanMap = applicationContext.getBeansWithAnnotation(JobHandler.class);
42
+
43
+        if (serviceBeanMap!=null && serviceBeanMap.size()>0) {
44
+            for (Object serviceBean : serviceBeanMap.values()) {
45
+                if (serviceBean instanceof IJobHandler){
46
+                    String name = serviceBean.getClass().getAnnotation(JobHandler.class).value();
47
+                    IJobHandler handler = (IJobHandler) serviceBean;
48
+                    if (loadJobHandler(name) != null) {
49
+                        throw new RuntimeException("xxl-job jobhandler naming conflicts.");
50
+                    }
51
+                    registJobHandler(name, handler);
52
+                }
53
+            }
54
+        }
55
+    }
56
+
57
+    // ---------------------- applicationContext ----------------------
58
+    private static ApplicationContext applicationContext;
59
+    @Override
60
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
61
+        this.applicationContext = applicationContext;
62
+    }
63
+    public static ApplicationContext getApplicationContext() {
64
+        return applicationContext;
65
+    }
66
+
67
+}

+ 31 - 69
xxl-job-core/src/main/java/com/xxl/job/core/glue/GlueFactory.java Voir le fichier

1
 package com.xxl.job.core.glue;
1
 package com.xxl.job.core.glue;
2
 
2
 
3
-import com.xxl.job.core.executor.XxlJobExecutor;
3
+import com.xxl.job.core.glue.impl.SpringGlueFactory;
4
 import com.xxl.job.core.handler.IJobHandler;
4
 import com.xxl.job.core.handler.IJobHandler;
5
 import groovy.lang.GroovyClassLoader;
5
 import groovy.lang.GroovyClassLoader;
6
-import org.slf4j.Logger;
7
-import org.slf4j.LoggerFactory;
8
-import org.springframework.beans.factory.annotation.Autowired;
9
-import org.springframework.beans.factory.annotation.Qualifier;
10
-import org.springframework.core.annotation.AnnotationUtils;
11
-
12
-import javax.annotation.Resource;
13
-import java.lang.reflect.Field;
14
-import java.lang.reflect.Modifier;
15
 
6
 
16
 /**
7
 /**
17
  * glue factory, product class/object by name
8
  * glue factory, product class/object by name
9
+ *
18
  * @author xuxueli 2016-1-2 20:02:27
10
  * @author xuxueli 2016-1-2 20:02:27
19
  */
11
  */
20
 public class GlueFactory {
12
 public class GlueFactory {
21
-	private static Logger logger = LoggerFactory.getLogger(GlueFactory.class);
22
-	
23
-	/**
24
-	 * groovy class loader
25
-	 */
26
-	private GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
27
 
13
 
28
-	// ----------------------------- spring support -----------------------------
14
+
29
 	private static GlueFactory glueFactory = new GlueFactory();
15
 	private static GlueFactory glueFactory = new GlueFactory();
30
 	public static GlueFactory getInstance(){
16
 	public static GlueFactory getInstance(){
31
 		return glueFactory;
17
 		return glueFactory;
32
 	}
18
 	}
19
+	public static void refreshInstance(int type){
20
+		if (type == 0) {
21
+			glueFactory = new GlueFactory();
22
+		} else if (type == 1) {
23
+			glueFactory = new SpringGlueFactory();
24
+		}
25
+	}
26
+
33
 
27
 
34
 	/**
28
 	/**
35
-	 * inject action of spring
36
-	 * @param instance
29
+	 * groovy class loader
30
+	 */
31
+	private GroovyClassLoader groovyClassLoader = new GroovyClassLoader();
32
+
33
+
34
+	/**
35
+	 * load new instance, prototype
36
+	 *
37
+	 * @param codeSource
38
+	 * @return
39
+	 * @throws Exception
37
 	 */
40
 	 */
38
-	private void injectService(Object instance){
39
-		if (instance==null) {
40
-			return;
41
-		}
42
-	    
43
-		Field[] fields = instance.getClass().getDeclaredFields();
44
-		for (Field field : fields) {
45
-			if (Modifier.isStatic(field.getModifiers())) {
46
-				continue;
47
-			}
48
-			
49
-			Object fieldBean = null;
50
-			// with bean-id, bean could be found by both @Resource and @Autowired, or bean could only be found by @Autowired
51
-			if (AnnotationUtils.getAnnotation(field, Resource.class) != null) {
52
-				try {
53
-					Resource resource = AnnotationUtils.getAnnotation(field, Resource.class);
54
-					if (resource.name()!=null && resource.name().length()>0){
55
-						fieldBean = XxlJobExecutor.getApplicationContext().getBean(resource.name());
56
-					} else {
57
-						fieldBean = XxlJobExecutor.getApplicationContext().getBean(field.getName());
58
-					}
59
-				} catch (Exception e) {
60
-				}
61
-				if (fieldBean==null ) {
62
-					fieldBean = XxlJobExecutor.getApplicationContext().getBean(field.getType());
63
-				}
64
-			} else if (AnnotationUtils.getAnnotation(field, Autowired.class) != null) {
65
-				Qualifier qualifier = AnnotationUtils.getAnnotation(field, Qualifier.class);
66
-				if (qualifier!=null && qualifier.value()!=null && qualifier.value().length()>0) {
67
-					fieldBean = XxlJobExecutor.getApplicationContext().getBean(qualifier.value());
68
-				} else {
69
-					fieldBean = XxlJobExecutor.getApplicationContext().getBean(field.getType());
70
-				}
71
-			}
72
-			
73
-			if (fieldBean!=null) {
74
-				field.setAccessible(true);
75
-				try {
76
-					field.set(instance, fieldBean);
77
-				} catch (IllegalArgumentException e) {
78
-					logger.error(e.getMessage(), e);
79
-				} catch (IllegalAccessException e) {
80
-					logger.error(e.getMessage(), e);
81
-				}
82
-			}
83
-		}
84
-	}
85
-	
86
-	// ----------------------------- load instance -----------------------------
87
-	// load new instance, prototype
88
 	public IJobHandler loadNewInstance(String codeSource) throws Exception{
41
 	public IJobHandler loadNewInstance(String codeSource) throws Exception{
89
 		if (codeSource!=null && codeSource.trim().length()>0) {
42
 		if (codeSource!=null && codeSource.trim().length()>0) {
90
 			Class<?> clazz = groovyClassLoader.parseClass(codeSource);
43
 			Class<?> clazz = groovyClassLoader.parseClass(codeSource);
104
 		throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null");
57
 		throw new IllegalArgumentException(">>>>>>>>>>> xxl-glue, loadNewInstance error, instance is null");
105
 	}
58
 	}
106
 
59
 
60
+	/**
61
+	 * inject service of bean field
62
+	 *
63
+	 * @param instance
64
+	 */
65
+	public void injectService(Object instance) {
66
+		// do something
67
+	}
68
+
107
 }
69
 }

+ 80 - 0
xxl-job-core/src/main/java/com/xxl/job/core/glue/impl/SpringGlueFactory.java Voir le fichier

1
+package com.xxl.job.core.glue.impl;
2
+
3
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
4
+import com.xxl.job.core.glue.GlueFactory;
5
+import org.slf4j.Logger;
6
+import org.slf4j.LoggerFactory;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.beans.factory.annotation.Qualifier;
9
+import org.springframework.core.annotation.AnnotationUtils;
10
+
11
+import javax.annotation.Resource;
12
+import java.lang.reflect.Field;
13
+import java.lang.reflect.Modifier;
14
+
15
+/**
16
+ * @author xuxueli 2018-11-01
17
+ */
18
+public class SpringGlueFactory extends GlueFactory {
19
+    private static Logger logger = LoggerFactory.getLogger(SpringGlueFactory.class);
20
+
21
+
22
+    /**
23
+     * inject action of spring
24
+     * @param instance
25
+     */
26
+    @Override
27
+    public void injectService(Object instance){
28
+        if (instance==null) {
29
+            return;
30
+        }
31
+
32
+        if (XxlJobSpringExecutor.getApplicationContext() == null) {
33
+            return;
34
+        }
35
+
36
+        Field[] fields = instance.getClass().getDeclaredFields();
37
+        for (Field field : fields) {
38
+            if (Modifier.isStatic(field.getModifiers())) {
39
+                continue;
40
+            }
41
+
42
+            Object fieldBean = null;
43
+            // with bean-id, bean could be found by both @Resource and @Autowired, or bean could only be found by @Autowired
44
+
45
+            if (AnnotationUtils.getAnnotation(field, Resource.class) != null) {
46
+                try {
47
+                    Resource resource = AnnotationUtils.getAnnotation(field, Resource.class);
48
+                    if (resource.name()!=null && resource.name().length()>0){
49
+                        fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(resource.name());
50
+                    } else {
51
+                        fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(field.getName());
52
+                    }
53
+                } catch (Exception e) {
54
+                }
55
+                if (fieldBean==null ) {
56
+                    fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(field.getType());
57
+                }
58
+            } else if (AnnotationUtils.getAnnotation(field, Autowired.class) != null) {
59
+                Qualifier qualifier = AnnotationUtils.getAnnotation(field, Qualifier.class);
60
+                if (qualifier!=null && qualifier.value()!=null && qualifier.value().length()>0) {
61
+                    fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(qualifier.value());
62
+                } else {
63
+                    fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(field.getType());
64
+                }
65
+            }
66
+
67
+            if (fieldBean!=null) {
68
+                field.setAccessible(true);
69
+                try {
70
+                    field.set(instance, fieldBean);
71
+                } catch (IllegalArgumentException e) {
72
+                    logger.error(e.getMessage(), e);
73
+                } catch (IllegalAccessException e) {
74
+                    logger.error(e.getMessage(), e);
75
+                }
76
+            }
77
+        }
78
+    }
79
+
80
+}

+ 1 - 1
xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/resources/applicationcontext-xxl-job.xml Voir le fichier

22
 	<context:component-scan base-package="com.xxl.job.executor.service.jobhandler" />
22
 	<context:component-scan base-package="com.xxl.job.executor.service.jobhandler" />
23
 
23
 
24
 	<!-- 配置02、执行器 -->
24
 	<!-- 配置02、执行器 -->
25
-	<bean id="xxlJobExecutor" class="com.xxl.job.core.executor.XxlJobExecutor" init-method="start" destroy-method="destroy" >
25
+	<bean id="xxlJobSpringExecutor" class="com.xxl.job.core.executor.impl.XxlJobSpringExecutor" init-method="start" destroy-method="destroy" >
26
 		<!-- 执行器注册中心地址[选填],为空则关闭自动注册 -->
26
 		<!-- 执行器注册中心地址[选填],为空则关闭自动注册 -->
27
 		<property name="adminAddresses" value="${xxl.job.admin.addresses}" />
27
 		<property name="adminAddresses" value="${xxl.job.admin.addresses}" />
28
 		<!-- 执行器AppName[选填],为空则关闭自动注册 -->
28
 		<!-- 执行器AppName[选填],为空则关闭自动注册 -->

+ 12 - 12
xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/core/config/XxlJobConfig.java Voir le fichier

1
 package com.xxl.job.executor.core.config;
1
 package com.xxl.job.executor.core.config;
2
 
2
 
3
-import com.xxl.job.core.executor.XxlJobExecutor;
3
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
4
 import org.slf4j.Logger;
4
 import org.slf4j.Logger;
5
 import org.slf4j.LoggerFactory;
5
 import org.slf4j.LoggerFactory;
6
 import org.springframework.beans.factory.annotation.Value;
6
 import org.springframework.beans.factory.annotation.Value;
41
 
41
 
42
 
42
 
43
     @Bean(initMethod = "start", destroyMethod = "destroy")
43
     @Bean(initMethod = "start", destroyMethod = "destroy")
44
-    public XxlJobExecutor xxlJobExecutor() {
44
+    public XxlJobSpringExecutor xxlJobExecutor() {
45
         logger.info(">>>>>>>>>>> xxl-job config init.");
45
         logger.info(">>>>>>>>>>> xxl-job config init.");
46
-        XxlJobExecutor xxlJobExecutor = new XxlJobExecutor();
47
-        xxlJobExecutor.setAdminAddresses(adminAddresses);
48
-        xxlJobExecutor.setAppName(appName);
49
-        xxlJobExecutor.setIp(ip);
50
-        xxlJobExecutor.setPort(port);
51
-        xxlJobExecutor.setAccessToken(accessToken);
52
-        xxlJobExecutor.setLogPath(logPath);
53
-        xxlJobExecutor.setLogRetentionDays(logRetentionDays);
54
-
55
-        return xxlJobExecutor;
46
+        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
47
+        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
48
+        xxlJobSpringExecutor.setAppName(appName);
49
+        xxlJobSpringExecutor.setIp(ip);
50
+        xxlJobSpringExecutor.setPort(port);
51
+        xxlJobSpringExecutor.setAccessToken(accessToken);
52
+        xxlJobSpringExecutor.setLogPath(logPath);
53
+        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
54
+
55
+        return xxlJobSpringExecutor;
56
     }
56
     }
57
 
57
 
58
 }
58
 }