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 6881c8445c..cd9c835f39 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -8,6 +8,7 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.env.RemoteWorkspace; @@ -105,6 +106,7 @@ public class EnvChangeEntrance { private boolean switch2Env(final String envName, PopTipStrategy strategy) { DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName); + DesignerWorkspaceInfoContext.setWorkspaceInfo(selectedEnv); WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); try { diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java new file mode 100644 index 0000000000..ba8a5b09f4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfoContext.java @@ -0,0 +1,20 @@ +package com.fr.design.env; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/24 + */ +public class DesignerWorkspaceInfoContext { + + private static DesignerWorkspaceInfo workspaceInfo; + + public static DesignerWorkspaceInfo getWorkspaceInfo() { + return workspaceInfo; + } + + public static void setWorkspaceInfo(DesignerWorkspaceInfo workspaceInfo) { + DesignerWorkspaceInfoContext.workspaceInfo = workspaceInfo; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index c1e994bdc4..5f3e57b26e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -6,6 +6,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.EnvChangeEntrance; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceInfoContext; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.loghandler.DesignerLogger; @@ -127,9 +128,7 @@ public class DesignerSocketIO { } private static SSLContext getSSLContext() throws Exception { - String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); - DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); - WorkspaceConnectionInfo connection = info.getConnection(); + WorkspaceConnectionInfo connection = getConnectionInfo(); String certPath = connection.getCertPath(); String certSecretKey = connection.getCertSecretKey(); if (StringUtils.isBlank(certPath) || StringUtils.isBlank(certSecretKey)) { @@ -144,6 +143,16 @@ public class DesignerSocketIO { .build(); } + private static WorkspaceConnectionInfo getConnectionInfo() { + if (DesignerWorkspaceInfoContext.getWorkspaceInfo() == null) { + String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); + DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); + return info.getConnection(); + } else { + return DesignerWorkspaceInfoContext.getWorkspaceInfo().getConnection(); + } + } + private static String[] getSocketUri() throws IOException { Workspace current = WorkContext.getCurrent(); URL url = new URL(current.getPath());