Browse Source

REPORT-126685 fbp设计器适配——数据连接存储位置研究

mss/2.0
Destiny.Lin 6 months ago
parent
commit
362783181f
  1. 78
      designer-base/src/main/java/com/fr/design/ConfigHelper.java
  2. 9
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  3. 2
      designer-base/src/main/java/com/fr/design/backup/DesignContext.java
  4. 117
      designer-base/src/main/java/com/fr/design/backup/EnvBackupHelper.java
  5. 88
      designer-base/src/main/java/com/fr/design/mem/MemConfigBackupManager.java
  6. 2
      designer-base/src/main/java/com/fr/design/mem/MemConfigRepository.java
  7. 30
      designer-base/src/main/java/com/fr/design/mem/MemConfigRepositoryBuilder.java
  8. 19
      designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java
  9. 15
      designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java
  10. 20
      designer-realize/src/main/java/com/fanruan/boot/mem/MemConfigRepositoryBuilder.java
  11. 17
      designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java
  12. 1
      designer-realize/src/main/java/com/fr/start/CarinaDesigner.java
  13. 2
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

78
designer-realize/src/main/java/com/fanruan/boot/ConfigHelper.java → 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.carina.Carina;
import com.fanruan.product.ProductConstants; import com.fanruan.product.ProductConstants;
import com.fr.io.utils.ResourceIOUtils; import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.stable.StringUtils; 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.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException;
import java.util.Properties; import java.util.Properties;
/** /**
@ -27,9 +33,9 @@ import java.util.Properties;
public class ConfigHelper { public class ConfigHelper {
public static final String TAIL = ".properties"; public static final String TAIL = ".properties";
public static final String CONFIG = "confighelper"; 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 = ProductConstants.getEnvHome() + File.separator + CONFIG + File.separator;
public static final String BASE_PATH = BASE + "BaseProperties" + TAIL; 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() { public static Properties getEnvProperties(Workspace workspace) {
return getProperties(getEnvPropertiesPath(), getBaseProperties()); return getProperties(getEnvPropertiesPath(workspace), getBaseProperties());
} }
/** /**
* 获取当前环境配置的路径 * 获取当前环境配置
*/
public static String getEnvPropertiesPath() {
return path + TAIL;
}
/**
* 规范化配置文件的路径保证配置文件落在缓存文件夹(110)
*/ */
public static String normalise(String path) { public static Properties getEnvProperties() {
if (!path.startsWith(BASE)) { return getProperties(getEnvPropertiesPath(null), getBaseProperties());
path = BASE + path.replace("\\", "_").replace("/", "_").replace(":", "_");
}
return path;
} }
/** /**
* 设置config路径 * 获取对应环境配置的路径
*/ */
public static void setPath(String path) { public static String getEnvPropertiesPath(Workspace workspace) {
ConfigHelper.path = normalise(path); return CommonUtils.pathJoin(workspace == null ? WorkContext.getCurrent().getPath() : workspace.getPath(), ProjectConstants.ASSETS_NAME, CONFIG, ENV) + TAIL;
} }
/** /**
* 获取路径 * 获取当前环境配置的路径
*/ */
public static String getPath() { public static String getEnvPropertiesPath() {
if (StringUtils.isEmpty(path)) { return getEnvPropertiesPath(null);
path = Carina.getApplicationContext().getWebInfPath();
}
return path;
} }
private static Properties getProperties(String path, Properties defaultValue){ private static Properties getProperties(String path, Properties defaultValue){
@ -90,8 +81,9 @@ public class ConfigHelper {
properties.putAll(defaultValue); properties.putAll(defaultValue);
} }
try { try {
if (!ResourceIOUtils.exist(path)) { File file = new File(path);
ResourceIOUtils.createFile(path); if (!file.exists()) {
createFile(file);
} }
properties.load(new BufferedReader(new FileReader(path))); properties.load(new BufferedReader(new FileReader(path)));
} catch (Exception e) { } catch (Exception e) {
@ -100,4 +92,28 @@ public class ConfigHelper {
return properties; 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();
}
} }

9
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -1,6 +1,7 @@
package com.fr.design; package com.fr.design;
import com.fr.common.report.ReportState; import com.fr.common.report.ReportState;
import com.fr.design.backup.EnvBackupHelper;
import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard; import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard;
import com.fr.design.plugin.remind.PluginErrorDesignReminder; import com.fr.design.plugin.remind.PluginErrorDesignReminder;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
@ -59,6 +60,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Properties;
import java.util.Set; import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
@ -109,14 +111,15 @@ public class EnvChangeEntrance {
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv);
WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection();
EnvBackupHelper.getInstance().backup();
try { try {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv); Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace != null && selectedEnv.checkValid(); boolean checkValid = workspace != null && selectedEnv.checkValid();
if (!checkValid) { if (!checkValid) {
return false; return false;
} }
// 更新目标环境
EnvBackupHelper.getInstance().prepare4switch(workspace);
WorkContext.switchTo(workspace, new WorkContextCallback() { WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override @Override
public void done() { public void done() {
@ -127,6 +130,7 @@ public class EnvChangeEntrance {
//初始化一下serverTray //初始化一下serverTray
ServerTray.init(); ServerTray.init();
} }
EnvBackupHelper.getInstance().success();
} }
}); });
// REPORT-25688如果是war包部署的服务器,给与提示 // REPORT-25688如果是war包部署的服务器,给与提示
@ -142,6 +146,7 @@ public class EnvChangeEntrance {
PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); PluginErrorDesignReminder.getInstance().remindStartFailedPlugins();
} catch (Exception exception) { } catch (Exception exception) {
// 失败的处理 // 失败的处理
EnvBackupHelper.getInstance().failed();
WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); WorkspaceExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv);
return false; return false;
} }

