|
@@ -1,8 +1,10 @@
|
1
|
1
|
package com.xuxueli.executor.sample.nutz.config;
|
2
|
2
|
|
|
3
|
+import com.xuxueli.executor.sample.nutz.jobhandler.CommandJobHandler;
|
|
4
|
+import com.xuxueli.executor.sample.nutz.jobhandler.DemoJobHandler;
|
|
5
|
+import com.xuxueli.executor.sample.nutz.jobhandler.HttpJobHandler;
|
|
6
|
+import com.xuxueli.executor.sample.nutz.jobhandler.ShardingJobHandler;
|
3
|
7
|
import com.xxl.job.core.executor.XxlJobExecutor;
|
4
|
|
-import com.xxl.job.core.handler.IJobHandler;
|
5
|
|
-import com.xxl.job.core.handler.annotation.JobHandler;
|
6
|
8
|
import org.nutz.ioc.impl.PropertiesProxy;
|
7
|
9
|
import org.nutz.mvc.NutConfig;
|
8
|
10
|
import org.nutz.mvc.Setup;
|
|
@@ -16,23 +18,17 @@ import org.slf4j.LoggerFactory;
|
16
|
18
|
*/
|
17
|
19
|
public class NutzSetup implements Setup {
|
18
|
20
|
private Logger logger = LoggerFactory.getLogger(NutzSetup.class);
|
19
|
|
- //public static final Log logger = Logs.get();
|
20
|
21
|
|
21
|
22
|
private XxlJobExecutor xxlJobExecutor = null;
|
22
|
23
|
|
23
|
24
|
@Override
|
24
|
25
|
public void init(NutConfig cfg) {
|
25
|
26
|
|
26
|
|
- // regist JobHandler
|
27
|
|
- String[] beanNames = cfg.getIoc().getNamesByType(IJobHandler.class);
|
28
|
|
- if (beanNames==null || beanNames.length==0) {
|
29
|
|
- return;
|
30
|
|
- }
|
31
|
|
- for (String beanName : beanNames) {
|
32
|
|
- IJobHandler jobHandler = cfg.getIoc().get(IJobHandler.class, beanName);
|
33
|
|
- String name = jobHandler.getClass().getAnnotation(JobHandler.class).value();
|
34
|
|
- XxlJobExecutor.registJobHandler(name, jobHandler);
|
35
|
|
- }
|
|
27
|
+ // registry jobhandler
|
|
28
|
+ XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler());
|
|
29
|
+ XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler());
|
|
30
|
+ XxlJobExecutor.registJobHandler("httpJobHandler", new HttpJobHandler());
|
|
31
|
+ XxlJobExecutor.registJobHandler("commandJobHandler", new CommandJobHandler());
|
36
|
32
|
|
37
|
33
|
// load executor prop
|
38
|
34
|
PropertiesProxy xxlJobProp = new PropertiesProxy("xxl-job-executor.properties");
|