From f15df7d003056c36f72057ecb1d1cd7b7c7817a8 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 14 Oct 2024 19:16:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-137327=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E4=B8=8B=E5=88=87=E6=8D=A2=E7=9B=AE=E5=BD=95=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF=E4=BC=98=E5=8C=96=20=E9=85=8D=E7=BD=AE=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/boot/env/DesignEnvComponent.java | 4 ++ .../config/UpDataDesignerRemoteOperator.java | 51 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 designer-realize/src/main/java/com/fanruan/config/UpDataDesignerRemoteOperator.java diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java index 3605694488..a63f0486e8 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java @@ -12,6 +12,7 @@ import com.fanruan.carina.annotions.Stop; import com.fanruan.carina.annotions.Supplemental; import com.fanruan.config.ConfigProviderFactory; import com.fanruan.config.LocalConfigSource; +import com.fanruan.config.UpDataDesignerRemoteOperator; import com.fanruan.config.realm.ConfigRealm; import com.fanruan.dao.context.DBContextProvider; import com.fanruan.dao.context.DBContextStarter; @@ -51,6 +52,7 @@ import com.fr.config.holder.ConfigChangeListener; import com.fr.config.holder.ValidateConfigManger; import com.fr.config.impl.ConfConfigProviderImpl; import com.fr.config.impl.ConfigInsecurityElementProviderImpl; +import com.fr.config.utils.UpDataHelper; import com.fr.decision.service.context.ServiceContext; import com.fr.design.backup.EnvBackupHelper; import com.fr.env.detect.EnvDetectorCenter; @@ -351,6 +353,7 @@ public class DesignEnvComponent { DaoContext.setXmlEntityDao(new RemoteXmlEntityDao()); DaoContext.setClassHelperDao(new RemoteClassHelperDao()); DaoContext.setEntityDao(new RemoteEntityDao()); + UpDataHelper.getInstance().registerOperator(UpDataDesignerRemoteOperator.getInstance()); } else { //本地 TransactorFactory.setTransactor(new HibernateTransactor()); @@ -369,6 +372,7 @@ public class DesignEnvComponent { private void stopConfConfig() { + UpDataHelper.getInstance().resetOperator(); DaoContext.setClassHelperDao(null); DaoContext.setEntityDao(null); DaoContext.setXmlEntityDao(null); diff --git a/designer-realize/src/main/java/com/fanruan/config/UpDataDesignerRemoteOperator.java b/designer-realize/src/main/java/com/fanruan/config/UpDataDesignerRemoteOperator.java new file mode 100644 index 0000000000..533e28f9d4 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/config/UpDataDesignerRemoteOperator.java @@ -0,0 +1,51 @@ +package com.fanruan.config; + +import com.fanruan.repository.ConfigRepository; +import com.fr.config.utils.ConfData; +import com.fr.config.utils.ConfigReadUtils; +import com.fr.config.utils.PrefixHandler; +import com.fr.config.utils.UpDataOperator; +import com.fr.stable.StringUtils; + +/** + * 设计器远程下获取Updata的操作类 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/10/14 + */ +public class UpDataDesignerRemoteOperator implements UpDataOperator { + + private static final UpDataDesignerRemoteOperator INSTANCE = new UpDataDesignerRemoteOperator(); + + /** + * 单例 + */ + public static UpDataDesignerRemoteOperator getInstance() { + return INSTANCE; + } + + @Override + public ConfData getUpData(String prefix, String tenantId) { + return ConfigRepository.getInstance().getConfigByConfigsCache(getConfigNameSpace(prefix), () -> { + ConfData data = new ConfData(); + data.setDataMap(ConfigReadUtils.getData(prefix, tenantId)); + data.setMap(ConfigReadUtils.getClassInfo(prefix, tenantId)); + return data; + }); + } + + private String getConfigNameSpace(String id) { + + if (StringUtils.isEmpty(id)) { + throw new IllegalArgumentException("id cannot be null"); + } + int length = id.length(); + for (int i = 0; i < length; i++) { + if (PrefixHandler.SEPERATOR == id.charAt(i)) { + return id.substring(0, i); + } + } + throw new IllegalArgumentException("cannot resolve namespace of " + id); + } +} From c1e283382b254f2c82084803515324eed0d21d0c Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 15 Oct 2024 09:45:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-137327=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E4=B8=8B=E5=88=87=E6=8D=A2=E7=9B=AE=E5=BD=95=E5=8D=A1?= =?UTF-8?q?=E9=A1=BF=E4=BC=98=E5=8C=96=20=E4=BC=98=E5=8C=96=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/boot/env/DesignEnvComponent.java | 8 ++++---- ...rator.java => SetupDataDesignerRemoteOperator.java} | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) rename designer-realize/src/main/java/com/fanruan/config/{UpDataDesignerRemoteOperator.java => SetupDataDesignerRemoteOperator.java} (77%) diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java index a63f0486e8..c9c0b627d2 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java @@ -12,7 +12,7 @@ import com.fanruan.carina.annotions.Stop; import com.fanruan.carina.annotions.Supplemental; import com.fanruan.config.ConfigProviderFactory; import com.fanruan.config.LocalConfigSource; -import com.fanruan.config.UpDataDesignerRemoteOperator; +import com.fanruan.config.SetupDataDesignerRemoteOperator; import com.fanruan.config.realm.ConfigRealm; import com.fanruan.dao.context.DBContextProvider; import com.fanruan.dao.context.DBContextStarter; @@ -52,7 +52,7 @@ import com.fr.config.holder.ConfigChangeListener; import com.fr.config.holder.ValidateConfigManger; import com.fr.config.impl.ConfConfigProviderImpl; import com.fr.config.impl.ConfigInsecurityElementProviderImpl; -import com.fr.config.utils.UpDataHelper; +import com.fr.config.utils.SetupDataHelper; import com.fr.decision.service.context.ServiceContext; import com.fr.design.backup.EnvBackupHelper; import com.fr.env.detect.EnvDetectorCenter; @@ -353,7 +353,7 @@ public class DesignEnvComponent { DaoContext.setXmlEntityDao(new RemoteXmlEntityDao()); DaoContext.setClassHelperDao(new RemoteClassHelperDao()); DaoContext.setEntityDao(new RemoteEntityDao()); - UpDataHelper.getInstance().registerOperator(UpDataDesignerRemoteOperator.getInstance()); + SetupDataHelper.getInstance().registerOperator(SetupDataDesignerRemoteOperator.getInstance()); } else { //本地 TransactorFactory.setTransactor(new HibernateTransactor()); @@ -372,7 +372,7 @@ public class DesignEnvComponent { private void stopConfConfig() { - UpDataHelper.getInstance().resetOperator(); + SetupDataHelper.getInstance().resetOperator(); DaoContext.setClassHelperDao(null); DaoContext.setEntityDao(null); DaoContext.setXmlEntityDao(null); diff --git a/designer-realize/src/main/java/com/fanruan/config/UpDataDesignerRemoteOperator.java b/designer-realize/src/main/java/com/fanruan/config/SetupDataDesignerRemoteOperator.java similarity index 77% rename from designer-realize/src/main/java/com/fanruan/config/UpDataDesignerRemoteOperator.java rename to designer-realize/src/main/java/com/fanruan/config/SetupDataDesignerRemoteOperator.java index 533e28f9d4..bf5193c2ae 100644 --- a/designer-realize/src/main/java/com/fanruan/config/UpDataDesignerRemoteOperator.java +++ b/designer-realize/src/main/java/com/fanruan/config/SetupDataDesignerRemoteOperator.java @@ -4,7 +4,7 @@ import com.fanruan.repository.ConfigRepository; import com.fr.config.utils.ConfData; import com.fr.config.utils.ConfigReadUtils; import com.fr.config.utils.PrefixHandler; -import com.fr.config.utils.UpDataOperator; +import com.fr.config.utils.SetupDataOperator; import com.fr.stable.StringUtils; /** @@ -14,19 +14,19 @@ import com.fr.stable.StringUtils; * @since 11.0 * Created on 2024/10/14 */ -public class UpDataDesignerRemoteOperator implements UpDataOperator { +public class SetupDataDesignerRemoteOperator implements SetupDataOperator { - private static final UpDataDesignerRemoteOperator INSTANCE = new UpDataDesignerRemoteOperator(); + private static final SetupDataDesignerRemoteOperator INSTANCE = new SetupDataDesignerRemoteOperator(); /** * 单例 */ - public static UpDataDesignerRemoteOperator getInstance() { + public static SetupDataDesignerRemoteOperator getInstance() { return INSTANCE; } @Override - public ConfData getUpData(String prefix, String tenantId) { + public ConfData getData(String prefix, String tenantId) { return ConfigRepository.getInstance().getConfigByConfigsCache(getConfigNameSpace(prefix), () -> { ConfData data = new ConfData(); data.setDataMap(ConfigReadUtils.getData(prefix, tenantId));