Browse Source

REPORT-114392-远程设计fbp能够正常使用 完善代码

mss/2.0
Destiny.Lin 5 months ago
parent
commit
d761b74dc8
  1. 6
      designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java
  2. 58
      designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java
  3. 2
      designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java

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

@ -104,7 +104,7 @@ import org.jetbrains.annotations.NotNull;
*/ */
@FineComponent(name = "design_env_choose") @FineComponent(name = "design_env_choose")
public class DesignEnvChooseComponent extends ResourceAffiliate { public class DesignEnvChooseComponent extends ResourceAffiliate {
private Listener<Workspace> beforeSwitch4Min = new Listener<Workspace>(Integer.MIN_VALUE) { private Listener<Workspace> afterSwitch4Max = new Listener<Workspace>(Integer.MAX_VALUE) {
@Override @Override
public void on(Event event, Workspace current) { public void on(Event event, Workspace current) {
@ -147,8 +147,8 @@ public class DesignEnvChooseComponent extends ResourceAffiliate {
@Start @Start
public void start() { public void start() {
registerEnvListener();
startEnvChoose(); startEnvChoose();
registerEnvListener();
afterAllStart(); afterAllStart();
} }
@ -217,7 +217,7 @@ public class DesignEnvChooseComponent extends ResourceAffiliate {
private void registerEnvListener() { private void registerEnvListener() {
/*切换环境前,重启所有相关模块,最后执行*/ /*切换环境前,重启所有相关模块,最后执行*/
listenEvent(WorkspaceEvent.BeforeSwitch, beforeSwitch4Min); listenEvent(WorkspaceEvent.AfterSwitch, afterSwitch4Max);
/*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/
listenEvent(WorkspaceEvent.BeforeSwitch, beforeSwitch4Max); listenEvent(WorkspaceEvent.BeforeSwitch, beforeSwitch4Max);

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

@ -169,36 +169,38 @@ public class DesignEnvComponent {
} }
private void startScheduler() { private void startScheduler() {
TenantContext.doIsolatedWork(() -> { if (WorkContext.getCurrent().isLocal()) {
ClusterLock lock = ClusterBridge.getLockFactory().get(SchedulerCoreComponent.class); TenantContext.doIsolatedWork(() -> {
// 多节点同时启动quartz模块可能会产生脏数据,导致报错,使用集群锁控制一下 ClusterLock lock = ClusterBridge.getLockFactory().get(SchedulerCoreComponent.class);
DBSession dbSession = null; // 多节点同时启动quartz模块可能会产生脏数据,导致报错,使用集群锁控制一下
try { DBSession dbSession = null;
lock.lock(); try {
final DBContextProvider context = BaseDBEnv.getDBContext(); lock.lock();
if (context == null) { final DBContextProvider context = BaseDBEnv.getDBContext();
throw new IllegalArgumentException("ConfigDBActivator must start before SchedulerActivator"); if (context == null) {
} throw new IllegalArgumentException("ConfigDBActivator must start before SchedulerActivator");
dbSession = context.openSession(); }
dbSession.doWork(new AbstractWork() { dbSession = context.openSession();
dbSession.doWork(new AbstractWork() {
@Override
public void execute(Connection connection) throws SQLException { @Override
//quartz需要的数据库方言 public void execute(Connection connection) throws SQLException {
Properties properties = context.getDBProperties(); //quartz需要的数据库方言
QuartzContext.getInstance().initScheduler(properties); 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();
} }
}); lock.unlock();
EventDispatcher.fire(SchedulerEvent.START);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
if (dbSession != null) {
dbSession.closeSession();
} }
lock.unlock(); }, "default");
} }
}, "default");
} }

2
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.CompatibleConnectionOperator;
import com.fr.workspace.server.repository.compatible.register.CompatibleRegister; import com.fr.workspace.server.repository.compatible.register.CompatibleRegister;
import com.fanruan.workplace.network.RemoteNetworkRepository; 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.connection.ConnectionRepository;
import com.fr.workspace.server.repository.resource.PublicResourceRepository; import com.fr.workspace.server.repository.resource.PublicResourceRepository;
import com.fr.workspace.server.repository.resource.WorkResourceRepository; import com.fr.workspace.server.repository.resource.WorkResourceRepository;
@ -98,6 +99,7 @@ public class DesignWorkContextComponent {
RepositoryManager.getInstance().pureRegisterRepo4Start(ShareRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(ShareRepository.getInstance());
RepositoryManager.getInstance().pureRegisterRepo4Start(WorkResourceRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(WorkResourceRepository.getInstance());
RepositoryManager.getInstance().pureRegisterRepo4Start(PublicResourceRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(PublicResourceRepository.getInstance());
RepositoryManager.getInstance().pureRegisterRepo4Start(ConfigRepository.getInstance());
RepositoryManager.getInstance().initLocalRepository(); RepositoryManager.getInstance().initLocalRepository();
CompatibleRegister.registerCompatibleEnv(); CompatibleRegister.registerCompatibleEnv();
for (WorkRPCRegister<?> workRPCRegister : ServiceContext.group(WorkspaceKey.class).getAll()) { for (WorkRPCRegister<?> workRPCRegister : ServiceContext.group(WorkspaceKey.class).getAll()) {

Loading…
Cancel
Save