ZhiQinIsZhen opened a new issue #1971:
URL: https://github.com/apache/shardingsphere-elasticjob/issues/1971


   ## Feature Request
   
   **For English only**, other languages will not accept.
   Current version add some jobs,first wo need to add config to yml, such as
   ```properties
   elasticjob:
     simpleJob:
       elasticJobClass: com.auth.service.job.service.impl.TestSimpleJob
       cron: 0/5 * * * * ?
       shardingTotalCount: 3
       shardingItemParameters: 0=Beijing,1=Shanghai,2=Guangzhou
   ```
   
   we have to modify the configuration every time we add a task 
   This is too much trouble
   
   ### Is your feature request related to a problem?
   yes
   ### Describe the feature you would like.
   we can add a annotation,this annotation has the same fields with 
**org.apache.shardingsphere.elasticjob.lite.spring.boot.job.ElasticJobConfigurationProperties**
   
   Then we can add some code to 
**org.apache.shardingsphere.elasticjob.lite.spring.boot.job.ElasticJobBootstrapConfiguration#createJobBootstrapBeans**
 method
   such as
   ```java
   
   ElasticJobProperties elasticJobProperties = 
this.applicationContext.getBean(ElasticJobProperties.class);
           //扫描目标类
           Map<String, Object> beanMap = 
this.applicationContext.getBeansWithAnnotation(com.auth.common.job.annotation.ElasticJob
 .class);
           if (beanMap != null && beanMap.size() > 0) {
               for (Map.Entry<String, Object> entry : beanMap.entrySet()) {
                   String beanName = entry.getKey();
                   Class<?> clz = entry.getValue().getClass();
                   if (clz.isAssignableFrom(ElasticJob.class)) {
                       com.auth.common.job.annotation.ElasticJob elasticJob =
                               
clz.getAnnotation(com.auth.common.job.annotation.ElasticJob.class);
                       ElasticJobConfigurationProperties properties = new 
ElasticJobConfigurationProperties();
                       properties.setElasticJobClass((Class<? extends 
ElasticJob>) clz);
                       properties.setCron(elasticJob.cron());
                       
properties.setShardingTotalCount(elasticJob.shardingTotalCount());
                       
properties.setShardingItemParameters(elasticJob.shardingItemParameters());
                       properties.setOverwrite(elasticJob.overwrite());
                       ......
                       elasticJobProperties.getJobs().put(beanName, properties);
                   }
               }
           }
           SingletonBeanRegistry singletonBeanRegistry = 
((ConfigurableApplicationContext)this.applicationContext).getBeanFactory();
          ......
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to