Browse Source

Pull request #13312: REPORT-109525 【设计器性能】启动性能优化

Merge in DESIGN/design from ~DESTINY.LIN/design:feature/x to feature/x

* commit '4fecaf1c7bf50a51e6288336988d60265673b0d6':
  REPORT-109525 【设计器性能】启动性能优化 完善逻辑
  REPORT-109525 【设计器性能】启动性能优化 规范
  REPORT-109525 【设计器性能】启动性能优化
feature/x
Destiny.Lin-林锦龙 12 months ago
parent
commit
3e8af4dfe8
  1. 2
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  2. 15
      designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java
  3. 2
      designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateConfigManager.java
  4. 2
      designer-base/src/main/java/com/fr/start/server/FineEmbedServer.java
  5. 11
      designer-realize/src/main/java/com/fr/design/share/SharableManager.java
  6. 2
      designer-realize/src/main/java/com/fr/start/DesignerInitial.java
  7. 16
      designer-realize/src/main/java/com/fr/start/MainDesigner.java
  8. 17
      designer-realize/src/main/java/com/fr/start/SplashContext.java
  9. 1
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  10. 9
      designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

2
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -308,7 +308,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter, AsyncXmlReada
private static boolean asyncInitEnvManager() { private static boolean asyncInitEnvManager() {
AtomicBoolean noEx = new AtomicBoolean(false); AtomicBoolean noEx = new AtomicBoolean(false);
OptimizeUtil.open(DesignerEnvManager.class.getSimpleName().toLowerCase(), OptimizeUtil.Module.COMMON, () -> { OptimizeUtil.initiateOpen(DesignerEnvManager.class.getSimpleName().toLowerCase(), () -> {
try { try {
designerEnvManager.initElements(designerEnvManager.getDesignerEnvFile()); designerEnvManager.initElements(designerEnvManager.getDesignerEnvFile());
noEx.set(true); noEx.set(true);

15
designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java

@ -11,6 +11,11 @@ import com.fr.event.Null;
* @date 2019-06-18 * @date 2019-06-18
*/ */
public enum DesignerLaunchStatus implements Event<Null> { public enum DesignerLaunchStatus implements Event<Null> {
/**
* 界面前置事件初始化完成
*/
UI_PRE_INIT_COMPLETE,
/** /**
* 初始化环境完成 * 初始化环境完成
*/ */
@ -46,4 +51,14 @@ public enum DesignerLaunchStatus implements Event<Null> {
status = state; status = state;
EventDispatcher.fire(DesignerLaunchStatus.getStatus()); EventDispatcher.fire(DesignerLaunchStatus.getStatus());
} }
/**
* 设置状态并异步触发事件
*
* @param state 当前启动状态
*/
public static void setStatusAndAsyncFire(DesignerLaunchStatus state) {
status = state;
EventDispatcher.asyncFire(DesignerLaunchStatus.getStatus());
}
} }

2
designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateConfigManager.java

@ -15,7 +15,7 @@ public class DesignerPushUpdateConfigManager implements XMLReadable, XMLWriter {
private static DesignerPushUpdateConfigManager singleton; private static DesignerPushUpdateConfigManager singleton;
private boolean autoPushUpdateEnabled = true; // 是否开启自动推送更新 private boolean autoPushUpdateEnabled = true; // 是否开启自动推送更新
private boolean cloudAnalyticsDelay = false; // 是否云端运维模块延迟启动 private boolean cloudAnalyticsDelay = true; // 是否云端运维模块延迟启动
private String lastIgnoredVersion = StringUtils.EMPTY; // 最近一次跳过的更新版本 private String lastIgnoredVersion = StringUtils.EMPTY; // 最近一次跳过的更新版本
private DesignerPushUpdateConfigManager() { private DesignerPushUpdateConfigManager() {

2
designer-base/src/main/java/com/fr/start/server/FineEmbedServer.java

@ -2,6 +2,7 @@ package com.fr.start.server;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.module.ModuleContext; import com.fr.module.ModuleContext;
import com.fr.plugin.listener.SpecialPluginEvent;
/** /**
* Created by juhaoyu on 2018/6/6. * Created by juhaoyu on 2018/6/6.
@ -15,6 +16,7 @@ public abstract class FineEmbedServer {
public synchronized static void start() { public synchronized static void start() {
onStarting = true; onStarting = true;
EventDispatcher.fire(SpecialPluginEvent.WITH_SERVER_AND_NOT_START_IN_REMOTE);
EventDispatcher.fire(EmbedServerEvent.BeforeStart); EventDispatcher.fire(EmbedServerEvent.BeforeStart);
ModuleContext.getModule(FineEmbedServerActivator.class).start(); ModuleContext.getModule(FineEmbedServerActivator.class).start();
onStarting = false; onStarting = false;

11
designer-realize/src/main/java/com/fr/design/share/SharableManager.java

@ -8,6 +8,7 @@ import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.collect.SharableCollectorManager; import com.fr.design.mainframe.share.collect.SharableCollectorManager;
import com.fr.design.mainframe.share.config.ComponentReuseConfigManager;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler; import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptSelectionClipboardHandler;
import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptTransferableClipboardHandler; import com.fr.design.mainframe.share.encrypt.clipboard.impl.EncryptTransferableClipboardHandler;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane; import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane;
@ -30,11 +31,13 @@ import java.util.List;
public class SharableManager { public class SharableManager {
public static void start() { public static void start() {
SharableCollectorManager.getInstance().execute(); if (ComponentReuseConfigManager.getInstance().supportUploadReu()) {
SharableCollectorManager.getInstance().execute();
ClipboardFilter.registerClipboardHandler(EncryptSelectionClipboardHandler.getInstance());
ClipboardFilter.registerClipboardHandler(EncryptTransferableClipboardHandler.getInstance());
registerSharableEncryptDefinePanes();
}
listenEnv(); listenEnv();
ClipboardFilter.registerClipboardHandler(EncryptSelectionClipboardHandler.getInstance());
ClipboardFilter.registerClipboardHandler(EncryptTransferableClipboardHandler.getInstance());
registerSharableEncryptDefinePanes();
} }
public static void saveTemplate(JTemplate jt) { public static void saveTemplate(JTemplate jt) {

2
designer-realize/src/main/java/com/fr/start/DesignerInitial.java

@ -35,7 +35,7 @@ public class DesignerInitial {
SplashContext.getInstance().hide(); SplashContext.getInstance().hide();
} }
}); });
DesignerLaunchStatus.setStatus(DesignerLaunchStatus.STARTUP_COMPLETE); DesignerLaunchStatus.setStatusAndAsyncFire(DesignerLaunchStatus.STARTUP_COMPLETE);
} }
}); });
}); });

16
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -12,6 +12,7 @@ import com.fr.design.actions.server.TemplateThemeManagerAction;
import com.fr.design.actions.server.WidgetManagerAction; import com.fr.design.actions.server.WidgetManagerAction;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.carton.SwitchForSwingChecker; import com.fr.design.carton.SwitchForSwingChecker;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.deeplink.DeepLinkManager; import com.fr.design.deeplink.DeepLinkManager;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
@ -58,6 +59,7 @@ import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.log.SystemOutLoggerProvider;
import com.fr.module.Module; import com.fr.module.Module;
import com.fr.module.ModuleContext; import com.fr.module.ModuleContext;
import com.fr.module.engine.event.LifecycleErrorEvent; import com.fr.module.engine.event.LifecycleErrorEvent;
@ -117,11 +119,14 @@ public class MainDesigner extends BaseDesigner {
* @param args 参数 * @param args 参数
*/ */
public static void main(String[] args) { public static void main(String[] args) {
DesignerStartupContext.getRecorder().start(); DesignerStartupContext.getRecorder().start();
// 设置一下默认的logger,启动后再Reset
FineLoggerFactory.setLogger(SystemOutLoggerProvider.getInstance());
showSplash();
DesignerEnvManager.getEnvManager(); DesignerEnvManager.getEnvManager();
startPreload0(); startPreload0();
DesignerLifecycleMonitorContext.getMonitor().beforeStart(); DesignerLifecycleMonitorContext.getMonitor().beforeStart();
@ -129,7 +134,7 @@ public class MainDesigner extends BaseDesigner {
FineRuntime.start(); FineRuntime.start();
//等 FineRuntime 启动后启动 //等 FineRuntime 启动后启动
DeepLinkManager.getInstance().start(args); DeepLinkManager.getInstance().start(args);
startPreload1(); startPreload1();
DesignerSubListener.getInstance().start(); DesignerSubListener.getInstance().start();
@ -166,8 +171,7 @@ public class MainDesigner extends BaseDesigner {
CompletableFuture<Void> initLookAndFeel = CompletableFuture.runAsync(DesignUtils::initLookAndFeel); CompletableFuture<Void> initLookAndFeel = CompletableFuture.runAsync(DesignUtils::initLookAndFeel);
PreLoadService.getInstance().addUIFuture(initLookAndFeel); PreLoadService.getInstance().addUIFuture(initLookAndFeel);
DesignerLaunchStatus.setStatusAndAsyncFire(DesignerLaunchStatus.UI_PRE_INIT_COMPLETE);
showSplash();
} }
/** /**

17
designer-realize/src/main/java/com/fr/start/SplashContext.java

@ -1,11 +1,13 @@
package com.fr.start; package com.fr.start;
import com.fr.concurrent.NamedThreadFactory; import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.design.mainframe.bbs.BBSConstants;
import com.fr.event.Event; import com.fr.event.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.general.locale.image.I18nImage; import com.fr.general.locale.image.I18nImage;
import com.fr.module.ModuleEvent; import com.fr.module.ModuleEvent;
@ -28,13 +30,13 @@ public class SplashContext {
public static final String SPLASH_PATH = getSplashPath(); public static final String SPLASH_PATH = getSplashPath();
public static final String SPLASH_CACHE_NAME = SPLASH_PATH.substring(SPLASH_PATH.lastIndexOf("/") + 1); public static final String SPLASH_CACHE_NAME = SPLASH_PATH.substring(SPLASH_PATH.lastIndexOf("/") + 1);
private static final int FETCH_ONLINE_MAX_TIMES = 50; private static final int FETCH_ONLINE_MAX_TIMES = 50;
private static final String THANKS = Toolkit.i18nText("Fine-Design_Report_Thanks_To"); private String thanks = StringUtils.EMPTY;
private static final SplashContext SPLASH_CONTEXT = new SplashContext(); private static final SplashContext SPLASH_CONTEXT = new SplashContext();
private SplashStrategy splashStrategy; private SplashStrategy splashStrategy;
private String moduleId = Toolkit.i18nText("Fine-Design_Basic_Initializing"); private String moduleId = StringUtils.EMPTY;
private int loadingIndex = 0; private int loadingIndex = 0;
private String[] loading = new String[]{"..", "....", "......"}; private String[] loading = new String[]{"..", "....", "......"};
@ -73,7 +75,12 @@ public class SplashContext {
public void show() { public void show() {
splashStrategy.show(); splashStrategy.show();
//监听 //监听
initListener(); EventDispatcher.listen(DesignerLaunchStatus.UI_PRE_INIT_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
initListener();
}
});
} }
/** /**
@ -91,6 +98,8 @@ public class SplashContext {
} }
private void initListener() { private void initListener() {
thanks = Toolkit.i18nText("Fine-Design_Report_Thanks_To");
moduleId = Toolkit.i18nText("Fine-Design_Basic_Initializing");
scheduler.scheduleAtFixedRate(new Runnable() { scheduler.scheduleAtFixedRate(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -157,7 +166,7 @@ public class SplashContext {
if (shouldShowThanks() && !hasShowThanks) { if (shouldShowThanks() && !hasShowThanks) {
tryFetchOnline(); tryFetchOnline();
if (StringUtils.isNotEmpty(guest)) { if (StringUtils.isNotEmpty(guest)) {
updateThanksLog(THANKS + guest); updateThanksLog(thanks + guest);
hasShowThanks = true; hasShowThanks = true;
} }
} }

1
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -554,6 +554,7 @@ public class DesignerActivator extends Activator implements Prepare {
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() { EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override @Override
public void on(Event event, Null param) { public void on(Event event, Null param) {
FineLoggerFactory.reset();
new SwingWorker<Void, Void>() { new SwingWorker<Void, Void>() {
@Override @Override

9
designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java

@ -2,12 +2,18 @@ package com.fr.start.module;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.RestartHelper; import com.fr.design.RestartHelper;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.file.TemplateResourceManager; import com.fr.design.file.TemplateResourceManager;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.file.TmpFileUtils; import com.fr.file.TmpFileUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.module.Activator; import com.fr.module.Activator;
import com.fr.start.common.DesignerStartupPool;
/** /**
* Created by juhaoyu on 2018/1/8. * Created by juhaoyu on 2018/1/8.
@ -17,7 +23,8 @@ public class PreStartActivator extends Activator {
@Override @Override
public void start() { public void start() {
//清空临时文件 //清空临时文件
TmpFileUtils.cleanUpInnerTmpFiles(); Runtime.getRuntime().addShutdownHook(new Thread(TmpFileUtils::cleanUpInnerTmpFiles));
RestartHelper.deleteRecordFilesWhenStart(); RestartHelper.deleteRecordFilesWhenStart();
//初始化起始画面放到 SplashContext 里面 //初始化起始画面放到 SplashContext 里面
//EventDispatcher.fire(ModuleEvent.MajorModuleStarting, Toolkit.i18nText("Fine-Design_Basic_Initializing")); //EventDispatcher.fire(ModuleEvent.MajorModuleStarting, Toolkit.i18nText("Fine-Design_Basic_Initializing"));

Loading…
Cancel
Save