From 06c72af1876bb8237498755273dd2b8ac53b6ac2 Mon Sep 17 00:00:00 2001
From: xuxueli <931591021@qq.com>
Date: Mon, 25 Dec 2017 18:29:39 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9ENutz=E6=89=A7=E8=A1=8C?=
=?UTF-8?q?=E5=99=A8Sample=E7=A4=BA=E4=BE=8B=E9=A1=B9=E7=9B=AE=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
doc/XXL-JOB官方文档.md | 61 ++++++++++---------
.../jfinal/config/JFinalCoreConfig.java | 3 +-
.../jfinal/controller/IndexController.java | 1 +
.../jfinal/jobhandler/DemoJobHandler.java | 9 ++-
.../resources/xxl-job-executor.properties | 2 +-
.../src/main/webapp/WEB-INF/web.xml | 6 ++
.../src/main/webapp/index.html | 1 +
.../executor/sample/nutz/MainModule.java | 27 ++++----
.../{MainSetup.java => config/NutzSetup.java} | 45 ++++++++------
.../nutz/jobhandler/DemoJobHandler.java | 22 ++++---
.../nutz/jobhandler/ShardingJobHandler.java | 9 +--
.../sample/nutz/module/IndexModule.java | 14 ++---
.../src/main/resources/ioc/dao.js | 38 ------------
.../src/main/resources/log4j.xml | 18 +++---
.../{custom => }/xxl-job-executor.properties | 4 +-
.../src/main/webapp/WEB-INF/index.jsp | 12 ----
.../src/main/webapp/WEB-INF/web.xml | 16 ++++-
.../src/main/webapp/index | 0
.../src/main/webapp/index.html | 1 +
.../service/jobhandler/DemoJobHandler.java | 8 +--
.../src/main/webapp/WEB-INF/web.xml | 7 ++-
.../src/main/webapp/index.html | 2 +-
.../service/jobhandler/DemoJobHandler.java | 8 +--
.../src/main/resources/application.properties | 2 +-
24 files changed, 149 insertions(+), 167 deletions(-)
create mode 100644 xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/index.html
rename xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/{MainSetup.java => config/NutzSetup.java} (51%)
delete mode 100644 xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/ioc/dao.js
rename xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/{custom => }/xxl-job-executor.properties (74%)
delete mode 100644 xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/index.jsp
delete mode 100644 xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index
create mode 100644 xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index.html
diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md
index 3b34f6f9..432bddb0 100644
--- a/doc/XXL-JOB官方文档.md
+++ b/doc/XXL-JOB官方文档.md
@@ -386,9 +386,11 @@ XXL-JOB是一个轻量级分布式任务调度框架,其核心设计目标是
任务逻辑以JobHandler的形式存在于“执行器”所在项目中,开发流程如下:
#### 步骤一:执行器项目中,开发JobHandler:
- - 1、 新建一个继承com.xxl.job.core.handler.IJobHandler的Java类;
- - 2、 该类被Spring容器扫描为Bean实例,如加“@Component”注解;
- - 3、 添加 “@JobHandler(value="自定义jobhandler名称")”注解,注解的value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
+
+ - 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”;
+ - 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例;
+ - 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
+ - 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
(可参考Sample示例执行器中的DemoJobHandler,见下图)
![输入图片说明](https://static.oschina.net/uploads/img/201607/23232347_oLlM.png "在这里输入图片标题")
@@ -1073,32 +1075,33 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 10、任务日志文件路径时间戳格式化时SimpleDateFormat并发问题解决;
### 6.20 版本 V1.9.0 特性[迭代中]
-- 1、新增任务运行模式 "GLUE模式(NodeJS) ",支持NodeJS脚本任务;
-- 2、脚本任务Shell、Python和Nodejs等支持获取分片参数;
-- 3、失败重试,完整支持:调度中心调度失败且启用"失败重试"策略时,将会自动重试一次;执行器执行失败且回调失败重试状态(新增失败重试状态返回值)时,也将会自动重试一次;
-- 4、失败告警策略扩展:默认提供邮件失败告警,可扩展短信等,扩展代码位置为 "JobFailMonitorHelper.failAlarm";
-- 5、执行器端口支持自动生成(小于等于0时),避免端口定义冲突;
-- 6、调度报表优化,支持时间区间筛选;
-- 7、Log组件支持输出异常栈信息,底层实现优化;
-- 8、告警邮件样式优化,调整为表格形式,邮件组件调整为commons-email简化邮件操作;
-- 9、项目依赖升级,如spring、jackson等;
-- 10、任务日志,记录发起调度的机器信息;
-- 11、交互优化,如登陆注销;
-- 12、任务Cron长度扩展支持至128位,支持负责类型Cron设置;
-- 13、执行器地址录入交互优化,地址长度扩展支持至512位,支持大规模执行器集群配置;
-- 14、任务参数“IJobHandler.execute”入参改为“String params”,增强入参通用性。
-- 15、JobHandler提供init/destroy方法,支持在JobHandler初始化和销毁时进行附加操作;
-- 16、任务注解调整为 “@JobHandler”,与任务抽象接口统一;
-- 17、修复任务监控线程被耗时任务阻塞的问题;
-- 18、修复任务监控线程无法监控任务触发和执行状态均未0的问题;
-- 19、执行器动态代理对象,拦截非业务方法的执行;
-- 20、修复JobThread捕获Error错误不更新JobLog的问题;
-- 21、修复任务列表界面左侧菜单合并时样式错乱问题;
-- 22、调度中心项目日志配置改为xml文件格式;
-- 23、Log地址格式兼容,支持非"/"结尾路径配置;
-- 24、底层系统日志级别规范调整,清理遗留代码;
-- 25、建表SQL优化,支持同步创建制定编码的库和表;
-- 26、Nutz执行器Sample示例项目;
+- 1、新增Nutz执行器Sample示例项目;
+- 2、新增任务运行模式 "GLUE模式(NodeJS) ",支持NodeJS脚本任务;
+- 3、脚本任务Shell、Python和Nodejs等支持获取分片参数;
+- 4、失败重试,完整支持:调度中心调度失败且启用"失败重试"策略时,将会自动重试一次;执行器执行失败且回调失败重试状态(新增失败重试状态返回值)时,也将会自动重试一次;
+- 5、失败告警策略扩展:默认提供邮件失败告警,可扩展短信等,扩展代码位置为 "JobFailMonitorHelper.failAlarm";
+- 6、执行器端口支持自动生成(小于等于0时),避免端口定义冲突;
+- 7、调度报表优化,支持时间区间筛选;
+- 8、Log组件支持输出异常栈信息,底层实现优化;
+- 9、告警邮件样式优化,调整为表格形式,邮件组件调整为commons-email简化邮件操作;
+- 10、项目依赖升级,如spring、jackson等;
+- 11、任务日志,记录发起调度的机器信息;
+- 12、交互优化,如登陆注销;
+- 13、任务Cron长度扩展支持至128位,支持负责类型Cron设置;
+- 14、执行器地址录入交互优化,地址长度扩展支持至512位,支持大规模执行器集群配置;
+- 15、任务参数“IJobHandler.execute”入参改为“String params”,增强入参通用性。
+- 16、JobHandler提供init/destroy方法,支持在JobHandler初始化和销毁时进行附加操作;
+- 17、任务注解调整为 “@JobHandler”,与任务抽象接口统一;
+- 18、修复任务监控线程被耗时任务阻塞的问题;
+- 19、修复任务监控线程无法监控任务触发和执行状态均未0的问题;
+- 20、执行器动态代理对象,拦截非业务方法的执行;
+- 21、修复JobThread捕获Error错误不更新JobLog的问题;
+- 22、修复任务列表界面左侧菜单合并时样式错乱问题;
+- 23、调度中心项目日志配置改为xml文件格式;
+- 24、Log地址格式兼容,支持非"/"结尾路径配置;
+- 25、底层系统日志级别规范调整,清理遗留代码;
+- 26、建表SQL优化,支持同步创建制定编码的库和表;
+
### TODO LIST
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/config/JFinalCoreConfig.java b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/config/JFinalCoreConfig.java
index aa5be69c..3b16c4af 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/config/JFinalCoreConfig.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/config/JFinalCoreConfig.java
@@ -17,8 +17,9 @@ public class JFinalCoreConfig extends JFinalConfig {
private Logger logger = LoggerFactory.getLogger(JFinalCoreConfig.class);
// ---------------------- xxl-job executor ----------------------
- XxlJobExecutor xxlJobExecutor = null;
+ private XxlJobExecutor xxlJobExecutor = null;
private void initXxlJobExecutor() {
+
// registry jobhandler
XxlJobExecutor.registJobHandler("demoJobHandler", new DemoJobHandler());
XxlJobExecutor.registJobHandler("shardingJobHandler", new ShardingJobHandler());
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/controller/IndexController.java b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/controller/IndexController.java
index b00c773b..2c47b73f 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/controller/IndexController.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/controller/IndexController.java
@@ -7,4 +7,5 @@ public class IndexController extends Controller {
public void index(){
renderText("xxl job executor running.");
}
+
}
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/DemoJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/DemoJobHandler.java
index ceec9b44..bf4e888d 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/DemoJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/java/com/xuxueli/executor/sample/jfinal/jobhandler/DemoJobHandler.java
@@ -6,14 +6,13 @@ import com.xxl.job.core.log.XxlJobLogger;
import java.util.concurrent.TimeUnit;
-
/**
- * 任务Handler的一个Demo(Bean模式)
+ * 任务Handler示例(Bean模式)
*
* 开发步骤:
- * 1、继承 “IJobHandler” ;
- * 2、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
- * 3、在 "JFinalCoreConfig" 中注册,执行Jobhandler名称;
+ * 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”;
+ * 2、注册到执行器工厂:在 "JFinalCoreConfig.initXxlJobExecutor" 中手动注册,注解key值对应的是调度中心新建任务的JobHandler属性的值。
+ * 3、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
*
* @author xuxueli 2015-12-19 19:43:36
*/
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/resources/xxl-job-executor.properties b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/resources/xxl-job-executor.properties
index 19be360e..4cafd293 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/resources/xxl-job-executor.properties
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/resources/xxl-job-executor.properties
@@ -4,7 +4,7 @@ xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
### xxl-job executor address
xxl.job.executor.appname=xxl-job-executor-sample
xxl.job.executor.ip=
-xxl.job.executor.port=9997
+xxl.job.executor.port=9996
### xxl-job log path
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/WEB-INF/web.xml b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/WEB-INF/web.xml
index 418f9cc3..208179ce 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/WEB-INF/web.xml
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/WEB-INF/web.xml
@@ -3,6 +3,7 @@
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
+
xxl-job-executor-sample-jfinal
webAppRootKey
@@ -23,4 +24,9 @@
/*
+
+
+ index.html
+
+
\ No newline at end of file
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/index.html b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/index.html
new file mode 100644
index 00000000..7085239b
--- /dev/null
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-jfinal/src/main/webapp/index.html
@@ -0,0 +1 @@
+i am alive.
\ No newline at end of file
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainModule.java b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainModule.java
index 01e1b34f..a8163ff9 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainModule.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainModule.java
@@ -1,26 +1,23 @@
package com.xuxueli.executor.sample.nutz;
-import org.nutz.mvc.annotation.Encoding;
-import org.nutz.mvc.annotation.Fail;
-import org.nutz.mvc.annotation.IocBy;
-import org.nutz.mvc.annotation.Localization;
-import org.nutz.mvc.annotation.Modules;
-import org.nutz.mvc.annotation.Ok;
-import org.nutz.mvc.annotation.SetupBy;
+import com.xuxueli.executor.sample.nutz.config.NutzSetup;
+import org.nutz.mvc.annotation.*;
import org.nutz.mvc.ioc.provider.ComboIocProvider;
+
/**
- *
- * @author 邓华锋
+ * nutz module
*
+ * @author xuxueli 2017-12-25 17:58:43
*/
-@IocBy(type=ComboIocProvider.class,args={"*org.nutz.ioc.loader.json.JsonLoader","ioc/",
- "*org.nutz.ioc.loader.annotation.AnnotationIocLoader","com.xuxueli"})
-@Encoding(input="utf-8",output="utf-8")
-@Modules(scanPackage=true)
+@IocBy(type = ComboIocProvider.class,
+ args = {"*org.nutz.ioc.loader.annotation.AnnotationIocLoader",
+ "com.xuxueli.executor.sample.nutz"})
+@Encoding(input = "utf-8", output = "utf-8")
+@Modules(scanPackage = true)
@Localization("msg")
@Ok("json")
@Fail("json")
-@SetupBy(MainSetup.class)
+@SetupBy(NutzSetup.class)
public class MainModule {
-
+
}
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainSetup.java b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/config/NutzSetup.java
similarity index 51%
rename from xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainSetup.java
rename to xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/config/NutzSetup.java
index b2192392..cc7c9c24 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/MainSetup.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/config/NutzSetup.java
@@ -1,33 +1,41 @@
-package com.xuxueli.executor.sample.nutz;
+package com.xuxueli.executor.sample.nutz.config;
-import org.nutz.ioc.IocException;
+import com.xxl.job.core.executor.XxlJobExecutor;
+import com.xxl.job.core.handler.IJobHandler;
+import com.xxl.job.core.handler.annotation.JobHandler;
import org.nutz.ioc.impl.PropertiesProxy;
-import org.nutz.log.Log;
-import org.nutz.log.Logs;
import org.nutz.mvc.NutConfig;
import org.nutz.mvc.Setup;
-
-import com.xxl.job.core.executor.XxlJobExecutor;
-import com.xxl.job.core.handler.IJobHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- *
- * @author 邓华锋
+ * nutz setup
*
+ * @author xuxueli 2017-12-25 17:58:43
*/
-public class MainSetup implements Setup {
- public static final Log log = Logs.get();
- XxlJobExecutor xxlJobExecutor = null;
+public class NutzSetup implements Setup {
+ private Logger logger = LoggerFactory.getLogger(NutzSetup.class);
+ //public static final Log logger = Logs.get();
+
+ private XxlJobExecutor xxlJobExecutor = null;
@Override
public void init(NutConfig cfg) {
- // 通用注册IJobHandler
- String[] names = cfg.getIoc().getNamesByType(IJobHandler.class);
- for (String name : names) {
- XxlJobExecutor.registJobHandler(name, cfg.getIoc().get(IJobHandler.class, name));
+
+ // regist JobHandler
+ String[] beanNames = cfg.getIoc().getNamesByType(IJobHandler.class);
+ if (beanNames==null || beanNames.length==0) {
+ return;
+ }
+ for (String beanName : beanNames) {
+ IJobHandler jobHandler = cfg.getIoc().get(IJobHandler.class, beanName);
+ String name = jobHandler.getClass().getAnnotation(JobHandler.class).value();
+ XxlJobExecutor.registJobHandler(name, jobHandler);
}
+
// load executor prop
- PropertiesProxy xxlJobProp = cfg.getIoc().get(PropertiesProxy.class, "conf");
+ PropertiesProxy xxlJobProp = new PropertiesProxy("xxl-job-executor.properties");
// init executor
xxlJobExecutor = new XxlJobExecutor();
@@ -42,7 +50,7 @@ public class MainSetup implements Setup {
try {
xxlJobExecutor.start();
} catch (Exception e) {
- log.error(e.getMessage(), e);
+ logger.error(e.getMessage(), e);
}
}
@@ -52,4 +60,5 @@ public class MainSetup implements Setup {
xxlJobExecutor.destroy();
}
}
+
}
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/DemoJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/DemoJobHandler.java
index b37eb256..20f1b3ba 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/DemoJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/DemoJobHandler.java
@@ -1,36 +1,38 @@
package com.xuxueli.executor.sample.nutz.jobhandler;
-import java.util.concurrent.TimeUnit;
-
-import org.nutz.ioc.loader.annotation.IocBean;
-
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.nutz.ioc.loader.annotation.IocBean;
+import java.util.concurrent.TimeUnit;
/**
- * 任务Handler的一个Demo(Bean模式)
+ * 任务Handler示例(Bean模式)
*
* 开发步骤:
- * 1、继承 “IJobHandler” ;
- * 2、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
- * 3、在 "JFinalCoreConfig" 中注册,执行Jobhandler名称;
+ * 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”;
+ * 2、注册到Nutz容器:添加“@IocBean”注解,被Nutz容器扫描为Bean实例;
+ * 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
+ * 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
*
* @author xuxueli 2015-12-19 19:43:36
*/
+@JobHandler(value="demoJobHandler")
@IocBean
public class DemoJobHandler extends IJobHandler {
@Override
- public ReturnT execute(String... params) throws Exception {
+ public ReturnT execute(String param) throws Exception {
XxlJobLogger.log("XXL-JOB, Hello World.");
for (int i = 0; i < 5; i++) {
XxlJobLogger.log("beat at:" + i);
TimeUnit.SECONDS.sleep(2);
}
- return ReturnT.SUCCESS;
+ return SUCCESS;
}
}
+
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/ShardingJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/ShardingJobHandler.java
index db31758c..f374731d 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/ShardingJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/jobhandler/ShardingJobHandler.java
@@ -1,5 +1,6 @@
package com.xuxueli.executor.sample.nutz.jobhandler;
+import com.xxl.job.core.handler.annotation.JobHandler;
import org.nutz.ioc.loader.annotation.IocBean;
import com.xxl.job.core.biz.model.ReturnT;
@@ -7,17 +8,17 @@ import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.log.XxlJobLogger;
import com.xxl.job.core.util.ShardingUtil;
-
/**
* 分片广播任务
*
* @author xuxueli 2017-07-25 20:56:50
*/
+@JobHandler(value="shardingJobHandler")
@IocBean
public class ShardingJobHandler extends IJobHandler {
@Override
- public ReturnT execute(String... params) throws Exception {
+ public ReturnT execute(String param) throws Exception {
// 分片参数
ShardingUtil.ShardingVO shardingVO = ShardingUtil.getShardingVo();
@@ -32,7 +33,7 @@ public class ShardingJobHandler extends IJobHandler {
}
}
- return ReturnT.SUCCESS;
+ return SUCCESS;
}
-
+
}
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/module/IndexModule.java b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/module/IndexModule.java
index 0a103e6c..0cd0233d 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/module/IndexModule.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/java/com/xuxueli/executor/sample/nutz/module/IndexModule.java
@@ -3,16 +3,14 @@ package com.xuxueli.executor.sample.nutz.module;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
-/**
- *
- * @author 邓华锋
- *
- */
+
@IocBean
public class IndexModule {
- @At
- @Ok("jsp:index")
- public void index() {
+ @At("/")
+ @Ok("json")
+ public String index() {
+ return "xxl job executor running.";
}
+
}
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/ioc/dao.js b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/ioc/dao.js
deleted file mode 100644
index cc80b0a7..00000000
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/ioc/dao.js
+++ /dev/null
@@ -1,38 +0,0 @@
-var ioc = {
- conf : {
- type : "org.nutz.ioc.impl.PropertiesProxy",
- fields : {
- paths : [ "custom/" ]
- }
- },
- /**
- * 配置单例job执行
- */
- /*xxlJobExecutor : {
- type : "com.xxl.job.core.executor.XxlJobExecutor",
- events : {
- create : "start",
- depose : "destroy"
- },
- fields : {
- ip : {
- java : "$conf.get('xxl.job.executor.ip')"
- },
- port : {
- java : "$conf.get('xxl.job.executor.port')"
- },
- appName : {
- java : "$conf.get('xxl.job.executor.appname')"
- },
- adminAddresses : {
- java : "$conf.get('xxl.job.admin.addresses')"
- },
- logPath : {
- java : "$conf.get('xxl.job.executor.logpath')"
- },
- accessToken : {
- java : "$conf.get('xxl.job.accessToken')"
- }
- }
- }*/
-};
\ No newline at end of file
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/log4j.xml b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/log4j.xml
index f6196a83..b9ba6cef 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/log4j.xml
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/log4j.xml
@@ -2,19 +2,19 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/custom/xxl-job-executor.properties b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/xxl-job-executor.properties
similarity index 74%
rename from xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/custom/xxl-job-executor.properties
rename to xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/xxl-job-executor.properties
index 6617671c..19be360e 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/custom/xxl-job-executor.properties
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/resources/xxl-job-executor.properties
@@ -4,10 +4,10 @@ xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
### xxl-job executor address
xxl.job.executor.appname=xxl-job-executor-sample
xxl.job.executor.ip=
-xxl.job.executor.port=1024
+xxl.job.executor.port=9997
### xxl-job log path
-xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler/
+xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler
### xxl-job, access token
xxl.job.accessToken=
\ No newline at end of file
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/index.jsp b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/index.jsp
deleted file mode 100644
index 03f281fd..00000000
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/index.jsp
+++ /dev/null
@@ -1,12 +0,0 @@
-<%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
-
-
-
-
-nutz 执行器启动成功
-
-
-nutz 执行器启动成功!
-
-
\ No newline at end of file
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/web.xml b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/web.xml
index 97bbf405..19f2817f 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/web.xml
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/WEB-INF/web.xml
@@ -3,9 +3,16 @@
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
+
xxl-job-executor-sample-nutz
+
+ webAppRootKey
+ xxl-job-executor-sample-nutz
+
+
+
- xxl-job-executor-sample-nutz
+ nutz
org.nutz.mvc.NutFilter
modules
@@ -13,10 +20,13 @@
- xxl-job-executor-sample-nutz
+ nutz
/*
+
+
- index
+ index.html
+
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index
deleted file mode 100644
index e69de29b..00000000
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index.html b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index.html
new file mode 100644
index 00000000..7085239b
--- /dev/null
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-nutz/src/main/webapp/index.html
@@ -0,0 +1 @@
+i am alive.
\ No newline at end of file
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
index c5fa304d..a1a9c72d 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
@@ -10,12 +10,12 @@ import java.util.concurrent.TimeUnit;
/**
- * 任务Handler的一个Demo(Bean模式)
+ * 任务Handler示例(Bean模式)
*
* 开发步骤:
- * 1、新建一个继承com.xxl.job.core.handler.IJobHandler的Java类;
- * 2、该类被Spring容器扫描为Bean实例,如加“@Component”注解;
- * 3、添加 “@JobHandler(value="自定义jobhandler名称")”注解,注解的value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
+ * 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”;
+ * 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例;
+ * 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
* 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
*
* @author xuxueli 2015-12-19 19:43:36
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/WEB-INF/web.xml b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/WEB-INF/web.xml
index 55b78eed..9179af7b 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/WEB-INF/web.xml
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/WEB-INF/web.xml
@@ -3,12 +3,14 @@
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
+
xxl-job-executor-sample-spring
webAppRootKey
xxl-job-executor-sample-spring
-
+
+
contextConfigLocation
classpath*:applicationcontext-*.xml
@@ -20,7 +22,8 @@
org.springframework.web.context.ContextLoaderListener
-
+
+
index.html
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/index.html b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/index.html
index ae4ee13c..7085239b 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/index.html
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-spring/src/main/webapp/index.html
@@ -1 +1 @@
-200
\ No newline at end of file
+i am alive.
\ No newline at end of file
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
index 01b4db84..1768e48e 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/DemoJobHandler.java
@@ -10,12 +10,12 @@ import java.util.concurrent.TimeUnit;
/**
- * 任务Handler的一个Demo(Bean模式)
+ * 任务Handler示例(Bean模式)
*
* 开发步骤:
- * 1、新建一个继承com.xxl.job.core.handler.IJobHandler的Java类;
- * 2、该类被Spring容器扫描为Bean实例,如加“@Component”注解;
- * 3、添加 “@JobHandler(value="自定义jobhandler名称")”注解,注解的value值为自定义的JobHandler名称,该名称对应的是调度中心新建任务的JobHandler属性的值。
+ * 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”;
+ * 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例;
+ * 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。
* 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志;
*
* @author xuxueli 2015-12-19 19:43:36
diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties
index 6c441571..71fb98f2 100644
--- a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties
+++ b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/resources/application.properties
@@ -11,7 +11,7 @@ xxl.job.admin.addresses=http://127.0.0.1:8080/xxl-job-admin
### xxl-job executor address
xxl.job.executor.appname=xxl-job-executor-sample
xxl.job.executor.ip=
-xxl.job.executor.port=-1
+xxl.job.executor.port=9998
### xxl-job log path
xxl.job.executor.logpath=/data/applogs/xxl-job/jobhandler