Browse Source

feat: KERNEL-10354 bytebuddy / 加解密性能优化 @Harrison

处理设计器的 loginAuthServer 逻辑
启动的时候比较耗时,完全没必要启动的时候就起来。
等启动完成后启动也没关系
feature/x
Harrison 3 years ago
parent
commit
9656561af1
  1. 24
      designer-base/src/main/java/com/fr/design/login/socketio/LoginAuthServer.java
  2. 23
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

24
designer-base/src/main/java/com/fr/design/login/socketio/LoginAuthServer.java

@ -1,5 +1,6 @@
package com.fr.design.login.socketio; package com.fr.design.login.socketio;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.login.DesignerLoginType; import com.fr.design.login.DesignerLoginType;
import com.fr.design.login.bean.BBSAccountLogin; 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.SocketIOClient;
import com.fr.third.socketio.SocketIOServer; import com.fr.third.socketio.SocketIOServer;
import com.fr.third.socketio.listener.DataListener; import com.fr.third.socketio.listener.DataListener;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
/** /**
* @author Lanlan * @author Lanlan
@ -20,6 +25,8 @@ import java.net.URLDecoder;
*/ */
public class LoginAuthServer { public class LoginAuthServer {
private AtomicBoolean started = new AtomicBoolean(false);
private SocketIOServer server; private SocketIOServer server;
private static final String HOSTNAME = "localhost"; private static final String HOSTNAME = "localhost";
@ -47,6 +54,23 @@ public class LoginAuthServer {
} }
public void start() { 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 { try {
server.start(); server.start();
} catch (Exception e) { } catch (Exception e) {

23
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.BaseFormula;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.base.MultiFieldParameter; import com.fr.base.MultiFieldParameter;
import com.fr.base.OptimizeUtil;
import com.fr.base.passport.FinePassportListenerAdapter; import com.fr.base.passport.FinePassportListenerAdapter;
import com.fr.base.passport.FinePassportManager; import com.fr.base.passport.FinePassportManager;
import com.fr.base.process.ProcessOperator; 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.actions.RecoverForDesigner;
import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.design.update.push.DesignerPushUpdateManager;
import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane;
import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.xml.GeneralXMLTools; import com.fr.general.xml.GeneralXMLTools;
import com.fr.js.EmailJavaScript; import com.fr.js.EmailJavaScript;
@ -159,6 +163,8 @@ public class DesignerActivator extends Activator implements Prepare {
@Override @Override
public void start() { public void start() {
startLoginAuthServer();
migrateBBSInfoFromFineDB(); migrateBBSInfoFromFineDB();
FormThemeConfigMigrator.getInstance().upgrade(); FormThemeConfigMigrator.getInstance().upgrade();
ReportThemeConfigMigrator.getInstance().upgrade(); ReportThemeConfigMigrator.getInstance().upgrade();
@ -488,7 +494,22 @@ public class DesignerActivator extends Activator implements Prepare {
@Override @Override
public void prepare() { public void prepare() {
LoginAuthServer.getInstance().start();
ContentReplacerCenter.getInstance().register(); ContentReplacerCenter.getInstance().register();
} }
private void startLoginAuthServer() {
OptimizeUtil.execute(() -> {
// 设计器启动后启动
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
LoginAuthServer.getInstance().start();
}
});
}, () -> {
LoginAuthServer.getInstance().compatibleStart();
});
}
} }

Loading…
Cancel
Save