diff --git a/src/main/java/neatlogic/framework/process/spring/configuration/ItsmBaseConfiguration.java b/src/main/java/neatlogic/framework/process/spring/configuration/ItsmBaseConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..5cea68d5a728c104cf3221d8434f5e90b1d74b8c --- /dev/null +++ b/src/main/java/neatlogic/framework/process/spring/configuration/ItsmBaseConfiguration.java @@ -0,0 +1,48 @@ +package neatlogic.framework.process.spring.configuration; + +import neatlogic.framework.common.util.ModuleUtil; +import neatlogic.framework.process.stephandler.core.ProcessStepHandlerBase; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.Objects; + +@Configuration +public class ItsmBaseConfiguration { + + @Bean + public InstantiationAwareBeanPostProcessor getItsmInstantiationAwareBeanPostProcessor() { + return new InstantiationAwareBeanPostProcessor() { + @Override + public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException { + // 如果没有process模块,则不加载change模块Bean + if (beanClass.getName().startsWith("neatlogic.module.change")) { + if (ModuleUtil.getModuleById("process") == null) { + return new Object(); + } + } + // 如果没有process模块,则不加载event模块Bean + if (beanClass.getName().startsWith("neatlogic.module.event")) { + if (ModuleUtil.getModuleById("process") == null) { + return new Object(); + } + } + // 如果没有process模块,则不加载eoa模块Bean + if (beanClass.getName().startsWith("neatlogic.module.eoa")) { + if (ModuleUtil.getModuleById("process") == null) { + return new Object(); + } + } + // 如果没有process模块,则不加载ProcessStepHandlerBase子类Bean + if (Objects.equals(beanClass.getSuperclass(), ProcessStepHandlerBase.class)) { + if (ModuleUtil.getModuleById("process") == null) { + return new Object(); + } + } + return null; // 返回 null 表示不阻止 bean 的实例化 + } + }; + } +} diff --git a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerBase.java b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerBase.java index 1d57e31ca7aa8f5b778e77f9eff6b4f7292f1d45..f2facee8c719191f20136e545664caf2efc2e15f 100644 --- a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerBase.java +++ b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerBase.java @@ -73,7 +73,6 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.DigestUtils; import javax.annotation.Resource; @@ -170,7 +169,8 @@ public abstract class ProcessStepHandlerBase implements IProcessStepHandler { processTaskSerialNumberMapper = _processTaskSerialNumberMapper; } - @Autowired(required = false) +// @Autowired(required = false) + @Resource public void setIProcessStepHandlerUtil(IProcessStepHandlerUtil _processStepHandlerUtil) { IProcessStepHandlerUtil = _processStepHandlerUtil; }