diff --git a/doc/XXL-JOB-English-Documentation.md b/doc/XXL-JOB-English-Documentation.md index 4df32309..df897b61 100644 --- a/doc/XXL-JOB-English-Documentation.md +++ b/doc/XXL-JOB-English-Documentation.md @@ -603,9 +603,7 @@ The task logic exist in the executor project as JobHandler,the develop steps as - 1, create new java class implent com.xxl.job.core.handler.IJobHandler; - 2, if you add @Component annotation on the top of the class name it’s will be managed as a bean instance by spring container; - 3, add “@JobHandler(value=" customize jobhandler name")” annotation,the value stand for JobHandler name,it will be used as JobHandler property when create a new task in the schedule center. - (go and see DemoJobHandler in the xxl-job-executor-example project, as shown below) -![输入图片说明](https://www.xuxueli.com/doc/static/xxl-job/images/img_oLlM.png "在这里输入图片标题") #### Step 2:create task in schedule center If you want learn more about configure item please go and sedd “Description of configuration item”,select "BEAN模式" as run mode,property JobHandler please fill in the value defined by @JobHande. diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index d27d13f3..c73cf1b0 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -685,17 +685,23 @@ public XxlJobSpringExecutor xxlJobExecutor() { - 执行参数:任务执行所需的参数; ### 3.1 BEAN模式 -任务逻辑以JobHandler的形式存在于“执行器”所在项目中,开发流程如下: +任务逻辑以注解方法的形式存在于“执行器”所在项目中(任务方法底层会自动生成代理JobHandler),开发流程如下: -#### 步骤一:执行器项目中,开发JobHandler: +#### 步骤一:执行器项目中,开发Job方法: - - 1、继承"IJobHandler":“com.xxl.job.core.handler.IJobHandler”; - - 2、注册到Spring容器:添加“@Component”注解,被Spring容器扫描为Bean实例; - - 3、注册到执行器工厂:添加“@JobHandler(value="自定义jobhandler名称")”注解,注解value值对应的是调度中心新建任务的JobHandler属性的值。 - - 4、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志; - (可参考Sample示例执行器中的DemoJobHandler,见下图) + - 1、在Spring Bean实例中,开发Job方法,方式格式要求为 "public ReturnT execute(String param)" + - 2、为Job方法添加注解 "@XxlJob(value="自定义jobhandler名称", init = "JobHandler初始化方法", destroy = "JobHandler销毁方法")",注解value值对应的是调度中心新建任务的JobHandler属性的值。 + - 3、执行日志:需要通过 "XxlJobLogger.log" 打印执行日志; + +``` +// 可参考Sample示例执行器中的 "com.xxl.job.executor.service.jobhandler.SampleXxlJob" ,如下: +@XxlJob("demoJobHandler") +public ReturnT execute(String param) { -![输入图片说明](https://www.xuxueli.com/doc/static/xxl-job/images/img_oLlM.png "在这里输入图片标题") + XxlJobLogger.log("hello world."); + return ReturnT.SUCCESS; +} +``` #### 步骤二:调度中心,新建调度任务 参考上文“配置属性详细说明”对新建的任务进行参数配置,运行模式选中 "BEAN模式",JobHandler属性填写任务注解“@JobHandler”中定义的值; diff --git a/doc/images/img_oLlM.png b/doc/images/img_oLlM.png deleted file mode 100644 index f930be47..00000000 Binary files a/doc/images/img_oLlM.png and /dev/null differ diff --git a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java index 854866d1..d740cf88 100644 --- a/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java +++ b/xxl-job-executor-samples/xxl-job-executor-sample-springboot/src/main/java/com/xxl/job/executor/service/jobhandler/SampleXxlJob.java @@ -22,14 +22,14 @@ public class SampleXxlJob { @XxlJob("demoJobHandler2") public ReturnT execute(String param) { - XxlJobLogger.log("222"); + XxlJobLogger.log("hello world."); return ReturnT.SUCCESS; } @XxlJob(value="demoJobHandler3", init = "init", destroy = "destory") public ReturnT execute3(String param) { - XxlJobLogger.log("333"); + XxlJobLogger.log("hello world."); return ReturnT.SUCCESS; }