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..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,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.SetupDataDesignerRemoteOperator; 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.SetupDataHelper; 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()); + SetupDataHelper.getInstance().registerOperator(SetupDataDesignerRemoteOperator.getInstance()); } else { //本地 TransactorFactory.setTransactor(new HibernateTransactor()); @@ -369,6 +372,7 @@ public class DesignEnvComponent { private void stopConfConfig() { + SetupDataHelper.getInstance().resetOperator(); DaoContext.setClassHelperDao(null); DaoContext.setEntityDao(null); DaoContext.setXmlEntityDao(null); diff --git a/designer-realize/src/main/java/com/fanruan/config/SetupDataDesignerRemoteOperator.java b/designer-realize/src/main/java/com/fanruan/config/SetupDataDesignerRemoteOperator.java new file mode 100644 index 0000000000..bf5193c2ae --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/config/SetupDataDesignerRemoteOperator.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.SetupDataOperator; +import com.fr.stable.StringUtils; + +/** + * 设计器远程下获取Updata的操作类 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/10/14 + */ +public class SetupDataDesignerRemoteOperator implements SetupDataOperator { + + private static final SetupDataDesignerRemoteOperator INSTANCE = new SetupDataDesignerRemoteOperator(); + + /** + * 单例 + */ + public static SetupDataDesignerRemoteOperator getInstance() { + return INSTANCE; + } + + @Override + public ConfData getData(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); + } +}