This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new 6e6ef32  Update doc as jobListener move to JobConfiguration (#1468) 
(#1489)
6e6ef32 is described below

commit 6e6ef32f8f443a06ed3f5e46e9030d5bd0b8a665
Author: Tboy <[email protected]>
AuthorDate: Fri Sep 25 10:24:08 2020 +0800

    Update doc as jobListener move to JobConfiguration (#1468) (#1489)
---
 .../elasticjob-lite/configuration/java-api.cn.md   | 18 +---------------
 .../elasticjob-lite/configuration/java-api.en.md   | 18 +---------------
 .../configuration/spring-boot-starter.cn.md        |  1 +
 .../configuration/spring-boot-starter.en.md        |  1 +
 .../configuration/spring-namespace.cn.md           | 25 +---------------------
 .../configuration/spring-namespace.en.md           | 24 ---------------------
 .../usage/job-listener/java-api.cn.md              | 14 ++++++------
 .../usage/job-listener/java-api.en.md              | 14 ++++++------
 .../usage/job-listener/listener-interface.cn.md    | 14 ++++++++++++
 .../usage/job-listener/listener-interface.en.md    | 14 ++++++++++++
 .../usage/job-listener/spring-namespace.cn.md      |  5 +----
 .../usage/job-listener/spring-namespace.en.md      |  5 +----
 ...re.elasticjob.infra.listener.ElasticJobListener | 17 +++++++++++++++
 .../src/main/resources/conf/job.properties         |  5 -----
 14 files changed, 64 insertions(+), 111 deletions(-)

diff --git 
a/docs/content/user-manual/elasticjob-lite/configuration/java-api.cn.md 
b/docs/content/user-manual/elasticjob-lite/configuration/java-api.cn.md
index 63d7142..2bb2478 100644
--- a/docs/content/user-manual/elasticjob-lite/configuration/java-api.cn.md
+++ b/docs/content/user-manual/elasticjob-lite/configuration/java-api.cn.md
@@ -44,24 +44,8 @@ chapter = true
 | jobShardingStrategyType       | 否        |
 | jobExecutorServiceHandlerType | 否        |
 | jobErrorHandlerType           | 否        |
+| jobListenerTypes              | 否        |
 | description                   | 否        |
 | props                         | 否        |
 | disabled                      | 否        |
 | overwrite                     | 否        |
-
-## 作业监听器配置
-
-### 常规监听器配置
-
-接口名称:org.apache.shardingsphere.elasticjob.api.listener.ElasticJobListener
-
-可配置属性:无
-
-### 分布式监听器配置
-
-类名称:org.apache.shardingsphere.elasticjob.lite.api.listener.AbstractDistributeOnceElasticJobListener
-
-| 属性名                          | 构造器注入 |
-| ------------------------------ |:--------- |
-| started-timeout-milliseconds   | 是        |
-| completed-timeout-milliseconds | 是        |
diff --git 
a/docs/content/user-manual/elasticjob-lite/configuration/java-api.en.md 
b/docs/content/user-manual/elasticjob-lite/configuration/java-api.en.md
index bf1fddf..2f025cd 100644
--- a/docs/content/user-manual/elasticjob-lite/configuration/java-api.en.md
+++ b/docs/content/user-manual/elasticjob-lite/configuration/java-api.en.md
@@ -44,24 +44,8 @@ Configuration:
 | jobShardingStrategyType       | No                    |
 | jobExecutorServiceHandlerType | No                    |
 | jobErrorHandlerType           | No                    |
+| jobListenerTypes              | No                    |
 | description                   | No                    |
 | props                         | No                    |
 | disabled                      | No                    |
 | overwrite                     | No                    |
-
-## Job Listener Configuration
-
-### Common Listener Configuration
-
-Interface name: 
`org.apache.shardingsphere.elasticjob.api.listener.ElasticJobListener`
-
-Configuration: no
-
-### Distributed Listener Configuration
-
-Class name: 
`org.apache.shardingsphere.elasticjob.lite.api.listener.AbstractDistributeOnceElasticJobListener`
-
-| Name                           | Constructor injection |
-| ------------------------------ |:--------------------- |
-| started-timeout-milliseconds   | Yes                   |
-| completed-timeout-milliseconds | Yes                   |
diff --git 
a/docs/content/user-manual/elasticjob-lite/configuration/spring-boot-starter.cn.md
 
b/docs/content/user-manual/elasticjob-lite/configuration/spring-boot-starter.cn.md
index 419b4d0..7f25c02 100644
--- 
a/docs/content/user-manual/elasticjob-lite/configuration/spring-boot-starter.cn.md
+++ 
b/docs/content/user-manual/elasticjob-lite/configuration/spring-boot-starter.cn.md
@@ -59,6 +59,7 @@ elasticjob.reg-center.server-lists=localhost:6181
 | job-sharding-strategy-type        | 否       |
 | job-executor-service-handler-type | 否       |
 | job-error-handler-type            | 否       |
+| job-listener-types                | 否       |
 | description                       | 否       |
 | props                             | 否       |
 | disabled                          | 否       |
diff --git 
a/docs/content/user-manual/elasticjob-lite/configuration/spring-boot-starter.en.md
 
b/docs/content/user-manual/elasticjob-lite/configuration/spring-boot-starter.en.md
index 80def1b..2852abd 100644
--- 
a/docs/content/user-manual/elasticjob-lite/configuration/spring-boot-starter.en.md
+++ 
b/docs/content/user-manual/elasticjob-lite/configuration/spring-boot-starter.en.md
@@ -59,6 +59,7 @@ Configuration:
 | job-sharding-strategy-type        | No       |
 | job-executor-service-handler-type | No       |
 | job-error-handler-type            | No       |
+| job-listener-types                | No       |
 | description                       | No       |
 | props                             | No       |
 | disabled                          | No       |
diff --git 
a/docs/content/user-manual/elasticjob-lite/configuration/spring-namespace.cn.md 
b/docs/content/user-manual/elasticjob-lite/configuration/spring-namespace.cn.md
index cfd313f..952d9a1 100644
--- 
a/docs/content/user-manual/elasticjob-lite/configuration/spring-namespace.cn.md
+++ 
b/docs/content/user-manual/elasticjob-lite/configuration/spring-namespace.cn.md
@@ -59,35 +59,12 @@ chapter = true
 | job-sharding-strategy-type        | 否       |
 | job-executor-service-handler-type | 否       |
 | job-error-handler-type            | 否       |
+| job-listener-types                | 否       |
 | description                       | 否       |
 | props                             | 否       |
 | disabled                          | 否       |
 | overwrite                         | 否       |
 
-## 作业监听配置
-
-\<elasticjob:listener />
-
-elasticjob:listener 必须配置为 elasticjob:job 的子元素,并且在子元素中只允许出现一次
-
-可配置属性:
-
-| 属性名  | 类型   | 是否必填 | 缺省值 | 描述                                               |
-| ------ |:------ |:------- |:----- 
|:-------------------------------------------------- |
-| class  | String | 是      |       | 前置后置任务监听实现类,需实现 ElasticJobListener 接口 |
-
-\<elasticjob:distributed-listener />
-
-elasticjob:distributed-listener 必须配置为 elasticjob:job 的子元素,并且在子元素中只允许出现一次
-
-可配置属性:
-
-| 属性名                          | 类型   | 是否必填 | 缺省值          | 描述               
                                                         |
-| ------------------------------ |:------ |:------- |:-------------- 
|:--------------------------------------------------------------------------- |
-| class                          | String | 是      |                | 
前置后置任务分布式监听实现类,需继承 AbstractDistributeOnceElasticJobListener 类 |
-| started-timeout-milliseconds   | long   | 否      | Long.MAX_VALUE | 
最后一个作业执行前的执行方法的超时毫秒数                                         |
-| completed-timeout-milliseconds | long   | 否      | Long.MAX_VALUE | 
最后一个作业执行后的执行方法的超时毫秒数                                         |
-
 ## 事件追踪配置
 
 \<elasticjob:rdb-event-trace />
diff --git 
a/docs/content/user-manual/elasticjob-lite/configuration/spring-namespace.en.md 
b/docs/content/user-manual/elasticjob-lite/configuration/spring-namespace.en.md
index 27ef0e7..1bb3f58 100644
--- 
a/docs/content/user-manual/elasticjob-lite/configuration/spring-namespace.en.md
+++ 
b/docs/content/user-manual/elasticjob-lite/configuration/spring-namespace.en.md
@@ -64,30 +64,6 @@ Configuration:
 | disabled                          | No       |
 | overwrite                         | No       |
 
-## Job Listener Configuration
-
-\<elasticjob:listener />
-
-`elasticjob:listener` must be configured as a child element of 
`elasticjob:job`, and configure only once in the child element.
-
-Configuration: 
-
-| Name   | Data Type   | Required | Default Value | Description                
                                              |
-| ------ |:----------- |:-------- |:------------- 
|:------------------------------------------------------------------------ |
-| class  | String      | Yes      |               | Common listener class, 
need to implement `ElasticJobListener` interface  |
-
-\<elasticjob:distributed-listener />
-
-`elasticjob:distributed-listener` must be configured as a child element of 
`elasticjob:job`, and configure only once in the child element.
-
-Configuration: 
-
-| Name                           | Data Type   | Required | Default Value  | 
Description                                                                     
              |
-| ------------------------------ |:----------- |:-------- |:-------------- 
|:---------------------------------------------------------------------------------------------
 |
-| class                          | String      | Yes      |                | 
Distributed listener class, need to extend 
`AbstractDistributeOnceElasticJobListener` class   |
-| started-timeout-milliseconds   | long        | No       | Long.MAX_VALUE | 
The timeout in milliseconds before the last job is executed                     
              |
-| completed-timeout-milliseconds | long        | No       | Long.MAX_VALUE | 
The timeout in milliseconds after the last job is executed                      
              |
-
 ## Event Tracing Configuration
 
 \<elasticjob:rdb-event-trace />
diff --git 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/java-api.cn.md 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/java-api.cn.md
index 17247e8..af2003e 100644
--- a/docs/content/user-manual/elasticjob-lite/usage/job-listener/java-api.cn.md
+++ b/docs/content/user-manual/elasticjob-lite/usage/job-listener/java-api.cn.md
@@ -10,7 +10,7 @@ chapter = true
 public class JobMain {
     
     public static void main(String[] args) {
-        new ScheduleJobBootstrap(createRegistryCenter(), 
createJobConfiguration(), new MyElasticJobListener()).schedule();
+        new ScheduleJobBootstrap(createRegistryCenter(), 
createJobConfiguration()).schedule();
     }
     
     private static CoordinatorRegistryCenter createRegistryCenter() {
@@ -20,8 +20,8 @@ public class JobMain {
     }
     
     private static JobConfiguration createJobConfiguration() {
-        // 创建作业配置
-        ...
+        JobConfiguration jobConfiguration = 
JobConfiguration.newBuilder("test", 2)
+                                .jobListenerTypes("simpleListener", 
"distributeListener").build();
     }
 }
 ```
@@ -32,9 +32,7 @@ public class JobMain {
 public class JobMain {
     
     public static void main(String[] args) {
-        long startTimeoutMills = 5000L;
-        long completeTimeoutMills = 10000L;
-        new ScheduleJobBootstrap(createRegistryCenter(), 
createJobConfiguration(), new 
MyDistributeOnceElasticJobListener(startTimeoutMills, 
completeTimeoutMills)).schedule();
+        new ScheduleJobBootstrap(createRegistryCenter(), 
createJobConfiguration()).schedule();
     }
     
     private static CoordinatorRegistryCenter createRegistryCenter() {
@@ -44,8 +42,8 @@ public class JobMain {
     }
     
     private static JobConfiguration createJobConfiguration() {
-        // 创建作业配置
-        ...
+        JobConfiguration jobConfiguration = 
JobConfiguration.newBuilder("test", 2)
+                        .jobListenerTypes("simpleListener", 
"distributeListener").build();
     }
 }
 ```
diff --git 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/java-api.en.md 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/java-api.en.md
index 82cc94b..22dcfd7 100644
--- a/docs/content/user-manual/elasticjob-lite/usage/job-listener/java-api.en.md
+++ b/docs/content/user-manual/elasticjob-lite/usage/job-listener/java-api.en.md
@@ -10,7 +10,7 @@ chapter = true
 public class JobMain {
     
     public static void main(String[] args) {
-        new ScheduleJobBootstrap(createRegistryCenter(), 
createJobConfiguration(), new MyElasticJobListener()).schedule();
+        new ScheduleJobBootstrap(createRegistryCenter(), 
createJobConfiguration()).schedule();
     }
     
     private static CoordinatorRegistryCenter createRegistryCenter() {
@@ -20,8 +20,8 @@ public class JobMain {
     }
     
     private static JobConfiguration createJobConfiguration() {
-        // Create job configuration
-        ...
+        JobConfiguration jobConfiguration = 
JobConfiguration.newBuilder("test", 2)
+                                        .jobListenerTypes("simpleListener", 
"distributeListener").build();
     }
 }
 ```
@@ -32,9 +32,7 @@ public class JobMain {
 public class JobMain {
     
     public static void main(String[] args) {
-        long startTimeoutMills = 5000L;
-        long completeTimeoutMills = 10000L;
-        new ScheduleJobBootstrap(createRegistryCenter(), 
createJobConfiguration(), new 
MyDistributeOnceElasticJobListener(startTimeoutMills, 
completeTimeoutMills)).schedule();
+        new ScheduleJobBootstrap(createRegistryCenter(), 
createJobConfiguration()).schedule();
     }
     
     private static CoordinatorRegistryCenter createRegistryCenter() {
@@ -44,8 +42,8 @@ public class JobMain {
     }
     
     private static JobConfiguration createJobConfiguration() {
-        // Create job configuration
-        ...
+        JobConfiguration jobConfiguration = 
JobConfiguration.newBuilder("test", 2)
+                                                
.jobListenerTypes("simpleListener", "distributeListener").build();
     }
 }
 ```
diff --git 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/listener-interface.cn.md
 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/listener-interface.cn.md
index 1d423fb..6f2c637 100644
--- 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/listener-interface.cn.md
+++ 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/listener-interface.cn.md
@@ -22,6 +22,11 @@ public class MyJobListener implements ElasticJobListener {
     public void afterJobExecuted(ShardingContexts shardingContexts) {
         // do something ...
     }
+    
+    @Override
+    public String getType() {
+        return "simpleJobListener";
+    }
 }
 ```
 
@@ -47,5 +52,14 @@ public class MyDistributeOnceJobListener extends 
AbstractDistributeOnceElasticJo
     public void doAfterJobExecutedAtLastCompleted(ShardingContexts 
shardingContexts) {
         // do something ...
     }
+    
+    @Override
+    public String getType() {
+        return "distributeOnceJobListener";
+    }
 }
 ```
+
+## 添加SPI实现
+
+将JobListener实现添加至infra-common下resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener
diff --git 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/listener-interface.en.md
 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/listener-interface.en.md
index 2006fa3..4e3ad42 100644
--- 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/listener-interface.en.md
+++ 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/listener-interface.en.md
@@ -22,6 +22,11 @@ public class MyJobListener implements ElasticJobListener {
     public void afterJobExecuted(ShardingContexts shardingContexts) {
         // do something ...
     }
+   
+    @Override
+    public String getType() {
+        return "simpleJobListener";
+    }
 }
 ```
 
@@ -47,6 +52,15 @@ public class MyDistributeOnceJobListener extends 
AbstractDistributeOnceElasticJo
     public void doAfterJobExecutedAtLastCompleted(ShardingContexts 
shardingContexts) {
         // do something ...
     }
+    
+    @Override
+    public String getType() {
+        return "distributeOnceJobListener";
+    }
 }
 ```
 
+## Add SPI implementation
+
+Put JobListener implementation to module infra-common, 
resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener
+
diff --git 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/spring-namespace.cn.md
 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/spring-namespace.cn.md
index a43c798..466b5d8 100644
--- 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/spring-namespace.cn.md
+++ 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/spring-namespace.cn.md
@@ -22,10 +22,7 @@ chapter = true
     <!-- 配置作业 Bean -->
     <bean id="myJob" class="xxx.MyJob" />
     
-    <elasticjob:job id="${myJob.id}" job-ref="myJob" 
registry-center-ref="regCenter" sharding-total-count="3" cron="0/1 * * * * ?">
-        <!-- 配置作业监听器 -->
-        <elasticjob:listener class="xxx.MyJobListener" />
-        <elasticjob:distributed-listener 
class="xxx.MyDistributeOnceJobListener" started-timeout-milliseconds="10000" 
completed-timeout-milliseconds="20000" />
+    <elasticjob:job id="${myJob.id}" job-ref="myJob" 
registry-center-ref="regCenter" sharding-total-count="3" cron="0/1 * * * * ?" 
job-listener-types="simpleJobListener,distributeOnceJobListener">
     </elasticjob:job>
 </beans>
 ```
diff --git 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/spring-namespace.en.md
 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/spring-namespace.en.md
index c5f95bd..00ac867 100644
--- 
a/docs/content/user-manual/elasticjob-lite/usage/job-listener/spring-namespace.en.md
+++ 
b/docs/content/user-manual/elasticjob-lite/usage/job-listener/spring-namespace.en.md
@@ -22,10 +22,7 @@ chapter = true
     <!-- Configuration Job Bean -->
     <bean id="myJob" class="xxx.MyJob" />
     
-    <elasticjob:job id="${myJob.id}" job-ref="myJob" 
registry-center-ref="regCenter" sharding-total-count="3" cron="0/1 * * * * ?">
-        <!-- Configure job listener -->
-        <elasticjob:listener class="xxx.MyJobListener" />
-        <elasticjob:distributed-listener 
class="xxx.MyDistributeOnceJobListener" started-timeout-milliseconds="10000" 
completed-timeout-milliseconds="20000" />
+    <elasticjob:job id="${myJob.id}" job-ref="myJob" 
registry-center-ref="regCenter" sharding-total-count="3" cron="0/1 * * * * ?" 
job-listener-types="simpleJobListener,distributeOnceJobListener">
     </elasticjob:job>
 </beans>
 ```
diff --git 
a/elasticjob-infra/elasticjob-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener
 
b/elasticjob-infra/elasticjob-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener
new file mode 100644
index 0000000..6222972
--- /dev/null
+++ 
b/elasticjob-infra/elasticjob-infra-common/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.infra.listener.ElasticJobListener
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
diff --git 
a/examples/elasticjob-example-lite-spring/src/main/resources/conf/job.properties
 
b/examples/elasticjob-example-lite-spring/src/main/resources/conf/job.properties
index eaec9c5..c600af3 100644
--- 
a/examples/elasticjob-example-lite-spring/src/main/resources/conf/job.properties
+++ 
b/examples/elasticjob-example-lite-spring/src/main/resources/conf/job.properties
@@ -20,11 +20,6 @@ event.rdb.url=jdbc:h2:mem:job_event_storage
 event.rdb.username=sa
 event.rdb.password=
 
-listener.simple=org.apache.shardingsphere.elasticjob.lite.example.listener.SpringSimpleListener
-listener.distributed=org.apache.shardingsphere.elasticjob.lite.example.listener.SpringSimpleDistributeListener
-listener.distributed.startedTimeoutMilliseconds=1000
-listener.distributed.completedTimeoutMilliseconds=3000
-
 simple.id=springSimpleJob
 simple.cron=0/5 * * * * ?
 simple.shardingTotalCount=3

Reply via email to