diff --git a/designer-realize/src/main/java/com/fanruan/boot/ConfigHelper.java b/designer-base/src/main/java/com/fr/design/ConfigHelper.java
similarity index 51%
rename from designer-realize/src/main/java/com/fanruan/boot/ConfigHelper.java
rename to designer-base/src/main/java/com/fr/design/ConfigHelper.java
index a354a2f6b8..c3f22a8718 100644
--- a/designer-realize/src/main/java/com/fanruan/boot/ConfigHelper.java
+++ b/designer-base/src/main/java/com/fr/design/ConfigHelper.java
@@ -1,15 +1,21 @@
-package com.fanruan.boot;
+package com.fr.design;
import com.fanruan.carina.Carina;
import com.fanruan.product.ProductConstants;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory;
+import com.fr.stable.CommonUtils;
import com.fr.stable.StringUtils;
+import com.fr.stable.project.ProjectConstants;
+import com.fr.workspace.WorkContext;
+import com.fr.workspace.Workspace;
+import com.fr.workspace.resource.ResourceIOException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
+import java.io.IOException;
import java.util.Properties;
/**
@@ -27,9 +33,9 @@ import java.util.Properties;
public class ConfigHelper {
public static final String TAIL = ".properties";
public static final String CONFIG = "confighelper";
+ public static final String ENV = "envconfig";
public static final String BASE = ProductConstants.getEnvHome() + File.separator + CONFIG + File.separator;
public static final String BASE_PATH = BASE + "BaseProperties" + TAIL;
- private static String path = StringUtils.EMPTY;
@@ -42,46 +48,31 @@ public class ConfigHelper {
/**
- * 获取当前环境配置
+ * 获取对应环境配置
*/
- public static Properties getEnvProperties() {
- return getProperties(getEnvPropertiesPath(), getBaseProperties());
+ public static Properties getEnvProperties(Workspace workspace) {
+ return getProperties(getEnvPropertiesPath(workspace), getBaseProperties());
}
/**
- * 获取当前环境配置的路径
- */
- public static String getEnvPropertiesPath() {
- return path + TAIL;
- }
-
- /**
- * 规范化配置文件的路径,保证配置文件落在缓存文件夹(110)中
+ * 获取当前环境配置
*/
- public static String normalise(String path) {
- if (!path.startsWith(BASE)) {
- path = BASE + path.replace("\\", "_").replace("/", "_").replace(":", "_");
- }
- return path;
+ public static Properties getEnvProperties() {
+ return getProperties(getEnvPropertiesPath(null), getBaseProperties());
}
-
/**
- * 设置config路径
+ * 获取对应环境配置的路径
*/
- public static void setPath(String path) {
- ConfigHelper.path = normalise(path);
+ public static String getEnvPropertiesPath(Workspace workspace) {
+ return CommonUtils.pathJoin(workspace == null ? WorkContext.getCurrent().getPath() : workspace.getPath(), ProjectConstants.ASSETS_NAME, CONFIG, ENV) + TAIL;
}
-
/**
- * 获取路径
+ * 获取当前环境配置的路径
*/
- public static String getPath() {
- if (StringUtils.isEmpty(path)) {
- path = Carina.getApplicationContext().getWebInfPath();
- }
- return path;
+ public static String getEnvPropertiesPath() {
+ return getEnvPropertiesPath(null);
}
private static Properties getProperties(String path, Properties defaultValue){
@@ -90,8 +81,9 @@ public class ConfigHelper {
properties.putAll(defaultValue);
}
try {
- if (!ResourceIOUtils.exist(path)) {
- ResourceIOUtils.createFile(path);
+ File file = new File(path);
+ if (!file.exists()) {
+ createFile(file);
}
properties.load(new BufferedReader(new FileReader(path)));
} catch (Exception e) {
@@ -100,4 +92,28 @@ public class ConfigHelper {
return properties;
}
+
+ private static boolean createFile(File file) throws ResourceIOException {
+ String parent = file.getParent();
+ if (StringUtils.isNotEmpty(parent)) {
+ createDirectory(parent);
+ }
+ try {
+ return file.createNewFile();
+ } catch (IOException e) {
+ throw new ResourceIOException("[Resource] Failed to create '" + file.getPath() + "'", e);
+ }
+ }
+
+ private static boolean createDirectory(String dir) {
+ File root = new File(dir);
+ if (root.exists()) {
+ return false;
+ }
+ if (!dir.endsWith(File.separator)) {
+ dir = dir.concat(File.separator);
+ }
+ // 创建目录
+ return root.mkdirs() || new File(dir).mkdirs();
+ }
}
diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
index d38def2836..bb55c90205 100644
--- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
+++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
@@ -1,6 +1,7 @@
package com.fr.design;
import com.fr.common.report.ReportState;
+import com.fr.design.backup.EnvBackupHelper;
import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard;
import com.fr.design.plugin.remind.PluginErrorDesignReminder;
import com.fr.design.data.DesignTableDataManager;
@@ -59,6 +60,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
import java.util.Set;
import java.util.HashSet;
@@ -109,14 +111,15 @@ public class EnvChangeEntrance {
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv);
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
-
+ EnvBackupHelper.getInstance().backup();
try {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace != null && selectedEnv.checkValid();
if (!checkValid) {
return false;
}
-
+ // 更新目标环境
+ EnvBackupHelper.getInstance().prepare4switch(workspace);
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void done() {
@@ -127,6 +130,7 @@ public class EnvChangeEntrance {
//初始化一下serverTray
ServerTray.init();
}
+ EnvBackupHelper.getInstance().success();
}
});
// REPORT-25688如果是war包部署的服务器,给与提示
@@ -142,6 +146,7 @@ public class EnvChangeEntrance {
PluginErrorDesignReminder.getInstance().remindStartFailedPlugins();
} catch (Exception exception) {
// 失败的处理
+ EnvBackupHelper.getInstance().failed();
WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv);
return false;
}
diff --git a/designer-realize/src/main/java/com/fr/start/DesignContext.java b/designer-base/src/main/java/com/fr/design/backup/DesignContext.java
similarity index 97%
rename from designer-realize/src/main/java/com/fr/start/DesignContext.java
rename to designer-base/src/main/java/com/fr/design/backup/DesignContext.java
index b4bb41ff58..bdb739b339 100644
--- a/designer-realize/src/main/java/com/fr/start/DesignContext.java
+++ b/designer-base/src/main/java/com/fr/design/backup/DesignContext.java
@@ -1,4 +1,4 @@
-package com.fr.start;
+package com.fr.design.backup;
import com.fanruan.carina.context.CarinaApplicationContext;
import com.fanruan.carina.standard.PartitionManager;
diff --git a/designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java b/designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java
new file mode 100644
index 0000000000..6ea52fd764
--- /dev/null
+++ b/designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java
@@ -0,0 +1,117 @@
+package com.fr.design.backup;
+
+import com.fanruan.carina.Carina;
+import com.fanruan.config.realm.ConfigRepositoryFactory;
+import com.fanruan.config.realm.local.LocalConfigRepositoryBuilder;
+import com.fr.design.ConfigHelper;
+import com.fr.design.mem.MemConfigBackupManager;
+import com.fr.log.FineLoggerFactory;
+import com.fr.workspace.WorkContext;
+import com.fr.workspace.Workspace;
+
+import java.util.Properties;
+
+/**
+ * 切换环境对应的帮助类,主要负责环境切换的备份与环境属性的设置
+ *
+ * @author Destiny.Lin
+ * @since 11.0
+ * Created on 2024/7/12
+ */
+public class EnvBackupHelper {
+ private static final EnvBackupHelper INSTANCE = new EnvBackupHelper();
+ private boolean swtiching = false;
+ private boolean local = true;
+ private Properties properties = null;
+ private String path = null;
+ private Workspace target;
+ private Workspace origin;
+ /**
+ * 获取单例
+ */
+ public static EnvBackupHelper getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * 备份
+ *
切换前需要判断,为什么?——当前的配置框架需要在切换前做好备份,防止切换失败,失败的话要切回备份
+ */
+ public void backup() {
+ FineLoggerFactory.getLogger().info("[EnvBackup] 1.back start...");
+ this.swtiching = true;
+ local = WorkContext.getCurrent().isLocal();
+ if (local) {
+ properties = ConfigHelper.getEnvProperties();
+ path = ConfigHelper.getEnvPropertiesPath();
+ }
+ origin = WorkContext.getCurrent();
+ }
+
+ /**
+ * 切换前的准备
+ * 设置目标环境
+ * 设置新的工程路径
+ */
+ public void prepare4switch(Workspace workspace) {
+ this.target = workspace;
+ ((DesignContext) Carina.getApplicationContext()).setDesignWebInfPath(workspace.getPath());
+ }
+
+ /**
+ * 切换
+ */
+ public void do4Switch4Config() {
+ FineLoggerFactory.getLogger().info("[EnvBackup] 2.do config switch");
+ // 切换环境的时候新配置框架启动前要先reset原来的
+ ConfigRepositoryFactory.getInstance().reset();
+ if (target.isLocal()) {
+ //如果目标是本地,就清空然后重新注册新的本地配置
+ ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new LocalConfigRepositoryBuilder(ConfigHelper.getEnvProperties(target), ConfigHelper.getEnvPropertiesPath(target)));
+ } else {
+ // 如果是切到远程,先暂时用备份的内存配置,成功后再转到新配置,失败则切回原内存配置
+ MemConfigBackupManager.getInstance().startSwitch();
+ }
+ }
+
+ /**
+ * 切换成功后的处理
+ */
+ public void success() {
+ FineLoggerFactory.getLogger().info("[EnvBackup] 3.switch all" );
+ //切换成功,如果原来是本地,则清空备份,不需要干别的,此时配置走的就是新环境的本地
+ if (local) {
+ properties = null;
+ path = null;
+ } else {
+ // 如果原来是远程,就把内存的新环境配置替换掉原来旧的,然后新配置清空
+ MemConfigBackupManager.getInstance().success();
+ }
+ }
+
+ /**
+ * 切换失败后的处理
+ */
+ public void failed() {
+ FineLoggerFactory.getLogger().info("[EnvBackup] 3.handle failed" );
+ ((DesignContext) Carina.getApplicationContext()).setDesignWebInfPath(origin.getPath());
+ // 切换失败,如果原来是本地,则切回去
+ ConfigRepositoryFactory.getInstance().reset();
+ if (local) {
+ ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new LocalConfigRepositoryBuilder(properties, path));
+ } else {
+ // 如果是远程,则新环境的配置全部弃用,直接走老的
+ MemConfigBackupManager.getInstance().failed();
+ }
+
+ }
+
+ public boolean isSwtiching() {
+ return swtiching;
+ }
+
+ public EnvBackupHelper setSwtiching(boolean swtiching) {
+ this.swtiching = swtiching;
+ return this;
+ }
+}
diff --git a/designer-base/src/main/java/com/fr/design/mem/MemConfigBackupManager.java b/designer-base/src/main/java/com/fr/design/mem/MemConfigBackupManager.java
new file mode 100644
index 0000000000..352e468343
--- /dev/null
+++ b/designer-base/src/main/java/com/fr/design/mem/MemConfigBackupManager.java
@@ -0,0 +1,88 @@
+package com.fr.design.mem;
+
+import com.fanruan.config.realm.ConfigRepositoryProvider;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * 内存配置框架备份管理
+ *
+ * @author Destiny.Lin
+ * @since 11.0
+ * Created on 2024/7/11
+ */
+public class MemConfigBackupManager {
+
+ private static final MemConfigBackupManager INSTANCE = new MemConfigBackupManager();
+
+ private Map oldEnvConfig = new ConcurrentHashMap<>();
+
+ private Map newEnvConfig = new ConcurrentHashMap<>();
+
+ private boolean switching = false;
+
+ /**
+ * 获取备份
+ */
+ public static MemConfigBackupManager getInstance() {
+ return INSTANCE;
+ }
+
+ /**
+ * 获取配置
+ */
+ public ConfigRepositoryProvider get(String namespace) {
+ if (switching) {
+ return newEnvConfig.getOrDefault(namespace, null);
+ }
+ return oldEnvConfig.getOrDefault(namespace, null);
+ }
+
+ /**
+ * 放入配置
+ */
+ public void put(String namespace, ConfigRepositoryProvider provider) {
+ if (switching) {
+ newEnvConfig.put(namespace, provider);
+ } else {
+ oldEnvConfig.put(namespace, provider);
+ }
+ }
+
+
+ /**
+ * 清理
+ */
+ public void clear() {
+ oldEnvConfig.clear();
+ newEnvConfig.clear();
+ switching = false;
+ }
+
+ /**
+ * 切换成功则将切换过程中的配置移动到旧配置,新的切换过程中的配置置空
+ */
+ public void success() {
+ oldEnvConfig = new HashMap<>(newEnvConfig);
+ newEnvConfig.clear();
+ switching = false;
+ }
+
+ public void failed() {
+ newEnvConfig.clear();
+ switching = false;
+ }
+
+ public boolean isSwitching() {
+ return switching;
+ }
+
+ /**
+ * 开始切换
+ */
+ public void startSwitch() {
+ switching = true;
+ }
+}
diff --git a/designer-realize/src/main/java/com/fanruan/boot/mem/MemConfigRepository.java b/designer-base/src/main/java/com/fr/design/mem/MemConfigRepository.java
similarity index 99%
rename from designer-realize/src/main/java/com/fanruan/boot/mem/MemConfigRepository.java
rename to designer-base/src/main/java/com/fr/design/mem/MemConfigRepository.java
index c88241794d..4528026741 100644
--- a/designer-realize/src/main/java/com/fanruan/boot/mem/MemConfigRepository.java
+++ b/designer-base/src/main/java/com/fr/design/mem/MemConfigRepository.java
@@ -1,4 +1,4 @@
-package com.fanruan.boot.mem;
+package com.fr.design.mem;
import com.fanruan.config.event.ConfigListener;
import com.fanruan.config.realm.ConfigRepositoryProvider;
diff --git a/designer-base/src/main/java/com/fr/design/mem/MemConfigRepositoryBuilder.java b/designer-base/src/main/java/com/fr/design/mem/MemConfigRepositoryBuilder.java
new file mode 100644
index 0000000000..63d6ff6814
--- /dev/null
+++ b/designer-base/src/main/java/com/fr/design/mem/MemConfigRepositoryBuilder.java
@@ -0,0 +1,30 @@
+package com.fr.design.mem;
+
+import com.fanruan.config.realm.ConfigRepositoryBuilder;
+import com.fanruan.config.realm.ConfigRepositoryProvider;
+
+
+
+/**
+ * 设计器MemConfigRepositoryBuilder
+ *
+ * @author Destiny.Lin
+ * @since 11.0
+ * Created on 2024/5/29
+ */
+public class MemConfigRepositoryBuilder implements ConfigRepositoryBuilder {
+ @Override
+ public ConfigRepositoryProvider build(String namespace) throws Exception {
+ ConfigRepositoryProvider provider = MemConfigBackupManager.getInstance().get(namespace);
+ if (provider != null) {
+ // 如果备份中有说明就是当前要的配置
+ return provider;
+ } else {
+ // 如果没有,说明是全新的远程环境,新建一个
+ provider = new MemConfigRepository(namespace);
+ // 备份也得放一个
+ MemConfigBackupManager.getInstance().put(namespace, provider);
+ }
+ return provider;
+ }
+}
diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java
index 49c3566b70..3a0b195b03 100644
--- a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java
+++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java
@@ -1,7 +1,8 @@
package com.fanruan.boot.env;
-import com.fanruan.boot.ConfigHelper;
+import com.fr.design.ConfigHelper;
import com.fanruan.boot.key.StartupArgsShell;
+import com.fr.design.mem.MemConfigRepositoryBuilder;
import com.fanruan.carina.Carina;
import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start;
@@ -26,7 +27,6 @@ import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.plugin.remind.PluginErrorDesignReminder;
import com.fr.env.utils.WorkspaceUtils;
import com.fr.event.Event;
-import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.file.filetree.FileNodes;
@@ -36,8 +36,7 @@ import com.fr.report.lock.DefaultLockInfoOperator;
import com.fr.report.lock.LocalLockInfoOperator;
import com.fr.report.lock.LockInfoOperator;
import com.fr.report.lock.ServerLockInfoOperator;
-import com.fr.stable.StringUtils;
-import com.fr.start.DesignContext;
+import com.fr.design.backup.DesignContext;
import com.fr.start.module.StartupArgs;
import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext;
@@ -186,7 +185,6 @@ public class DesignEnvChooseComponent extends ResourceAffiliate {
String current = DesignerEnvManager.getEnvManager().getCurEnvName();
workspaceInfo = WorkspaceUtils.getWorkspaceInfo();
((DesignContext)Carina.getApplicationContext()).setDesignWebInfPath(workspaceInfo.getPath());
- updateConfigPath(workspaceInfo);
Workspace workspace = DesignerWorkspaceGenerator.generate(workspaceInfo);
boolean checkValid = workspace != null && workspaceInfo.checkValid();
if (!checkValid) {
@@ -205,17 +203,14 @@ public class DesignEnvChooseComponent extends ResourceAffiliate {
private void updateConfigBuilder() {
ConfigRepositoryFactory.getInstance().reset();
- ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new LocalConfigRepositoryBuilder(ConfigHelper.getEnvProperties(), ConfigHelper.getEnvPropertiesPath()));
- }
-
- private void updateConfigPath(DesignerWorkspaceInfo workspaceInfo) {
- if (StringUtils.isEmpty(workspaceInfo.getPath())) {
- ConfigHelper.setPath(workspaceInfo.getConnection().getUrl());
+ if (WorkContext.getCurrent().isLocal()) {
+ ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new LocalConfigRepositoryBuilder(ConfigHelper.getEnvProperties(), ConfigHelper.getEnvPropertiesPath()));
} else {
- ConfigHelper.setPath(workspaceInfo.getPath());
+ ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new MemConfigRepositoryBuilder());
}
}
+
/**
* 注册切换环境前后事件监听
*/
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 dda5c6b80f..7eac572bb0 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
@@ -30,7 +30,6 @@ import com.fr.cbb.dialect.security.InsecurityElementFactory;
import com.fr.cluster.ClusterBridge;
import com.fr.cluster.lock.ClusterLock;
import com.fr.config.BaseDBEnv;
-import com.fr.config.ConfigContext;
import com.fr.config.ConfigEvent;
import com.fr.config.FinalPreferenceConfig;
import com.fr.config.dao.DaoContext;
@@ -46,6 +45,7 @@ import com.fr.config.dao.impl.remote.RemoteXmlEntityDao;
import com.fr.config.impl.ConfConfigProviderImpl;
import com.fr.config.impl.ConfigInsecurityElementProviderImpl;
import com.fr.decision.service.context.ServiceContext;
+import com.fr.design.backup.EnvBackupHelper;
import com.fr.env.detect.EnvDetectorCenter;
import com.fr.event.EventDispatcher;
import com.fr.general.FRLogger;
@@ -64,9 +64,7 @@ import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.record.analyzer.AnalyzerConfiguration;
-import com.fr.record.analyzer.AnalyzerKey;
import com.fr.record.analyzer.AnalyzerMutableGroup;
-import com.fr.record.analyzer.Assistant;
import com.fr.record.analyzer.DBMetrics;
import com.fr.scheduler.QuartzContext;
import com.fr.scheduler.SchedulerEvent;
@@ -76,7 +74,6 @@ import com.fr.security.encryption.core.EncryptionScaffold;
import com.fr.security.encryption.provider.SecuritySeedProvider;
import com.fr.security.encryption.storage.keys.LoadSeedSecurityKey;
-import com.fr.stable.GraphDrawHelper;
import com.fr.stable.StringUtils;
import com.fr.stable.db.DBContext;
import com.fr.stable.db.properties.FineMicroServicesDBProperties;
@@ -84,11 +81,8 @@ import com.fr.stable.db.session.DBSession;
import com.fr.stable.project.ProjectConstants;
import com.fr.tenant.context.TenantContext;
import com.fr.tenant.context.provider.CurrentTenantKey;
-import com.fr.third.net.bytebuddy.description.type.TypeDescription;
-import com.fr.third.net.bytebuddy.dynamic.DynamicType;
import com.fr.third.net.bytebuddy.implementation.MethodDelegation;
import com.fr.third.net.bytebuddy.matcher.ElementMatchers;
-import com.fr.third.net.bytebuddy.utility.JavaModule;
import com.fr.third.org.hibernate.jdbc.AbstractWork;
import com.fr.tolerance.FaultTolerance;
import com.fr.tolerance.FaultToleranceInterceptor;
@@ -102,7 +96,6 @@ import com.fr.workspace.WorkContext;
import java.net.URI;
import java.sql.Connection;
import java.sql.SQLException;
-import java.util.Objects;
import java.util.Properties;
/**
@@ -249,7 +242,7 @@ public class DesignEnvComponent {
private void startFileServer() throws Exception {
if (WorkContext.getCurrent().isLocal()) {
// 设计器远程下不需要文件系统,走PublicRepo的接口,本地下走基础的磁盘读写
- LocalFileRepository localFileRepository = LocalFileRepository.getSingleton();
+ LocalFileRepository localFileRepository = new LocalFileRepository(ProjectConstants.LOCAL_ENV, ServiceContext.getWebInfPath());
ResourceRepository realRepo = RepositoryFactory.getRepo();
FSProperties fsProperties = Carina.properties(FSProperties.class);
FileServer.init(
@@ -304,6 +297,10 @@ public class DesignEnvComponent {
*/
private void startConfConfig() {
+ if (EnvBackupHelper.getInstance().isSwtiching()) {
+ // 如果是切换环境触发的start,说明此时读的是新环境的配置
+ EnvBackupHelper.getInstance().do4Switch4Config();
+ }
BaseDBEnv.setDBContext((DBContext) Carina.getApplicationContext().singleton(DBContextShell.class).get());
if (!WorkContext.getCurrent().isLocal()) {
TransactorFactory.setTransactor(new RemoteTransactor());
diff --git a/designer-realize/src/main/java/com/fanruan/boot/mem/MemConfigRepositoryBuilder.java b/designer-realize/src/main/java/com/fanruan/boot/mem/MemConfigRepositoryBuilder.java
deleted file mode 100644
index 83fc978d01..0000000000
--- a/designer-realize/src/main/java/com/fanruan/boot/mem/MemConfigRepositoryBuilder.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.fanruan.boot.mem;
-
-import com.fanruan.config.realm.ConfigRepositoryBuilder;
-import com.fanruan.config.realm.ConfigRepositoryProvider;
-
-
-
-/**
- * 设计器MemConfigRepositoryBuilder
- *
- * @author Destiny.Lin
- * @since 11.0
- * Created on 2024/5/29
- */
-public class MemConfigRepositoryBuilder implements ConfigRepositoryBuilder {
- @Override
- public ConfigRepositoryProvider build(String namespace) throws Exception {
- return new MemConfigRepository(namespace);
- }
-}
diff --git a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java
index 8f3cdfa09b..21bca14bd0 100644
--- a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java
+++ b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java
@@ -1,8 +1,7 @@
package com.fanruan.boot.pre;
-import com.fanruan.boot.ConfigHelper;
+import com.fr.design.ConfigHelper;
import com.fanruan.boot.key.StartupArgsShell;
-import com.fanruan.boot.mem.MemConfigRepositoryBuilder;
import com.fanruan.carina.Carina;
import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start;
@@ -15,9 +14,7 @@ import com.fanruan.config.realm.ConfigRepositoryFactory;
import com.fanruan.config.realm.local.LocalConfigRepositoryBuilder;
import com.fanruan.mq.CarinaMQ;
import com.fanruan.mq.InternalMQProvider;
-import com.fanruan.product.ProductConstants;
import com.fr.base.function.UITerminator;
-import com.fr.carina.revert.provider.CarinaPluginProvider;
import com.fr.carina.util.CarinaResourceUtils;
import com.fr.carina.util.provider.CarinaResourceProvider;
import com.fr.design.DesignerEnvManager;
@@ -36,13 +33,10 @@ import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.module.engine.event.LifecycleErrorEvent;
-import com.fr.plugin.ExtraClassManager;
import com.fr.runtime.FineRuntime;
import com.fr.stable.CommonCodeUtils;
import com.fr.stable.CommonUtils;
-import com.fr.stable.fun.ResourcePathTransformer;
import com.fr.stable.lifecycle.FineLifecycleFatalError;
-import com.fr.stable.plugin.ExtraClassManagerProvider;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.resource.ResourceLoader;
import com.fr.start.DesignerSubListener;
@@ -57,22 +51,13 @@ import com.fr.tenant.context.PlatformScaffoldTenantStarter;
import com.fr.tenant.context.TenantContext;
import com.fr.tenant.context.provider.CurrentTenantKey;
import com.fr.tenant.store.impl.DefaultTenantStorage;
-import com.fr.web.controller.common.FileContentModificator;
-import com.fr.web.controller.plugin.PluginFileContentModificator;
-import com.fr.web.file.FileContentProcessorFactory;
import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.InputStream;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
import java.util.concurrent.CompletableFuture;
/**
diff --git a/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java b/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java
index ca5f2fc431..3e3f083b69 100644
--- a/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java
+++ b/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java
@@ -7,6 +7,7 @@ import com.fanruan.carina.context.CarinaApplicationContext;
import com.fanruan.carina.standard.PartitionManager;
import com.fanruan.carina.standard.PartitionManagerImpl;
import com.fr.base.StateHubContext;
+import com.fr.design.backup.DesignContext;
import com.fr.design.carton.SwitchForSwingChecker;
import com.fr.log.FineLoggerFactory;
diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java
index d4bb496d33..7dd13d1d7d 100644
--- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java
+++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java
@@ -16,7 +16,7 @@ import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.module.Activator;
-import com.fr.start.DesignContext;
+import com.fr.design.backup.DesignContext;
import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;