From df884edc76050b1d01181a4988046918dba997d8 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 23 Oct 2024 11:24:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=B7=A5=E5=8E=82?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=AD=E9=80=9A=E8=BF=87=E5=85=A8=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E8=8E=B7=E5=8F=96=E7=BB=84=E4=BB=B6=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E8=8E=B7=E5=8F=96=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1273774249312256]工厂模式中通过全类名获取组件时,扩展支持通过类名获取组件 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1273774249312256 --- ...rocessTaskSerialNumberPolicyHandlerFactory.java | 14 +++++++++++--- .../core/WorkerDispatcherFactory.java | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/neatlogic/framework/process/processtaskserialnumberpolicy/core/ProcessTaskSerialNumberPolicyHandlerFactory.java b/src/main/java/neatlogic/framework/process/processtaskserialnumberpolicy/core/ProcessTaskSerialNumberPolicyHandlerFactory.java index 08d4d497..2155627c 100644 --- a/src/main/java/neatlogic/framework/process/processtaskserialnumberpolicy/core/ProcessTaskSerialNumberPolicyHandlerFactory.java +++ b/src/main/java/neatlogic/framework/process/processtaskserialnumberpolicy/core/ProcessTaskSerialNumberPolicyHandlerFactory.java @@ -32,7 +32,12 @@ public class ProcessTaskSerialNumberPolicyHandlerFactory extends ModuleInitializ private static final List policyList = new ArrayList<>(); public static IProcessTaskSerialNumberPolicyHandler getHandler(String handler) { - return policyMap.get(handler); + IProcessTaskSerialNumberPolicyHandler processTaskSerialNumberPolicyHandler = policyMap.get(handler); + if (processTaskSerialNumberPolicyHandler == null) { + int index = handler.lastIndexOf("."); + processTaskSerialNumberPolicyHandler = policyMap.get(handler.substring(index + 1)); + } + return processTaskSerialNumberPolicyHandler; } public static List getPolicyHandlerList() { @@ -45,9 +50,12 @@ public class ProcessTaskSerialNumberPolicyHandlerFactory extends ModuleInitializ context.getBeansOfType(IProcessTaskSerialNumberPolicyHandler.class); for (Map.Entry entry : map.entrySet()) { IProcessTaskSerialNumberPolicyHandler numberPolicy = entry.getValue(); - policyMap.put(numberPolicy.getHandler(), numberPolicy); + String handler = numberPolicy.getHandler(); + int index = handler.lastIndexOf("."); + policyMap.put(handler, numberPolicy); + policyMap.put(handler.substring(index + 1), numberPolicy); ProcessTaskSerialNumberPolicyVo policy = new ProcessTaskSerialNumberPolicyVo(); - policy.setHandler(numberPolicy.getHandler()); + policy.setHandler(handler); policy.setName(numberPolicy.getName()); policy.setFormAttributeList(numberPolicy.makeupFormAttributeList()); policyList.add(policy); diff --git a/src/main/java/neatlogic/framework/process/workerdispatcher/core/WorkerDispatcherFactory.java b/src/main/java/neatlogic/framework/process/workerdispatcher/core/WorkerDispatcherFactory.java index f8a1a7d1..5ea98318 100644 --- a/src/main/java/neatlogic/framework/process/workerdispatcher/core/WorkerDispatcherFactory.java +++ b/src/main/java/neatlogic/framework/process/workerdispatcher/core/WorkerDispatcherFactory.java @@ -36,10 +36,15 @@ public class WorkerDispatcherFactory extends ModuleInitializedListenerBase { private static final Map className2ModuleIdMap = new HashMap<>(); public static IWorkerDispatcher getDispatcher(String name) { - if (!componentMap.containsKey(name) || componentMap.get(name) == null) { + IWorkerDispatcher workerDispatcher = componentMap.get(name); + if (workerDispatcher == null) { + int index = name.lastIndexOf("."); + workerDispatcher = componentMap.get(name.substring(index + 1)); + } + if (workerDispatcher == null) { throw new HandlerDispatchComponentTypeNotFoundException(name); } - return componentMap.get(name); + return workerDispatcher; } public static List getAllActiveWorkerDispatcher() { @@ -80,7 +85,10 @@ public class WorkerDispatcherFactory extends ModuleInitializedListenerBase { for (Map.Entry entry : myMap.entrySet()) { IWorkerDispatcher component = entry.getValue(); if (StringUtils.isNotBlank(component.getClassName())) { - componentMap.put(component.getClassName(), component); + String className = component.getClassName(); + componentMap.put(className, component); + int index = className.lastIndexOf("."); + componentMap.put(className.substring(index + 1), component); className2ModuleIdMap.put(component.getClassName(), context.getId()); } } -- Gitee From 1df6b336b1aee86f63c6bf73ed7c8ee893799c80 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 23 Oct 2024 11:27:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E5=B7=A5=E5=8E=82?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E4=B8=AD=E9=80=9A=E8=BF=87=E5=85=A8=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E8=8E=B7=E5=8F=96=E7=BB=84=E4=BB=B6=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E8=8E=B7=E5=8F=96=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1273774249312256]工厂模式中通过全类名获取组件时,扩展支持通过类名获取组件 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1273774249312256 --- .../workerdispatcher/core/WorkerDispatcherFactory.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/neatlogic/framework/process/workerdispatcher/core/WorkerDispatcherFactory.java b/src/main/java/neatlogic/framework/process/workerdispatcher/core/WorkerDispatcherFactory.java index 5ea98318..3d38af68 100644 --- a/src/main/java/neatlogic/framework/process/workerdispatcher/core/WorkerDispatcherFactory.java +++ b/src/main/java/neatlogic/framework/process/workerdispatcher/core/WorkerDispatcherFactory.java @@ -84,12 +84,12 @@ public class WorkerDispatcherFactory extends ModuleInitializedListenerBase { Map myMap = context.getBeansOfType(IWorkerDispatcher.class); for (Map.Entry entry : myMap.entrySet()) { IWorkerDispatcher component = entry.getValue(); - if (StringUtils.isNotBlank(component.getClassName())) { - String className = component.getClassName(); + String className = component.getClassName(); + if (StringUtils.isNotBlank(className)) { componentMap.put(className, component); int index = className.lastIndexOf("."); componentMap.put(className.substring(index + 1), component); - className2ModuleIdMap.put(component.getClassName(), context.getId()); + className2ModuleIdMap.put(className, context.getId()); } } } -- Gitee