Selaa lähdekoodia

update document

xuxueli 5 vuotta sitten
vanhempi
commit
e4d04a31b5

+ 9 - 13
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/config/NutzSetup.java Näytä tiedosto

1
 package com.xuxueli.executor.sample.nutz.config;
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
 import com.xxl.job.core.executor.XxlJobExecutor;
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
 import org.nutz.ioc.impl.PropertiesProxy;
8
 import org.nutz.ioc.impl.PropertiesProxy;
7
 import org.nutz.mvc.NutConfig;
9
 import org.nutz.mvc.NutConfig;
8
 import org.nutz.mvc.Setup;
10
 import org.nutz.mvc.Setup;
16
  */
18
  */
17
 public class NutzSetup implements Setup {
19
 public class NutzSetup implements Setup {
18
 	private Logger logger = LoggerFactory.getLogger(NutzSetup.class);
20
 	private Logger logger = LoggerFactory.getLogger(NutzSetup.class);
19
-	//public static final Log logger = Logs.get();
20
 
21
 
21
 	private XxlJobExecutor xxlJobExecutor = null;
22
 	private XxlJobExecutor xxlJobExecutor = null;
22
 
23
 
23
 	@Override
24
 	@Override
24
 	public void init(NutConfig cfg) {
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
 		// load executor prop
33
 		// load executor prop
38
 		PropertiesProxy xxlJobProp = new PropertiesProxy("xxl-job-executor.properties");
34
 		PropertiesProxy xxlJobProp = new PropertiesProxy("xxl-job-executor.properties");

+ 0 - 4
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/CommandJobHandler.java Näytä tiedosto

2
 
2
 
3
 import com.xxl.job.core.biz.model.ReturnT;
3
 import com.xxl.job.core.biz.model.ReturnT;
4
 import com.xxl.job.core.handler.IJobHandler;
4
 import com.xxl.job.core.handler.IJobHandler;
5
-import com.xxl.job.core.handler.annotation.JobHandler;
6
 import com.xxl.job.core.log.XxlJobLogger;
5
 import com.xxl.job.core.log.XxlJobLogger;
7
-import org.nutz.ioc.loader.annotation.IocBean;
8
 
6
 
9
 import java.io.BufferedInputStream;
7
 import java.io.BufferedInputStream;
10
 import java.io.BufferedReader;
8
 import java.io.BufferedReader;
15
  *
13
  *
16
  * @author xuxueli 2018-09-16 03:48:34
14
  * @author xuxueli 2018-09-16 03:48:34
17
  */
15
  */
18
-@JobHandler(value="commandJobHandler")
19
-@IocBean
20
 public class CommandJobHandler extends IJobHandler {
16
 public class CommandJobHandler extends IJobHandler {
21
 
17
 
22
     @Override
18
     @Override

+ 0 - 4
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/DemoJobHandler.java Näytä tiedosto

2
 
2
 
3
 import com.xxl.job.core.biz.model.ReturnT;
3
 import com.xxl.job.core.biz.model.ReturnT;
4
 import com.xxl.job.core.handler.IJobHandler;
4
 import com.xxl.job.core.handler.IJobHandler;
5
-import com.xxl.job.core.handler.annotation.JobHandler;
6
 import com.xxl.job.core.log.XxlJobLogger;
5
 import com.xxl.job.core.log.XxlJobLogger;
7
-import org.nutz.ioc.loader.annotation.IocBean;
8
 
6
 
9
 import java.util.concurrent.TimeUnit;
7
 import java.util.concurrent.TimeUnit;
10
 
8
 
19
  *
17
  *
20
  * @author xuxueli 2015-12-19 19:43:36
18
  * @author xuxueli 2015-12-19 19:43:36
21
  */
19
  */
22
-@JobHandler(value="demoJobHandler")
23
-@IocBean
24
 public class DemoJobHandler extends IJobHandler {
20
 public class DemoJobHandler extends IJobHandler {
25
 
21
 
26
 	@Override
22
 	@Override

+ 0 - 4
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/HttpJobHandler.java Näytä tiedosto

2
 
2
 
3
 import com.xxl.job.core.biz.model.ReturnT;
3
 import com.xxl.job.core.biz.model.ReturnT;
4
 import com.xxl.job.core.handler.IJobHandler;
4
 import com.xxl.job.core.handler.IJobHandler;
5
-import com.xxl.job.core.handler.annotation.JobHandler;
6
 import com.xxl.job.core.log.XxlJobLogger;
5
 import com.xxl.job.core.log.XxlJobLogger;
7
-import org.nutz.ioc.loader.annotation.IocBean;
8
 
6
 
9
 import java.io.BufferedReader;
7
 import java.io.BufferedReader;
10
 import java.io.InputStreamReader;
8
 import java.io.InputStreamReader;
16
  *
14
  *
17
  * @author xuxueli 2018-09-16 03:48:34
15
  * @author xuxueli 2018-09-16 03:48:34
18
  */
16
  */
19
-@JobHandler(value = "httpJobHandler")
20
-@IocBean
21
 public class HttpJobHandler extends IJobHandler {
17
 public class HttpJobHandler extends IJobHandler {
22
 
18
 
23
     @Override
19
     @Override

+ 0 - 5
xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/ShardingJobHandler.java Näytä tiedosto

1
 package com.xuxueli.executor.sample.nutz.jobhandler;
1
 package com.xuxueli.executor.sample.nutz.jobhandler;
2
 
2
 
3
-import com.xxl.job.core.handler.annotation.JobHandler;
4
-import org.nutz.ioc.loader.annotation.IocBean;
5
-
6
 import com.xxl.job.core.biz.model.ReturnT;
3
 import com.xxl.job.core.biz.model.ReturnT;
7
 import com.xxl.job.core.handler.IJobHandler;
4
 import com.xxl.job.core.handler.IJobHandler;
8
 import com.xxl.job.core.log.XxlJobLogger;
5
 import com.xxl.job.core.log.XxlJobLogger;
13
  *
10
  *
14
  * @author xuxueli 2017-07-25 20:56:50
11
  * @author xuxueli 2017-07-25 20:56:50
15
  */
12
  */
16
-@JobHandler(value="shardingJobHandler")
17
-@IocBean
18
 public class ShardingJobHandler extends IJobHandler {
13
 public class ShardingJobHandler extends IJobHandler {
19
 
14
 
20
 	@Override
15
 	@Override