Browse Source

Pull request #14206: REPORT-114392-远程设计fbp能够正常使用 完善代码

Merge in DESIGN/design from ~DESTINY.LIN/design:mss/2.0 to mss/2.0

* commit '575b80c556bf45f6fcdbf77c26ab0a9ac24b395a':
  REPORT-114392-远程设计fbp能够正常使用 完善代码
mss/2.0
Destiny.Lin-林锦龙 4 months ago
parent
commit
280e2ff39a
  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")
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
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);

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

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

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.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()) {

Loading…
Cancel
Save