From bee371d0f3c53f22ac5ce70881822770bae33aba Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Sat, 23 Dec 2023 23:06:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E6=B2=A1=E6=9C=89pr?= =?UTF-8?q?ocess=E6=A8=A1=E5=9D=97=E6=97=B6=EF=BC=8C=E4=B8=8D=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E4=B8=8Eprocess=E6=A8=A1=E5=9D=97=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84Bean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1053044454686720]没有process模块时,不加载与process模块相关的Bean http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1053044454686720 --- .../process/stephandler/core/ProcessStepHandlerFactory.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerFactory.java b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerFactory.java index 89c3e4f6..0188f4a6 100644 --- a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerFactory.java +++ b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerFactory.java @@ -74,9 +74,12 @@ public class ProcessStepHandlerFactory extends ModuleInitializedListenerBase { @Override public void onInitialized(NeatLogicWebApplicationContext context) { +// ItsmInstantiationAwareBeanPostProcessor bean = context.getBean(ItsmInstantiationAwareBeanPostProcessor.class); +// System.out.println("bean = " + bean); Map myMap = context.getBeansOfType(IProcessStepHandler.class); for (Map.Entry entry : myMap.entrySet()) { IProcessStepHandler component = entry.getValue(); + System.out.println("component = " + component); if (component.getHandler() != null) { componentMap.put(component.getHandler(), component); ProcessStepHandlerVo processStepHandlerVo = new ProcessStepHandlerVo(); -- Gitee From 188251655ff772237edd805f299b2dbf96f8c8e3 Mon Sep 17 00:00:00 2001 From: linbangquan <1437892690@qq.com> Date: Sun, 24 Dec 2023 00:00:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E6=B2=A1=E6=9C=89pr?= =?UTF-8?q?ocess=E6=A8=A1=E5=9D=97=E6=97=B6=EF=BC=8C=E4=B8=8D=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E4=B8=8Eprocess=E6=A8=A1=E5=9D=97=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84Bean?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1053044454686720]没有process模块时,不加载与process模块相关的Bean http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1053044454686720 --- .../configuration/ItsmBaseConfiguration.java | 48 +++++++++++++++++++ .../core/ProcessStepHandlerBase.java | 4 +- .../core/ProcessStepHandlerFactory.java | 3 -- 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 src/main/java/neatlogic/framework/process/spring/configuration/ItsmBaseConfiguration.java 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 00000000..5cea68d5 --- /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 1d57e31c..f2facee8 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; } diff --git a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerFactory.java b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerFactory.java index 0188f4a6..89c3e4f6 100644 --- a/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerFactory.java +++ b/src/main/java/neatlogic/framework/process/stephandler/core/ProcessStepHandlerFactory.java @@ -74,12 +74,9 @@ public class ProcessStepHandlerFactory extends ModuleInitializedListenerBase { @Override public void onInitialized(NeatLogicWebApplicationContext context) { -// ItsmInstantiationAwareBeanPostProcessor bean = context.getBean(ItsmInstantiationAwareBeanPostProcessor.class); -// System.out.println("bean = " + bean); Map myMap = context.getBeansOfType(IProcessStepHandler.class); for (Map.Entry entry : myMap.entrySet()) { IProcessStepHandler component = entry.getValue(); - System.out.println("component = " + component); if (component.getHandler() != null) { componentMap.put(component.getHandler(), component); ProcessStepHandlerVo processStepHandlerVo = new ProcessStepHandlerVo(); -- Gitee