You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/06/20 15:11:09 UTC

[shardingsphere-elasticjob-lite] branch master updated: refactor Spring namespace (#799)

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-lite.git


The following commit(s) were added to refs/heads/master by this push:
     new 3597258  refactor Spring namespace (#799)
3597258 is described below

commit 3597258268895c8b68eab35f8cb8c5e046cf6ecb
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Jun 20 23:10:55 2020 +0800

    refactor Spring namespace (#799)
---
 .../elasticjob/lite/api/JobScheduler.java          | 30 ++++++++++------------
 .../elasticjob/lite/api/JobSchedulerTest.java      |  6 +----
 .../lite/integrate/AbstractBaseStdJobTest.java     |  7 +++--
 .../common/AbstractJobBeanDefinitionParser.java    |  5 +++-
 .../dataflow/DataflowJobBeanDefinitionParser.java  |  6 +----
 .../simple/SimpleJobBeanDefinitionParser.java      |  6 +----
 .../src/main/resources/META-INF/namespace/job.xsd  |  5 ++--
 .../resources/META-INF/job/withEventTraceRdb.xml   |  8 ++++--
 .../resources/META-INF/job/withJobProperties.xml   |  9 ++++---
 .../src/test/resources/META-INF/job/withJobRef.xml |  1 +
 .../test/resources/META-INF/job/withListener.xml   |  9 ++++---
 .../META-INF/job/withListenerAndCglib.xml          |  8 ++++--
 .../job/withListenerAndJdkDynamicProxy.xml         | 10 +++++---
 .../resources/META-INF/job/withoutListener.xml     |  8 ++++--
 .../src/test/resources/conf/job/conf.properties    |  1 -
 15 files changed, 66 insertions(+), 53 deletions(-)

diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java
index bde57cd..542460f 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java
@@ -25,9 +25,9 @@ import org.apache.shardingsphere.elasticjob.lite.api.strategy.JobInstance;
 import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
 import org.apache.shardingsphere.elasticjob.lite.event.JobEventBus;
 import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
 import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
 import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
+import org.apache.shardingsphere.elasticjob.lite.internal.config.provided.JobInstanceProvided;
 import org.apache.shardingsphere.elasticjob.lite.internal.guarantee.GuaranteeService;
 import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
 import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduleController;
@@ -36,7 +36,6 @@ import org.apache.shardingsphere.elasticjob.lite.internal.schedule.LiteJob;
 import org.apache.shardingsphere.elasticjob.lite.internal.schedule.LiteJobFacade;
 import org.apache.shardingsphere.elasticjob.lite.internal.schedule.SchedulerFacade;
 import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
-import org.apache.shardingsphere.elasticjob.lite.internal.config.provided.JobInstanceProvided;
 import org.quartz.JobBuilder;
 import org.quartz.JobDetail;
 import org.quartz.Scheduler;
@@ -57,6 +56,8 @@ public final class JobScheduler {
     
     private static final String JOB_FACADE_DATA_MAP_KEY = "jobFacade";
     
+    private final ElasticJob elasticJob;
+    
     private final LiteJobConfiguration liteJobConfig;
     
     private final CoordinatorRegistryCenter regCenter;
@@ -67,17 +68,19 @@ public final class JobScheduler {
     
     private final JobFacade jobFacade;
     
-    public JobScheduler(final CoordinatorRegistryCenter regCenter, final LiteJobConfiguration liteJobConfig, final ElasticJobListener... elasticJobListeners) {
-        this(regCenter, liteJobConfig, new JobEventBus(), elasticJobListeners);
+    public JobScheduler(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final LiteJobConfiguration liteJobConfig, final ElasticJobListener... elasticJobListeners) {
+        this(regCenter, elasticJob, liteJobConfig, new JobEventBus(), elasticJobListeners);
     }
     
-    public JobScheduler(final CoordinatorRegistryCenter regCenter, final LiteJobConfiguration liteJobConfig, final JobEventConfiguration jobEventConfig, 
+    public JobScheduler(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, final LiteJobConfiguration liteJobConfig, final JobEventConfiguration jobEventConfig, 
                         final ElasticJobListener... elasticJobListeners) {
-        this(regCenter, liteJobConfig, new JobEventBus(jobEventConfig), elasticJobListeners);
+        this(regCenter, elasticJob, liteJobConfig, new JobEventBus(jobEventConfig), elasticJobListeners);
     }
     
-    private JobScheduler(final CoordinatorRegistryCenter regCenter, final LiteJobConfiguration liteJobConfig, final JobEventBus jobEventBus, final ElasticJobListener... elasticJobListeners) {
+    private JobScheduler(final CoordinatorRegistryCenter regCenter, final ElasticJob elasticJob, 
+                         final LiteJobConfiguration liteJobConfig, final JobEventBus jobEventBus, final ElasticJobListener... elasticJobListeners) {
         JobRegistry.getInstance().addJobInstance(liteJobConfig.getJobName(), new JobInstance());
+        this.elasticJob = elasticJob;
         this.liteJobConfig = liteJobConfig;
         this.regCenter = regCenter;
         List<ElasticJobListener> elasticJobListenerList = Arrays.asList(elasticJobListeners);
@@ -101,8 +104,7 @@ public final class JobScheduler {
     public void init() {
         LiteJobConfiguration liteJobConfigFromRegCenter = schedulerFacade.updateJobConfiguration(liteJobConfig);
         JobRegistry.getInstance().setCurrentShardingTotalCount(liteJobConfigFromRegCenter.getJobName(), liteJobConfigFromRegCenter.getTypeConfig().getCoreConfig().getShardingTotalCount());
-        JobScheduleController jobScheduleController = new JobScheduleController(
-                createScheduler(), createJobDetail(liteJobConfigFromRegCenter.getTypeConfig().getJobClass()), liteJobConfigFromRegCenter.getJobName());
+        JobScheduleController jobScheduleController = new JobScheduleController(createScheduler(), createJobDetail(elasticJob), liteJobConfigFromRegCenter.getJobName());
         JobRegistry.getInstance().registerJob(liteJobConfigFromRegCenter.getJobName(), jobScheduleController, regCenter);
         schedulerFacade.registerStartUpInfo(!liteJobConfigFromRegCenter.isDisabled());
         jobScheduleController.scheduleJob(liteJobConfigFromRegCenter.getTypeConfig().getCoreConfig().getCron());
@@ -132,17 +134,13 @@ public final class JobScheduler {
         return result;
     }
     
-    private JobDetail createJobDetail(final String jobClass) {
+    private JobDetail createJobDetail(final ElasticJob elasticJob) {
         JobDetail result = JobBuilder.newJob(LiteJob.class).withIdentity(liteJobConfig.getJobName()).build();
         result.getJobDataMap().put(JOB_FACADE_DATA_MAP_KEY, jobFacade);
         if (liteJobConfig.getTypeConfig() instanceof JobInstanceProvided && null != ((JobInstanceProvided) liteJobConfig.getTypeConfig()).getJobInstance()) {
             result.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, ((JobInstanceProvided) liteJobConfig.getTypeConfig()).getJobInstance());
-        } else if (!jobClass.equals(ScriptJob.class.getCanonicalName())) {
-            try {
-                result.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, Class.forName(jobClass).newInstance());
-            } catch (final ReflectiveOperationException ex) {
-                throw new JobConfigurationException("Elastic-Job: Job class '%s' can not initialize.", jobClass);
-            }
+        } else if (!elasticJob.getClass().getName().equals(ScriptJob.class.getName())) {
+            result.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, elasticJob);
         }
         return result;
     }
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/JobSchedulerTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/JobSchedulerTest.java
index d776ce0..e11c731 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/JobSchedulerTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/JobSchedulerTest.java
@@ -17,7 +17,6 @@
 
 package org.apache.shardingsphere.elasticjob.lite.api;
 
-import org.apache.shardingsphere.elasticjob.lite.api.listener.fixture.ElasticJobListenerCaller;
 import org.apache.shardingsphere.elasticjob.lite.api.strategy.JobInstance;
 import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
 import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
@@ -51,9 +50,6 @@ public final class JobSchedulerTest {
     @Mock
     private SchedulerFacade schedulerFacade;
     
-    @Mock
-    private ElasticJobListenerCaller caller;
-    
     private LiteJobConfiguration liteJobConfig;
     
     private JobScheduler jobScheduler;
@@ -63,7 +59,7 @@ public final class JobSchedulerTest {
         JobRegistry.getInstance().addJobInstance("test_job", new JobInstance("127.0.0.1@-@0"));
         liteJobConfig = LiteJobConfiguration.newBuilder(
                 new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "* * 0/10 * * ? 2050", 3).build(), TestSimpleJob.class.getCanonicalName())).build();
-        jobScheduler = new JobScheduler(regCenter, liteJobConfig);
+        jobScheduler = new JobScheduler(regCenter, new TestSimpleJob(), liteJobConfig);
         MockitoAnnotations.initMocks(this);
         ReflectionUtils.setFieldValue(jobScheduler, "regCenter", regCenter);
         ReflectionUtils.setFieldValue(jobScheduler, "schedulerFacade", schedulerFacade);
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java
index b87cbf1..3c0afe1 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/integrate/AbstractBaseStdJobTest.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.elasticjob.lite.integrate;
 
 import lombok.AccessLevel;
 import lombok.Getter;
+import lombok.SneakyThrows;
 import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
 import org.apache.shardingsphere.elasticjob.lite.api.JobScheduler;
 import org.apache.shardingsphere.elasticjob.lite.api.dataflow.DataflowJob;
@@ -75,10 +76,11 @@ public abstract class AbstractBaseStdJobTest {
     @Getter(AccessLevel.PROTECTED)
     private final String jobName = System.nanoTime() + "_test_job";
     
+    @SneakyThrows
     protected AbstractBaseStdJobTest(final Class<? extends ElasticJob> elasticJobClass, final boolean disabled) {
         this.disabled = disabled;
         liteJobConfig = initJobConfig(elasticJobClass);
-        jobScheduler = new JobScheduler(regCenter, liteJobConfig, new ElasticJobListener() {
+        jobScheduler = new JobScheduler(regCenter, elasticJobClass.newInstance(), liteJobConfig, new ElasticJobListener() {
             
             @Override
             public void beforeJobExecuted(final ShardingContexts shardingContexts) {
@@ -103,10 +105,11 @@ public abstract class AbstractBaseStdJobTest {
         leaderService = new LeaderService(regCenter, jobName);
     }
     
+    @SneakyThrows
     protected AbstractBaseStdJobTest(final Class<? extends ElasticJob> elasticJobClass, final int monitorPort) {
         this.monitorPort = monitorPort;
         liteJobConfig = initJobConfig(elasticJobClass);
-        jobScheduler = new JobScheduler(regCenter, liteJobConfig);
+        jobScheduler = new JobScheduler(regCenter, elasticJobClass.newInstance(), liteJobConfig);
         disabled = false;
         leaderService = new LeaderService(regCenter, jobName);
     }
diff --git a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java
index 07d244d..5c56383 100644
--- a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java
+++ b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/common/AbstractJobBeanDefinitionParser.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.elasticjob.lite.spring.job.parser.common;
 
 import com.google.common.base.Strings;
+import lombok.SneakyThrows;
 import org.apache.shardingsphere.elasticjob.lite.api.JobScheduler;
 import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
 import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
@@ -41,11 +42,13 @@ import java.util.List;
  */
 public abstract class AbstractJobBeanDefinitionParser extends AbstractBeanDefinitionParser {
     
+    @SneakyThrows
     @Override
-    protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
+    protected final AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
         BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(JobScheduler.class);
         factory.setInitMethodName("init");
         factory.addConstructorArgReference(element.getAttribute(BaseJobBeanDefinitionParserTag.REGISTRY_CENTER_REF_ATTRIBUTE));
+        factory.addConstructorArgReference(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE));
         factory.addConstructorArgValue(createLiteJobConfiguration(parserContext, element));
         BeanDefinition jobEventConfig = createJobEventConfig(element);
         if (null != jobEventConfig) {
diff --git a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/dataflow/DataflowJobBeanDefinitionParser.java b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/dataflow/DataflowJobBeanDefinitionParser.java
index 91b9dc4..7162471 100644
--- a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/dataflow/DataflowJobBeanDefinitionParser.java
+++ b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/dataflow/DataflowJobBeanDefinitionParser.java
@@ -35,11 +35,7 @@ public final class DataflowJobBeanDefinitionParser extends AbstractJobBeanDefini
     protected BeanDefinition getJobTypeConfigurationBeanDefinition(final ParserContext parserContext, final BeanDefinition jobCoreConfigurationBeanDefinition, final Element element) {
         BeanDefinitionBuilder result = BeanDefinitionBuilder.rootBeanDefinition(InstanceProvidedDataflowJobConfiguration.class);
         result.addConstructorArgValue(jobCoreConfigurationBeanDefinition);
-        if (Strings.isNullOrEmpty(element.getAttribute(BaseJobBeanDefinitionParserTag.CLASS_ATTRIBUTE))) {
-            result.addConstructorArgValue(parserContext.getRegistry().getBeanDefinition(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE)).getBeanClassName());
-        } else {
-            result.addConstructorArgValue(element.getAttribute(BaseJobBeanDefinitionParserTag.CLASS_ATTRIBUTE));
-        }
+        result.addConstructorArgValue(parserContext.getRegistry().getBeanDefinition(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE)).getBeanClassName());
         result.addConstructorArgValue(element.getAttribute(DataflowJobBeanDefinitionParserTag.STREAMING_PROCESS_ATTRIBUTE));
         if (Strings.isNullOrEmpty(element.getAttribute(BaseJobBeanDefinitionParserTag.CLASS_ATTRIBUTE))) {
             result.addConstructorArgReference(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE));
diff --git a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/simple/SimpleJobBeanDefinitionParser.java b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/simple/SimpleJobBeanDefinitionParser.java
index dcddef3..64347b0 100644
--- a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/simple/SimpleJobBeanDefinitionParser.java
+++ b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/simple/SimpleJobBeanDefinitionParser.java
@@ -35,11 +35,7 @@ public final class SimpleJobBeanDefinitionParser extends AbstractJobBeanDefiniti
     protected BeanDefinition getJobTypeConfigurationBeanDefinition(final ParserContext parserContext, final BeanDefinition jobCoreConfigurationBeanDefinition, final Element element) {
         BeanDefinitionBuilder result = BeanDefinitionBuilder.rootBeanDefinition(InstanceProvidedSimpleJobConfiguration.class);
         result.addConstructorArgValue(jobCoreConfigurationBeanDefinition);
-        if (Strings.isNullOrEmpty(element.getAttribute(BaseJobBeanDefinitionParserTag.CLASS_ATTRIBUTE))) {
-            result.addConstructorArgValue(parserContext.getRegistry().getBeanDefinition(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE)).getBeanClassName());
-        } else {
-            result.addConstructorArgValue(element.getAttribute(BaseJobBeanDefinitionParserTag.CLASS_ATTRIBUTE));
-        }
+        result.addConstructorArgValue(parserContext.getRegistry().getBeanDefinition(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE)).getBeanClassName());
         if (Strings.isNullOrEmpty(element.getAttribute(BaseJobBeanDefinitionParserTag.CLASS_ATTRIBUTE))) {
             result.addConstructorArgReference(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE));
         } else {
diff --git a/elastic-job-lite-spring/src/main/resources/META-INF/namespace/job.xsd b/elastic-job-lite-spring/src/main/resources/META-INF/namespace/job.xsd
index f452ff3..bcc0e97 100644
--- a/elastic-job-lite-spring/src/main/resources/META-INF/namespace/job.xsd
+++ b/elastic-job-lite-spring/src/main/resources/META-INF/namespace/job.xsd
@@ -40,10 +40,9 @@
         <xsd:complexContent>
             <xsd:extension base="beans:identifiedType">
                 <xsd:all>
-                    <xsd:element ref="listener" minOccurs="0" maxOccurs="1" />
-                    <xsd:element ref="distributed-listener" minOccurs="0" maxOccurs="1" />
+                    <xsd:element ref="listener" minOccurs="0" />
+                    <xsd:element ref="distributed-listener" minOccurs="0" />
                 </xsd:all>
-                <xsd:attribute name="class" type="xsd:string" />
                 <xsd:attribute name="job-ref" type="xsd:string" />
                 <xsd:attribute name="registry-center-ref" type="xsd:string" use="required" />
                 <xsd:attribute name="cron" type="xsd:string" use="required" />
diff --git a/elastic-job-lite-spring/src/test/resources/META-INF/job/withEventTraceRdb.xml b/elastic-job-lite-spring/src/test/resources/META-INF/job/withEventTraceRdb.xml
index 1da1d90..5fd1c59 100644
--- a/elastic-job-lite-spring/src/test/resources/META-INF/job/withEventTraceRdb.xml
+++ b/elastic-job-lite-spring/src/test/resources/META-INF/job/withEventTraceRdb.xml
@@ -25,10 +25,14 @@
                         http://elasticjob.shardingsphere.apache.org/schema/job/job.xsd
                         ">
     <import resource="base.xml"/>
-    <job:simple id="simpleElasticJob_namespace_event_trace_rdb" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" registry-center-ref="regCenter" 
+    
+    <bean id="fooJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" />
+    <bean id="dataflowJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" />
+    
+    <job:simple id="simpleElasticJob_namespace_event_trace_rdb" job-ref="fooJob" registry-center-ref="regCenter" 
                 cron="${simpleJob.cron}" sharding-total-count="${simpleJob.shardingTotalCount}" sharding-item-parameters="${simpleJob.shardingItemParameters}" disabled="${simpleJob.disabled}" 
                 overwrite="${simpleJob.overwrite}" executor-service-handler="org.apache.shardingsphere.elasticjob.lite.spring.fixture.handler.SimpleExecutorServiceHandler" event-trace-rdb-data-source="elasticJobLog" />
-    <job:dataflow id="dataflowElasticJob_namespace_event_trace_rdb" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" registry-center-ref="regCenter" 
+    <job:dataflow id="dataflowElasticJob_namespace_event_trace_rdb" job-ref="dataflowJob" registry-center-ref="regCenter" 
                   cron="0/1 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" description="中文描述" overwrite="true" 
                   job-exception-handler="org.apache.shardingsphere.elasticjob.lite.spring.fixture.handler.SimpleJobExceptionHandler" />
 </beans>
diff --git a/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobProperties.xml b/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobProperties.xml
index 84c6938..39bccbe 100644
--- a/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobProperties.xml
+++ b/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobProperties.xml
@@ -25,10 +25,13 @@
                         http://elasticjob.shardingsphere.apache.org/schema/job/job.xsd
                         ">
     <import resource="base.xml"/>
-    <job:simple id="simpleElasticJob_namespace_job_properties" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" 
+    
+    <bean id="fooJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" />
+    <bean id="dataflowJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" />
+    
+    <job:simple id="simpleElasticJob_namespace_job_properties" job-ref="fooJob" 
                 registry-center-ref="regCenter" cron="${simpleJob.cron}" sharding-total-count="${simpleJob.shardingTotalCount}" sharding-item-parameters="${simpleJob.shardingItemParameters}" 
                 disabled="${simpleJob.disabled}" overwrite="${simpleJob.overwrite}" executor-service-handler="org.apache.shardingsphere.elasticjob.lite.spring.fixture.handler.SimpleExecutorServiceHandler" />
-    <job:dataflow id="dataflowElasticJob_namespace_job_properties" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" 
-                  registry-center-ref="regCenter" cron="0/1 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" 
+    <job:dataflow id="dataflowElasticJob_namespace_job_properties" job-ref="dataflowJob" registry-center-ref="regCenter" cron="0/1 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" 
                   description="中文描述" overwrite="true" job-exception-handler="org.apache.shardingsphere.elasticjob.lite.spring.fixture.handler.SimpleJobExceptionHandler" />
 </beans>
diff --git a/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobRef.xml b/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobRef.xml
index 1fa556d..b17e0e9 100644
--- a/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobRef.xml
+++ b/elastic-job-lite-spring/src/test/resources/META-INF/job/withJobRef.xml
@@ -31,6 +31,7 @@
     <bean id="refDataflowJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.ref.RefFooDataflowElasticJob">
         <property name="fooService" ref="foo" />
     </bean>
+    
     <job:simple id="simpleElasticJob_job_ref" job-ref="refSimpleJob" registry-center-ref="regCenter" cron="${simpleJob.cron}" sharding-total-count="${simpleJob.shardingTotalCount}" 
                 sharding-item-parameters="${simpleJob.shardingItemParameters}" disabled="${simpleJob.disabled}" overwrite="${simpleJob.overwrite}" 
                 executor-service-handler="org.apache.shardingsphere.elasticjob.lite.spring.fixture.handler.SimpleExecutorServiceHandler" />
diff --git a/elastic-job-lite-spring/src/test/resources/META-INF/job/withListener.xml b/elastic-job-lite-spring/src/test/resources/META-INF/job/withListener.xml
index f0aaa91..324aa1a 100644
--- a/elastic-job-lite-spring/src/test/resources/META-INF/job/withListener.xml
+++ b/elastic-job-lite-spring/src/test/resources/META-INF/job/withListener.xml
@@ -25,10 +25,13 @@
                         http://elasticjob.shardingsphere.apache.org/schema/job/job.xsd
                         ">
     <import resource="base.xml"/>
-    <job:simple id="${simpleJob.id}" class="${simpleJob.class}" registry-center-ref="regCenter" cron="${simpleJob.cron}" sharding-total-count="${simpleJob.shardingTotalCount}" sharding-item-parameters="${simpleJob.shardingItemParameters}" disabled="${simpleJob.disabled}" overwrite="${simpleJob.overwrite}">
+    
+    <bean id="fooJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" />
+    <bean id="dataflowJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" />
+    
+    <job:simple id="${simpleJob.id}" job-ref="fooJob" registry-center-ref="regCenter" cron="${simpleJob.cron}" sharding-total-count="${simpleJob.shardingTotalCount}" sharding-item-parameters="${simpleJob.shardingItemParameters}" disabled="${simpleJob.disabled}" overwrite="${simpleJob.overwrite}">
         <job:listener class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.listener.SimpleListener" />
         <job:distributed-listener class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.listener.SimpleOnceListener" started-timeout-milliseconds="10000" completed-timeout-milliseconds="20000" />
     </job:simple>
-    <job:dataflow id="dataflowElasticJob_namespace_listener" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" 
-                  registry-center-ref="regCenter" cron="0/1 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" description="中文描述" overwrite="true" />
+    <job:dataflow id="dataflowElasticJob_namespace_listener" job-ref="dataflowJob" registry-center-ref="regCenter" cron="0/1 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" description="中文描述" overwrite="true" />
 </beans>
diff --git a/elastic-job-lite-spring/src/test/resources/META-INF/job/withListenerAndCglib.xml b/elastic-job-lite-spring/src/test/resources/META-INF/job/withListenerAndCglib.xml
index b51f2ed..c1a70c7 100644
--- a/elastic-job-lite-spring/src/test/resources/META-INF/job/withListenerAndCglib.xml
+++ b/elastic-job-lite-spring/src/test/resources/META-INF/job/withListenerAndCglib.xml
@@ -33,11 +33,15 @@
     <context:component-scan base-package="org.apache.shardingsphere.elasticjob.lite.spring.fixture.aspect,org.apache.shardingsphere.elasticjob.lite.spring.fixture.service" />
     <aop:aspectj-autoproxy proxy-target-class="true" />
     <import resource="base.xml"/>
-    <job:simple id="simpleElasticJob_namespace_listener_cglib" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" 
+    
+    <bean id="fooJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" />
+    <bean id="dataflowJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" />
+    
+    <job:simple id="simpleElasticJob_namespace_listener_cglib" job-ref="fooJob" 
                 registry-center-ref="regCenter" cron="${simpleJob.cron}" sharding-total-count="${simpleJob.shardingTotalCount}" sharding-item-parameters="${simpleJob.shardingItemParameters}" 
                 disabled="${simpleJob.disabled}" overwrite="${simpleJob.overwrite}" event-trace-rdb-data-source="elasticJobLog">
         <job:listener class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.listener.SimpleCglibListener" />
     </job:simple>
-    <job:dataflow id="dataflowElasticJob_namespace_listener_cglib" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" 
+    <job:dataflow id="dataflowElasticJob_namespace_listener_cglib" job-ref="dataflowJob" 
                   registry-center-ref="regCenter" cron="0/1 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" description="中文描述" overwrite="true" streaming-process="true" />
 </beans>
diff --git a/elastic-job-lite-spring/src/test/resources/META-INF/job/withListenerAndJdkDynamicProxy.xml b/elastic-job-lite-spring/src/test/resources/META-INF/job/withListenerAndJdkDynamicProxy.xml
index 2e2c8a9..0077221 100644
--- a/elastic-job-lite-spring/src/test/resources/META-INF/job/withListenerAndJdkDynamicProxy.xml
+++ b/elastic-job-lite-spring/src/test/resources/META-INF/job/withListenerAndJdkDynamicProxy.xml
@@ -31,13 +31,17 @@
                         http://www.springframework.org/schema/aop/spring-aop.xsd
                         ">
     <context:component-scan base-package="org.apache.shardingsphere.elasticjob.lite.spring.fixture.aspect,org.apache.shardingsphere.elasticjob.lite.spring.fixture.service" />
-    <aop:aspectj-autoproxy proxy-target-class="false" />
+    <aop:aspectj-autoproxy />
     <import resource="base.xml" />
-    <job:simple id="simpleElasticJob_namespace_listener_jdk_proxy" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" 
+    
+    <bean id="fooJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" />
+    <bean id="dataflowJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" />
+    
+    <job:simple id="simpleElasticJob_namespace_listener_jdk_proxy" job-ref="fooJob" 
                 registry-center-ref="regCenter" cron="${simpleJob.cron}" sharding-total-count="${simpleJob.shardingTotalCount}" sharding-item-parameters="${simpleJob.shardingItemParameters}" 
                 disabled="${simpleJob.disabled}" overwrite="${simpleJob.overwrite}" event-trace-rdb-data-source="elasticJobLog">
         <job:listener class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.listener.SimpleJdkDynamicProxyListener" />
     </job:simple>
-    <job:dataflow id="dataflowElasticJob_namespace_listener_jdk_proxy" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" 
+    <job:dataflow id="dataflowElasticJob_namespace_listener_jdk_proxy" job-ref="dataflowJob"
                   registry-center-ref="regCenter" cron="0/1 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" description="中文描述" overwrite="true" streaming-process="true" />
 </beans>
diff --git a/elastic-job-lite-spring/src/test/resources/META-INF/job/withoutListener.xml b/elastic-job-lite-spring/src/test/resources/META-INF/job/withoutListener.xml
index 1e2c867..7239c72 100644
--- a/elastic-job-lite-spring/src/test/resources/META-INF/job/withoutListener.xml
+++ b/elastic-job-lite-spring/src/test/resources/META-INF/job/withoutListener.xml
@@ -25,10 +25,14 @@
                         http://elasticjob.shardingsphere.apache.org/schema/job/job.xsd
                         ">
     <import resource="base.xml" />
-    <job:simple id="simpleElasticJob_namespace" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" 
+    
+    <bean id="fooJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob" />
+    <bean id="dataflowJob" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" />
+    
+    <job:simple id="simpleElasticJob_namespace" job-ref="fooJob" 
                 registry-center-ref="regCenter" cron="${simpleJob.cron}" sharding-total-count="${simpleJob.shardingTotalCount}" sharding-item-parameters="${simpleJob.shardingItemParameters}" 
                 disabled="${simpleJob.disabled}" overwrite="${simpleJob.overwrite}" />
-    <job:dataflow id="dataflowElasticJob_namespace" class="org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.DataflowElasticJob" 
+    <job:dataflow id="dataflowElasticJob_namespace" job-ref="dataflowJob" 
                   registry-center-ref="regCenter" sharding-total-count="${dataflowJob.shardingTotalCount}" cron="${dataflowJob.cron}" sharding-item-parameters="${dataflowJob.shardingItemParameters}" 
                   monitor-execution="${dataflowJob.monitorExecution}" failover="${dataflowJob.failover}" description="${dataflowJob.description}" disabled="${dataflowJob.disabled}" 
                   overwrite="${dataflowJob.overwrite}" streaming-process="${dataflowJob.streamingProcess}" />
diff --git a/elastic-job-lite-spring/src/test/resources/conf/job/conf.properties b/elastic-job-lite-spring/src/test/resources/conf/job/conf.properties
index be3d19c..4344ae1 100644
--- a/elastic-job-lite-spring/src/test/resources/conf/job/conf.properties
+++ b/elastic-job-lite-spring/src/test/resources/conf/job/conf.properties
@@ -22,7 +22,6 @@ regCenter.maxSleepTimeMilliseconds=3000
 regCenter.maxRetries=3
 
 simpleJob.id=simpleElasticJob_namespace_listener
-simpleJob.class=org.apache.shardingsphere.elasticjob.lite.spring.fixture.job.FooSimpleElasticJob
 simpleJob.cron=0/1 * * * * ?
 simpleJob.shardingTotalCount=3
 simpleJob.shardingItemParameters=0=A,1=B,2=C