2
designer-realize/src/main/java/com/fr/start/DesignContext.java → 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.context.CarinaApplicationContext;
import com.fanruan.carina.standard.PartitionManager; import com.fanruan.carina.standard.PartitionManager;

117
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;
}
/**
* 备份
* <p>切换前需要判断为什么当前的配置框架需要在切换前做好备份防止切换失败失败的话要切回备份</p>
*/
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();
}
/**
* 切换前的准备
* <p>设置目标环境</p>
* <p>设置新的工程路径</p>
*/
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;
}
}

88
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<String, ConfigRepositoryProvider> oldEnvConfig = new ConcurrentHashMap<>();
private Map<String, ConfigRepositoryProvider> 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;
}
}

2
designer-realize/src/main/java/com/fanruan/boot/mem/MemConfigRepository.java → 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.event.ConfigListener;
import com.fanruan.config.realm.ConfigRepositoryProvider; import com.fanruan.config.realm.ConfigRepositoryProvider;

30
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;
}
}

19
designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java vendored

@ -1,7 +1,8 @@
package com.fanruan.boot.env; package com.fanruan.boot.env;
import com.fanruan.boot.ConfigHelper; import com.fr.design.ConfigHelper;
import com.fanruan.boot.key.StartupArgsShell; import com.fanruan.boot.key.StartupArgsShell;
import com.fr.design.mem.MemConfigRepositoryBuilder;
import com.fanruan.carina.Carina; import com.fanruan.carina.Carina;
import com.fanruan.carina.annotions.FineComponent; import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start; 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.design.plugin.remind.PluginErrorDesignReminder;
import com.fr.env.utils.WorkspaceUtils; import com.fr.env.utils.WorkspaceUtils;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.event.Null; import com.fr.event.Null;
import com.fr.file.filetree.FileNodes; 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.LocalLockInfoOperator;
import com.fr.report.lock.LockInfoOperator; import com.fr.report.lock.LockInfoOperator;
import com.fr.report.lock.ServerLockInfoOperator; import com.fr.report.lock.ServerLockInfoOperator;
import com.fr.stable.StringUtils; import com.fr.design.backup.DesignContext;
import com.fr.start.DesignContext;
import com.fr.start.module.StartupArgs; import com.fr.start.module.StartupArgs;
import com.fr.value.NotNullLazyValue; import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
@ -186,7 +185,6 @@ public class DesignEnvChooseComponent extends ResourceAffiliate {
String current = DesignerEnvManager.getEnvManager().getCurEnvName(); String current = DesignerEnvManager.getEnvManager().getCurEnvName();
workspaceInfo = WorkspaceUtils.getWorkspaceInfo(); workspaceInfo = WorkspaceUtils.getWorkspaceInfo();
((DesignContext)Carina.getApplicationContext()).setDesignWebInfPath(workspaceInfo.getPath()); ((DesignContext)Carina.getApplicationContext()).setDesignWebInfPath(workspaceInfo.getPath());
updateConfigPath(workspaceInfo);
Workspace workspace = DesignerWorkspaceGenerator.generate(workspaceInfo); Workspace workspace = DesignerWorkspaceGenerator.generate(workspaceInfo);
boolean checkValid = workspace != null && workspaceInfo.checkValid(); boolean checkValid = workspace != null && workspaceInfo.checkValid();
if (!checkValid) { if (!checkValid) {
@ -205,17 +203,14 @@ public class DesignEnvChooseComponent extends ResourceAffiliate {
private void updateConfigBuilder() { private void updateConfigBuilder() {
ConfigRepositoryFactory.getInstance().reset(); ConfigRepositoryFactory.getInstance().reset();
ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new LocalConfigRepositoryBuilder(ConfigHelper.getEnvProperties(), ConfigHelper.getEnvPropertiesPath())); if (WorkContext.getCurrent().isLocal()) {
} ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new LocalConfigRepositoryBuilder(ConfigHelper.getEnvProperties(), ConfigHelper.getEnvPropertiesPath()));
private void updateConfigPath(DesignerWorkspaceInfo workspaceInfo) {
if (StringUtils.isEmpty(workspaceInfo.getPath())) {
ConfigHelper.setPath(workspaceInfo.getConnection().getUrl());
} else { } else {
ConfigHelper.setPath(workspaceInfo.getPath()); ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new MemConfigRepositoryBuilder());
} }
} }
/** /**
* 注册切换环境前后事件监听 * 注册切换环境前后事件监听
*/ */

15
designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java vendored

@ -30,7 +30,6 @@ import com.fr.cbb.dialect.security.InsecurityElementFactory;
import com.fr.cluster.ClusterBridge; import com.fr.cluster.ClusterBridge;
import com.fr.cluster.lock.ClusterLock; import com.fr.cluster.lock.ClusterLock;
import com.fr.config.BaseDBEnv; import com.fr.config.BaseDBEnv;
import com.fr.config.ConfigContext;
import com.fr.config.ConfigEvent; import com.fr.config.ConfigEvent;
import com.fr.config.FinalPreferenceConfig; import com.fr.config.FinalPreferenceConfig;
import com.fr.config.dao.DaoContext; 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.ConfConfigProviderImpl;
import com.fr.config.impl.ConfigInsecurityElementProviderImpl; import com.fr.config.impl.ConfigInsecurityElementProviderImpl;
import com.fr.decision.service.context.ServiceContext; import com.fr.decision.service.context.ServiceContext;
import com.fr.design.backup.EnvBackupHelper;
import com.fr.env.detect.EnvDetectorCenter; import com.fr.env.detect.EnvDetectorCenter;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
@ -64,9 +64,7 @@ import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.record.analyzer.AnalyzerConfiguration; import com.fr.record.analyzer.AnalyzerConfiguration;
import com.fr.record.analyzer.AnalyzerKey;
import com.fr.record.analyzer.AnalyzerMutableGroup; import com.fr.record.analyzer.AnalyzerMutableGroup;
import com.fr.record.analyzer.Assistant;
import com.fr.record.analyzer.DBMetrics; import com.fr.record.analyzer.DBMetrics;
import com.fr.scheduler.QuartzContext; import com.fr.scheduler.QuartzContext;
import com.fr.scheduler.SchedulerEvent; 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.provider.SecuritySeedProvider;
import com.fr.security.encryption.storage.keys.LoadSeedSecurityKey; import com.fr.security.encryption.storage.keys.LoadSeedSecurityKey;
import com.fr.stable.GraphDrawHelper;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.db.DBContext; import com.fr.stable.db.DBContext;
import com.fr.stable.db.properties.FineMicroServicesDBProperties; 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.stable.project.ProjectConstants;
import com.fr.tenant.context.TenantContext; import com.fr.tenant.context.TenantContext;
import com.fr.tenant.context.provider.CurrentTenantKey; 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.implementation.MethodDelegation;
import com.fr.third.net.bytebuddy.matcher.ElementMatchers; 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.third.org.hibernate.jdbc.AbstractWork;
import com.fr.tolerance.FaultTolerance; import com.fr.tolerance.FaultTolerance;
import com.fr.tolerance.FaultToleranceInterceptor; import com.fr.tolerance.FaultToleranceInterceptor;
@ -102,7 +96,6 @@ import com.fr.workspace.WorkContext;
import java.net.URI; import java.net.URI;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Objects;
import java.util.Properties; import java.util.Properties;
/** /**
@ -249,7 +242,7 @@ public class DesignEnvComponent {
private void startFileServer() throws Exception { private void startFileServer() throws Exception {
if (WorkContext.getCurrent().isLocal()) { if (WorkContext.getCurrent().isLocal()) {
// 设计器远程下不需要文件系统,走PublicRepo的接口,本地下走基础的磁盘读写 // 设计器远程下不需要文件系统,走PublicRepo的接口,本地下走基础的磁盘读写
LocalFileRepository localFileRepository = LocalFileRepository.getSingleton(); LocalFileRepository localFileRepository = new LocalFileRepository(ProjectConstants.LOCAL_ENV, ServiceContext.getWebInfPath());
ResourceRepository realRepo = RepositoryFactory.getRepo(); ResourceRepository realRepo = RepositoryFactory.getRepo();
FSProperties fsProperties = Carina.properties(FSProperties.class); FSProperties fsProperties = Carina.properties(FSProperties.class);
FileServer.init( FileServer.init(
@ -304,6 +297,10 @@ public class DesignEnvComponent {
*/ */
private void startConfConfig() { private void startConfConfig() {
if (EnvBackupHelper.getInstance().isSwtiching()) {
// 如果是切换环境触发的start,说明此时读的是新环境的配置
EnvBackupHelper.getInstance().do4Switch4Config();
}
BaseDBEnv.setDBContext((DBContext) Carina.getApplicationContext().singleton(DBContextShell.class).get()); BaseDBEnv.setDBContext((DBContext) Carina.getApplicationContext().singleton(DBContextShell.class).get());
if (!WorkContext.getCurrent().isLocal()) { if (!WorkContext.getCurrent().isLocal()) {
TransactorFactory.setTransactor(new RemoteTransactor()); TransactorFactory.setTransactor(new RemoteTransactor());

20
designer-realize/src/main/java/com/fanruan/boot/mem/MemConfigRepositoryBuilder.java

@ -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);
}
}

17
designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java

@ -1,8 +1,7 @@
package com.fanruan.boot.pre; 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.key.StartupArgsShell;
import com.fanruan.boot.mem.MemConfigRepositoryBuilder;
import com.fanruan.carina.Carina; import com.fanruan.carina.Carina;
import com.fanruan.carina.annotions.FineComponent; import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start; 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.config.realm.local.LocalConfigRepositoryBuilder;
import com.fanruan.mq.CarinaMQ; import com.fanruan.mq.CarinaMQ;
import com.fanruan.mq.InternalMQProvider; import com.fanruan.mq.InternalMQProvider;
import com.fanruan.product.ProductConstants;
import com.fr.base.function.UITerminator; import com.fr.base.function.UITerminator;
import com.fr.carina.revert.provider.CarinaPluginProvider;
import com.fr.carina.util.CarinaResourceUtils; import com.fr.carina.util.CarinaResourceUtils;
import com.fr.carina.util.provider.CarinaResourceProvider; import com.fr.carina.util.provider.CarinaResourceProvider;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -36,13 +33,10 @@ import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.module.engine.event.LifecycleErrorEvent; import com.fr.module.engine.event.LifecycleErrorEvent;
import com.fr.plugin.ExtraClassManager;
import com.fr.runtime.FineRuntime; import com.fr.runtime.FineRuntime;
import com.fr.stable.CommonCodeUtils; import com.fr.stable.CommonCodeUtils;
import com.fr.stable.CommonUtils; import com.fr.stable.CommonUtils;
import com.fr.stable.fun.ResourcePathTransformer;
import com.fr.stable.lifecycle.FineLifecycleFatalError; import com.fr.stable.lifecycle.FineLifecycleFatalError;
import com.fr.stable.plugin.ExtraClassManagerProvider;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.stable.resource.ResourceLoader; import com.fr.stable.resource.ResourceLoader;
import com.fr.start.DesignerSubListener; 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.TenantContext;
import com.fr.tenant.context.provider.CurrentTenantKey; import com.fr.tenant.context.provider.CurrentTenantKey;
import com.fr.tenant.store.impl.DefaultTenantStorage; 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 com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**

1
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.PartitionManager;
import com.fanruan.carina.standard.PartitionManagerImpl; import com.fanruan.carina.standard.PartitionManagerImpl;
import com.fr.base.StateHubContext; import com.fr.base.StateHubContext;
import com.fr.design.backup.DesignContext;
import com.fr.design.carton.SwitchForSwingChecker; import com.fr.design.carton.SwitchForSwingChecker;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;

2
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.Listener;
import com.fr.event.Null; import com.fr.event.Null;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.start.DesignContext; import com.fr.design.backup.DesignContext;
import com.fr.value.NotNullLazyValue; import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;

Loading…
Cancel
Save