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 3a0b195b03..35bbba6819 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 @@ -104,7 +104,7 @@ import org.jetbrains.annotations.NotNull; */ @FineComponent(name = "design_env_choose") public class DesignEnvChooseComponent extends ResourceAffiliate { - private Listener beforeSwitch4Min = new Listener(Integer.MIN_VALUE) { + private Listener afterSwitch4Max = new Listener(Integer.MAX_VALUE) { @Override public void on(Event event, Workspace current) { @@ -147,8 +147,8 @@ public class DesignEnvChooseComponent extends ResourceAffiliate { @Start public void start() { - registerEnvListener(); startEnvChoose(); + registerEnvListener(); afterAllStart(); } @@ -217,7 +217,7 @@ public class DesignEnvChooseComponent extends ResourceAffiliate { private void registerEnvListener() { /*切换环境前,重启所有相关模块,最后执行*/ - listenEvent(WorkspaceEvent.BeforeSwitch, beforeSwitch4Min); + listenEvent(WorkspaceEvent.AfterSwitch, afterSwitch4Max); /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ listenEvent(WorkspaceEvent.BeforeSwitch, beforeSwitch4Max); 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 b4a1e91e85..0621a6a7ae 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 @@ -169,36 +169,38 @@ public class DesignEnvComponent { } private void startScheduler() { - TenantContext.doIsolatedWork(() -> { - ClusterLock lock = ClusterBridge.getLockFactory().get(SchedulerCoreComponent.class); - // 多节点同时启动quartz模块可能会产生脏数据,导致报错,使用集群锁控制一下 - DBSession dbSession = null; - try { - lock.lock(); - final DBContextProvider context = BaseDBEnv.getDBContext(); - if (context == null) { - throw new IllegalArgumentException("ConfigDBActivator must start before SchedulerActivator"); - } - dbSession = context.openSession(); - dbSession.doWork(new AbstractWork() { - - @Override - public void execute(Connection connection) throws SQLException { - //quartz需要的数据库方言 - Properties properties = context.getDBProperties(); - QuartzContext.getInstance().initScheduler(properties); + if (WorkContext.getCurrent().isLocal()) { + TenantContext.doIsolatedWork(() -> { + ClusterLock lock = ClusterBridge.getLockFactory().get(SchedulerCoreComponent.class); + // 多节点同时启动quartz模块可能会产生脏数据,导致报错,使用集群锁控制一下 + DBSession dbSession = null; + try { + lock.lock(); + final DBContextProvider context = BaseDBEnv.getDBContext(); + if (context == null) { + throw new IllegalArgumentException("ConfigDBActivator must start before SchedulerActivator"); + } + dbSession = context.openSession(); + dbSession.doWork(new AbstractWork() { + + @Override + public void execute(Connection connection) throws SQLException { + //quartz需要的数据库方言 + Properties properties = context.getDBProperties(); + QuartzContext.getInstance().initScheduler(properties); + } + }); + EventDispatcher.fire(SchedulerEvent.START); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } finally { + if (dbSession != null) { + dbSession.closeSession(); } - }); - EventDispatcher.fire(SchedulerEvent.START); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } finally { - if (dbSession != null) { - dbSession.closeSession(); + lock.unlock(); } - lock.unlock(); - } - }, "default"); + }, "default"); + } } diff --git a/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java index 8049690aec..2c01bcd005 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java @@ -50,6 +50,7 @@ import com.fr.workspace.server.repository.authority.RemoteAuthorityRepository; import com.fr.workspace.server.repository.compatible.CompatibleConnectionOperator; import com.fr.workspace.server.repository.compatible.register.CompatibleRegister; import com.fanruan.workplace.network.RemoteNetworkRepository; +import com.fr.workspace.server.repository.config.ConfigRepository; import com.fr.workspace.server.repository.connection.ConnectionRepository; import com.fr.workspace.server.repository.resource.PublicResourceRepository; import com.fr.workspace.server.repository.resource.WorkResourceRepository; @@ -98,6 +99,7 @@ public class DesignWorkContextComponent { RepositoryManager.getInstance().pureRegisterRepo4Start(ShareRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(WorkResourceRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(PublicResourceRepository.getInstance()); + RepositoryManager.getInstance().pureRegisterRepo4Start(ConfigRepository.getInstance()); RepositoryManager.getInstance().initLocalRepository(); CompatibleRegister.registerCompatibleEnv(); for (WorkRPCRegister workRPCRegister : ServiceContext.group(WorkspaceKey.class).getAll()) {