Browse Source
* commit '1c70ee19f38e12f574189aa0a3d7effabbd5ca47': REPORT-17988 设计器启动速度--本机大概从 14.2s -> 10.2 1、basic并行 2、new Designer和env、core并行,但是和showDesigner串行 3、去掉读模板时候的进度条(待讨论,总共快了1s左右不过启动动画的时间长了,客户感受不确定)research/10.0
ju
6 years ago
7 changed files with 196 additions and 133 deletions
@ -0,0 +1,24 @@
|
||||
package com.fr.start; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2019-06-14. |
||||
* 设计器上下文 |
||||
*/ |
||||
public class DesignerInitial { |
||||
|
||||
private static volatile Designer designer; |
||||
|
||||
public synchronized static void init(String... args) { |
||||
|
||||
designer = new Designer(args); |
||||
} |
||||
|
||||
public synchronized static void show() { |
||||
|
||||
if (designer != null) { |
||||
designer.show(); |
||||
} |
||||
//启动画面结束
|
||||
SplashContext.getInstance().hide(); |
||||
} |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.fr.start.module; |
||||
|
||||
import com.fr.module.Activator; |
||||
import com.fr.start.DesignerInitial; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2019-06-14. |
||||
*/ |
||||
public class DesignerInitActivator extends Activator { |
||||
|
||||
@Override |
||||
public void start() { |
||||
|
||||
DesignerInitial.init(upFindSingleton(StartupArgs.class).get()); |
||||
} |
||||
|
||||
@Override |
||||
public void stop() { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,21 @@
|
||||
package com.fr.start.module; |
||||
|
||||
import com.fr.module.Activator; |
||||
import com.fr.start.DesignerInitial; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2019-06-14. |
||||
*/ |
||||
public class DesignerShowActivator extends Activator { |
||||
|
||||
@Override |
||||
public void start() { |
||||
|
||||
DesignerInitial.show(); |
||||
} |
||||
|
||||
@Override |
||||
public void stop() { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,94 @@
|
||||
package com.fr.start.module; |
||||
|
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.event.Event; |
||||
import com.fr.event.Listener; |
||||
import com.fr.module.Activator; |
||||
import com.fr.start.server.FineEmbedServer; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.Workspace; |
||||
import com.fr.workspace.WorkspaceEvent; |
||||
|
||||
import java.util.concurrent.ExecutorService; |
||||
import java.util.concurrent.Executors; |
||||
|
||||
/** |
||||
* Created by juhaoyu on 2019-06-14. |
||||
*/ |
||||
public class DesignerWorkspaceActivator extends Activator { |
||||
|
||||
@Override |
||||
public void start() { |
||||
|
||||
registerEnvListener(); |
||||
startServer(WorkContext.getCurrent()); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 注册切换环境前后事件监听 |
||||
*/ |
||||
private void registerEnvListener() { |
||||
|
||||
/*切换环境前,关闭所有相关模块,最后执行*/ |
||||
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>(Integer.MIN_VALUE) { |
||||
|
||||
@Override |
||||
public void on(Event event, Workspace current) { |
||||
|
||||
getSub(EnvBasedModule.class).stop(); |
||||
} |
||||
}); |
||||
/*切换环境后,重新启动所有相关模块,最先执行*/ |
||||
listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>(Integer.MAX_VALUE) { |
||||
|
||||
@Override |
||||
public void on(Event event, Workspace current) { |
||||
|
||||
getSub(EnvBasedModule.class).start(); |
||||
startServer(current); |
||||
} |
||||
}); |
||||
/*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ |
||||
listenEvent(WorkspaceEvent.BeforeSwitch, new Listener<Workspace>(Integer.MAX_VALUE) { |
||||
|
||||
@Override |
||||
public void on(Event event, Workspace workspace) { |
||||
|
||||
HistoryTemplateListCache.getInstance().stash(); |
||||
} |
||||
}); |
||||
|
||||
/*切换环境后,装载一下打开的所有文件对象,优先级低于默认优先级,要后于 启动相关模块部分 被触发*/ |
||||
listenEvent(WorkspaceEvent.AfterSwitch, new Listener<Workspace>(Integer.MIN_VALUE) { |
||||
|
||||
@Override |
||||
public void on(Event event, Workspace workspace) { |
||||
|
||||
HistoryTemplateListCache.getInstance().load(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void startServer(Workspace current) { |
||||
|
||||
// 切换后的环境是本地环境才启动内置服务器
|
||||
if (current.isLocal()) { |
||||
ExecutorService service = Executors.newSingleThreadExecutor(); |
||||
service.submit(new Runnable() { |
||||
|
||||
@Override |
||||
public void run() { |
||||
|
||||
FineEmbedServer.start(); |
||||
} |
||||
}); |
||||
service.shutdown(); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void stop() { |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue