diff --git a/doc/XXL-JOB官方文档.md b/doc/XXL-JOB官方文档.md index 0a043631..549c8b3d 100644 --- a/doc/XXL-JOB官方文档.md +++ b/doc/XXL-JOB官方文档.md @@ -2256,11 +2256,12 @@ public void execute() { - 5、【优化】任务线程名优化,提升可读性与问题定位效率(ISSUE-2527)。 ### 7.33 版本 v2.4.0 Release Notes[规划中] -- 1、【优化】[规划中]任务日志重构:一次调度只记录一条主任务,维护起止时间和状态。 +- 1、【优化】执行器任务Bean扫描逻辑优化:解决懒加载注解失效问题。 +- 2、【优化】[规划中]任务日志重构:一次调度只记录一条主任务,维护起止时间和状态。 - 普通任务:只记录一条主任务; - 广播任务:记录一条主任务,每个分片任务记录一条次任务,关联在主任务上; - 重试任务:失败时,新增主任务。所有调度记录,包括入口调度和重试调度,均挂载主任务上。 -- 2、【优化】[规划中]分片任务:全部完成后才会出发后置节点; +- 3、【优化】[规划中]分片任务:全部完成后才会出发后置节点; ### 7.34 版本 v2.4.1 Release Notes[规划中] - 1、[规划中]DAG流程任务 diff --git a/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java b/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java index 16dbc97e..953903c3 100644 --- a/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java +++ b/xxl-job-core/src/main/java/com/xxl/job/core/executor/impl/XxlJobSpringExecutor.java @@ -3,7 +3,6 @@ package com.xxl.job.core.executor.impl; import com.xxl.job.core.executor.XxlJobExecutor; import com.xxl.job.core.glue.GlueFactory; import com.xxl.job.core.handler.annotation.XxlJob; -import com.xxl.job.core.handler.impl.MethodJobHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; @@ -85,15 +84,18 @@ public class XxlJobSpringExecutor extends XxlJobExecutor implements ApplicationC // init job handler from method String[] beanDefinitionNames = applicationContext.getBeanNamesForType(Object.class, false, true); for (String beanDefinitionName : beanDefinitionNames) { + + // get bean Object bean = null; Lazy onBean = applicationContext.findAnnotationOnBean(beanDefinitionName, Lazy.class); if (onBean!=null){ - logger.debug("xxl-job skip @Lazy Bean:{}",beanDefinitionName); + logger.debug("xxl-job annotation scan, skip @Lazy Bean:{}", beanDefinitionName); continue; }else { bean = applicationContext.getBean(beanDefinitionName); } + // filter method Map annotatedMethods = null; // referred to :org.springframework.context.event.EventListenerMethodProcessor.processBean try { annotatedMethods = MethodIntrospector.selectMethods(bean.getClass(), @@ -110,12 +112,14 @@ public class XxlJobSpringExecutor extends XxlJobExecutor implements ApplicationC continue; } + // generate and regist method job handler for (Map.Entry methodXxlJobEntry : annotatedMethods.entrySet()) { Method executeMethod = methodXxlJobEntry.getKey(); XxlJob xxlJob = methodXxlJobEntry.getValue(); // regist registJobHandler(xxlJob, bean, executeMethod); } + } } @@ -131,4 +135,13 @@ public class XxlJobSpringExecutor extends XxlJobExecutor implements ApplicationC return applicationContext; } + /* + BeanDefinitionRegistryPostProcessor + registry.getBeanDefine() + @Override + public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { + this.registry = registry; + } + * */ + }