From 1f5f4613a1f8d589b43e8643f3af04739d763e0d Mon Sep 17 00:00:00 2001 From: Hades Date: Wed, 27 Jan 2021 11:40:29 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-45901=20=E3=80=9010.0.14=E3=80=91oem?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=A4=9A=E5=BC=80=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=20--=E5=8A=A0=E4=B8=8A=E7=AB=AF=E5=8F=A3=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 7 ++-- .../fr/design/port/DesignerPortContext.java | 32 +++++++++++++++++++ .../com/fr/design/utils/DesignerPort.java | 11 ++++--- 3 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/port/DesignerPortContext.java diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 4adcfc1b34..b8951ea8ba 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -20,6 +20,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.notification.SnapChatConfig; +import com.fr.design.port.DesignerPortContext; import com.fr.design.update.push.DesignerPushUpdateConfigManager; import com.fr.design.style.color.ColorSelectConfigManager; import com.fr.design.utils.DesignUtils; @@ -844,9 +845,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * 返回Jetty服务器的端口号 */ public int getEmbedServerPort() { - DesignerPortProvider portProvider = StableFactory.getMarkedInstanceObjectFromClass(DesignerPortProvider.MARK_STRING, DesignerPortProvider.class); - if (portProvider != null) { - return portProvider.embeddedServerPort(); + int embeddedServerPort = DesignerPortContext.getEmbeddedServerPort(); + if (embeddedServerPort >= DesignerPort.MIN_PORT && embeddedServerPort <= DesignerPort.MAX_PORT) { + return embeddedServerPort; } return this.jettyServerPort; } diff --git a/designer-base/src/main/java/com/fr/design/port/DesignerPortContext.java b/designer-base/src/main/java/com/fr/design/port/DesignerPortContext.java new file mode 100644 index 0000000000..e1e40ddfb0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/port/DesignerPortContext.java @@ -0,0 +1,32 @@ +package com.fr.design.port; + +import com.fr.design.fun.DesignerPortProvider; +import com.fr.stable.bridge.StableFactory; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/1/27 + */ +public class DesignerPortContext { + + private static int messagePort = -1; + + private static int embeddedServerPort = -1; + + static { + DesignerPortProvider designerPortProvider = StableFactory.getMarkedInstanceObjectFromClass(DesignerPortProvider.MARK_STRING, DesignerPortProvider.class); + if (designerPortProvider != null) { + messagePort = designerPortProvider.messagePort(); + embeddedServerPort = designerPortProvider.embeddedServerPort(); + } + } + + public static int getMessagePort() { + return messagePort; + } + + public static int getEmbeddedServerPort() { + return embeddedServerPort; + } +} diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java index 474c29a8f5..28ab5e4c14 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java @@ -10,6 +10,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.port.DesignerPortContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.exit.DesignerExiter; import com.fr.general.ComparatorUtils; @@ -36,8 +37,8 @@ import java.awt.event.ActionListener; public class DesignerPort implements XMLReadable, XMLWriter { public static final String XML_TAG = "DesignerPort"; - private static final int MIN_PORT = 1024; - private static final int MAX_PORT = 65535; + public static final int MIN_PORT = 1024; + public static final int MAX_PORT = 65535; public static final DesignerPort INSTANCE = new DesignerPort(); @@ -59,9 +60,9 @@ public class DesignerPort implements XMLReadable, XMLWriter { private int debugMessagePort = 51463; public int getMessagePort() { - DesignerPortProvider portProvider = StableFactory.getMarkedInstanceObjectFromClass(DesignerPortProvider.MARK_STRING, DesignerPortProvider.class); - if (portProvider != null) { - return portProvider.messagePort(); + int extraMessagePort = DesignerPortContext.getMessagePort(); + if (extraMessagePort >= MIN_PORT && extraMessagePort <= MAX_PORT) { + return extraMessagePort; } return messagePort; }