From 9656561af1e8d5ddf98a3dbfd2ebe5521cfe04af Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 14 Mar 2022 16:21:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20KERNEL-10354=20bytebuddy=20/=20?= =?UTF-8?q?=E5=8A=A0=E8=A7=A3=E5=AF=86=E6=80=A7=E8=83=BD=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20@Harrison=20=E5=A4=84=E7=90=86=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E7=9A=84=20loginAuthServer=20=E9=80=BB=E8=BE=91=20=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E7=9A=84=E6=97=B6=E5=80=99=E6=AF=94=E8=BE=83=E8=80=97?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=AE=8C=E5=85=A8=E6=B2=A1=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E7=9A=84=E6=97=B6=E5=80=99=E5=B0=B1=E8=B5=B7?= =?UTF-8?q?=E6=9D=A5=E3=80=82=20=E7=AD=89=E5=90=AF=E5=8A=A8=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=90=8E=E5=90=AF=E5=8A=A8=E4=B9=9F=E6=B2=A1=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../login/socketio/LoginAuthServer.java | 26 ++++++++++++++++++- .../fr/start/module/DesignerActivator.java | 23 +++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/login/socketio/LoginAuthServer.java b/designer-base/src/main/java/com/fr/design/login/socketio/LoginAuthServer.java index d60b97d0f6..0340fc3de3 100644 --- a/designer-base/src/main/java/com/fr/design/login/socketio/LoginAuthServer.java +++ b/designer-base/src/main/java/com/fr/design/login/socketio/LoginAuthServer.java @@ -1,5 +1,6 @@ package com.fr.design.login.socketio; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; import com.fr.design.login.DesignerLoginType; import com.fr.design.login.bean.BBSAccountLogin; @@ -11,7 +12,11 @@ import com.fr.third.socketio.Configuration; import com.fr.third.socketio.SocketIOClient; import com.fr.third.socketio.SocketIOServer; import com.fr.third.socketio.listener.DataListener; + import java.net.URLDecoder; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicBoolean; /** * @author Lanlan @@ -19,9 +24,11 @@ import java.net.URLDecoder; * Created by Lanlan on 2021/6/3 */ public class LoginAuthServer { + + private AtomicBoolean started = new AtomicBoolean(false); private SocketIOServer server; - + private static final String HOSTNAME = "localhost"; private static final int PORT = 41925; @@ -47,6 +54,23 @@ public class LoginAuthServer { } public void start() { + + // 只运行一次,不在乎成不成功 + if (started.compareAndSet(false, true)) { + asyncStart(); + } + } + + public void asyncStart() { + + ExecutorService asyncService = Executors.newSingleThreadExecutor(new NamedThreadFactory(LoginAuthServer.class.getName(), true)); + asyncService.submit(this::compatibleStart); + asyncService.shutdown(); + } + + @Deprecated + public void compatibleStart() { + try { server.start(); } catch (Exception e) { diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index be583c7d56..b8612fc6b5 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -3,6 +3,7 @@ package com.fr.start.module; import com.fr.base.BaseFormula; import com.fr.base.Formula; import com.fr.base.MultiFieldParameter; +import com.fr.base.OptimizeUtil; import com.fr.base.passport.FinePassportListenerAdapter; import com.fr.base.passport.FinePassportManager; import com.fr.base.process.ProcessOperator; @@ -80,7 +81,10 @@ import com.fr.design.share.ui.generate.ShareGeneratePane; import com.fr.design.update.actions.RecoverForDesigner; import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; +import com.fr.event.Event; import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.event.Null; import com.fr.general.GeneralContext; import com.fr.general.xml.GeneralXMLTools; import com.fr.js.EmailJavaScript; @@ -159,6 +163,8 @@ public class DesignerActivator extends Activator implements Prepare { @Override public void start() { + + startLoginAuthServer(); migrateBBSInfoFromFineDB(); FormThemeConfigMigrator.getInstance().upgrade(); ReportThemeConfigMigrator.getInstance().upgrade(); @@ -488,7 +494,22 @@ public class DesignerActivator extends Activator implements Prepare { @Override public void prepare() { - LoginAuthServer.getInstance().start(); + ContentReplacerCenter.getInstance().register(); } + + private void startLoginAuthServer() { + + OptimizeUtil.execute(() -> { + // 设计器启动后启动 + EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener() { + @Override + public void on(Event event, Null param) { + LoginAuthServer.getInstance().start(); + } + }); + }, () -> { + LoginAuthServer.getInstance().compatibleStart(); + }); + } }