Browse Source

REPORT-109525 【设计器性能】启动性能优化

feature/x
Destiny.Lin 11 months ago
parent
commit
afa1999115
  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. 10
      designer-realize/src/main/java/com/fr/start/MainDesigner.java
  8. 15
      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() {
AtomicBoolean noEx = new AtomicBoolean(false);
OptimizeUtil.open(DesignerEnvManager.class.getSimpleName().toLowerCase(), OptimizeUtil.Module.COMMON, () -> {
OptimizeUtil.initiateOpen(DesignerEnvManager.class.getSimpleName().toLowerCase(), () -> {
try {
designerEnvManager.initElements(designerEnvManager.getDesignerEnvFile());
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
*/
public enum DesignerLaunchStatus implements Event<Null> {
/**
* 界面前置事件初始化完成
*/
UI_PRE_INIT_COMPLETE,
/**
* 初始化环境完成
*/
@ -46,4 +51,14 @@ public enum DesignerLaunchStatus implements Event<Null> {
status = state;
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 boolean autoPushUpdateEnabled = true; // 是否开启自动推送更新
private boolean cloudAnalyticsDelay = false; // 是否云端运维模块延迟启动
private boolean cloudAnalyticsDelay = true; // 是否云端运维模块延迟启动
private String lastIgnoredVersion = StringUtils.EMPTY; // 最近一次跳过的更新版本
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.module.ModuleContext;
import com.fr.plugin.engine.core.SpecialPluginEvent;
/**
* Created by juhaoyu on 2018/6/6.
@ -15,6 +16,7 @@ public abstract class FineEmbedServer {
public synchronized static void start() {
onStarting = true;
EventDispatcher.fire(SpecialPluginEvent.WITH_SERVER_AND_NOT_START_IN_REMOTE);
EventDispatcher.fire(EmbedServerEvent.BeforeStart);
ModuleContext.getModule(FineEmbedServerActivator.class).start();
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.share.collect.ComponentCollector;
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.EncryptTransferableClipboardHandler;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane;
@ -30,11 +31,13 @@ import java.util.List;
public class SharableManager {
public static void start() {
SharableCollectorManager.getInstance().execute();
if (ComponentReuseConfigManager.getInstance().supportUploadReu()) {
SharableCollectorManager.getInstance().execute();
ClipboardFilter.registerClipboardHandler(EncryptSelectionClipboardHandler.getInstance());
ClipboardFilter.registerClipboardHandler(EncryptTransferableClipboardHandler.getInstance());
registerSharableEncryptDefinePanes();
}
listenEnv();
ClipboardFilter.registerClipboardHandler(EncryptSelectionClipboardHandler.getInstance());
ClipboardFilter.registerClipboardHandler(EncryptTransferableClipboardHandler.getInstance());
registerSharableEncryptDefinePanes();
}
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();
}
});
DesignerLaunchStatus.setStatus(DesignerLaunchStatus.STARTUP_COMPLETE);
DesignerLaunchStatus.setStatusAndAsyncFire(DesignerLaunchStatus.STARTUP_COMPLETE);
}
});
});

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

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

@ -1,11 +1,13 @@
package com.fr.start;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.bbs.BBSConstants;
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.locale.image.I18nImage;
import com.fr.module.ModuleEvent;
@ -28,13 +30,13 @@ public class SplashContext {
public static final String SPLASH_PATH = getSplashPath();
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 String THANKS = Toolkit.i18nText("Fine-Design_Report_Thanks_To");
private String THANKS = StringUtils.EMPTY;
private static final SplashContext SPLASH_CONTEXT = new SplashContext();
private SplashStrategy splashStrategy;
private String moduleId = Toolkit.i18nText("Fine-Design_Basic_Initializing");
private String moduleId = StringUtils.EMPTY;
private int loadingIndex = 0;
private String[] loading = new String[]{"..", "....", "......"};
@ -73,7 +75,12 @@ public class SplashContext {
public void 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() {
THANKS = Toolkit.i18nText("Fine-Design_Report_Thanks_To");
moduleId = Toolkit.i18nText("Fine-Design_Basic_Initializing");
scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {

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

@ -546,6 +546,7 @@ public class DesignerActivator extends Activator implements Prepare {
EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener<Null>() {
@Override
public void on(Event event, Null param) {
FineLoggerFactory.reset();
new SwingWorker<Void, Void>() {
@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.RestartHelper;
import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.file.TemplateResourceManager;
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.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.module.Activator;
import com.fr.start.common.DesignerStartupPool;
/**
* Created by juhaoyu on 2018/1/8.
@ -17,7 +23,8 @@ public class PreStartActivator extends Activator {
@Override
public void start() {
//清空临时文件
TmpFileUtils.cleanUpInnerTmpFiles();
Runtime.getRuntime().addShutdownHook(new Thread(TmpFileUtils::cleanUpInnerTmpFiles));
RestartHelper.deleteRecordFilesWhenStart();
//初始化起始画面放到 SplashContext 里面
//EventDispatcher.fire(ModuleEvent.MajorModuleStarting, Toolkit.i18nText("Fine-Design_Basic_Initializing"));

Loading…
Cancel
Save