From 1095b7b2baa4b19921d5d1346423aaddfb5f3778 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Tue, 28 May 2024 16:33:34 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-114391=20=E3=80=90=E5=BE=AE=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E9=80=82=E9=85=8D=E3=80=91=E8=BF=9C=E7=A8=8B&?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=AE=BE=E8=AE=A1=E5=99=A8=E8=83=BD=E5=A4=9F?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 3 + .../com/fr/design/env/RemoteWorkspace.java | 21 +- .../com/fr/design/extra/LoginWebBridge.java | 6 +- .../com/fr/design/extra/PluginHelper.java | 63 ++++ .../com/fr/design/extra/PluginWebBridge.java | 3 +- .../com/fr/design/extra/WebViewDlgHelper.java | 14 +- .../fr/design/formula/FunctionConstants.java | 6 +- .../fr/design/gui/date/UICalendarPanel.java | 2 +- .../share/collect/ComponentCollector.java | 3 +- .../update/ui/dialog/UpdateMainDialog.java | 1 + .../java/com/fr/design/upm/UpmFinder.java | 22 +- .../fr/env/detect/ui/EnvDetectorDialog.java | 2 - .../com/fr/start/server/FineEmbedServer.java | 21 +- .../server/FineEmbedServerActivator.java | 4 +- .../chart/map/designer/type/GisLayerPane.java | 112 ++++--- .../generate/task/ComponentUploader.java | 5 +- .../boot/DesignConfConfigComponent.java | 38 +++ .../boot/DesignCoreSupplementalComponent.java | 46 +++ .../com/fanruan/boot/DesignEnvComponent.java | 19 ++ .../fanruan/boot/DesignFunctionComponent.java | 23 ++ .../fanruan/boot/DesignLoggerComponent.java | 38 +++ .../boot/DesignSerializationComponent.java | 24 ++ .../fanruan/boot/DesignTenantComponent.java | 51 +++ .../fanruan/boot/DesignUpdateComponent.java | 19 ++ .../boot/DesignWorkContextComponent.java | 99 ++++++ .../boot/DesignWorkspaceComponent.java | 21 ++ .../DesignWorkspaceRegisterComponent.java | 19 ++ .../com/fanruan/boot/DesignerComponent.java | 24 ++ .../fanruan/boot/DesignerDaoComponent.java | 38 +++ .../fanruan/boot/DesignerInitComponent.java | 28 ++ .../fanruan/boot/DesignerShowComponent.java | 43 +++ .../boot/DesignerStartupComponent.java | 194 ++++++++++++ .../com/fanruan/boot/PreLoadComponent.java | 118 +++++++ .../com/fanruan/boot/XMLableComponent.java | 23 ++ .../boot/key/ActivatorContextGroup.java | 14 + .../fanruan/boot/key/StartupArgsShell.java | 14 + .../fr/design/present/CurrencyLinePane.java | 2 +- .../EditReportServerParameterPane.java | 3 +- .../java/com/fr/start/CarinaDesigner.java | 83 +++++ .../main/java/com/fr/start/DesignContext.java | 42 +++ .../java/com/fr/start/DesignLauncher.java | 88 ++++++ .../com/fr/start/EmptyServletContext.java | 290 ++++++++++++++++++ .../main/java/com/fr/start/MainDesigner.java | 4 +- .../fr/start/module/DesignerActivator.java | 22 +- .../start/module/DesignerInitActivator.java | 17 +- .../com/fr/start/module/DesignerStartup.java | 2 +- .../module/DesignerWorkspaceActivator.java | 186 ++++++++--- .../module/DesignerWorkspaceProvider.java | 8 +- .../optimized/DesignerPluginActivator.java | 9 +- .../DesignerStartupPageActivator.java | 21 +- .../optimized/TenantDBAdapter4Designer.java | 5 + .../start/util/DesignerStartupPageUtil.java | 19 +- 52 files changed, 1806 insertions(+), 176 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/extra/PluginHelper.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignConfConfigComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignCoreSupplementalComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignEnvComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignFunctionComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignLoggerComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignSerializationComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignTenantComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignUpdateComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignWorkContextComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignWorkspaceComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignWorkspaceRegisterComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignerComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignerDaoComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignerInitComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignerShowComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/DesignerStartupComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/PreLoadComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/XMLableComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/key/ActivatorContextGroup.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/key/StartupArgsShell.java create mode 100644 designer-realize/src/main/java/com/fr/start/CarinaDesigner.java create mode 100644 designer-realize/src/main/java/com/fr/start/DesignContext.java create mode 100644 designer-realize/src/main/java/com/fr/start/DesignLauncher.java create mode 100644 designer-realize/src/main/java/com/fr/start/EmptyServletContext.java diff --git a/build.gradle b/build.gradle index c0142b54d4..56018d25e5 100644 --- a/build.gradle +++ b/build.gradle @@ -67,6 +67,9 @@ allprojects { implementation 'com.fr.plugin:fine-plugin-api:' + apiVersion implementation 'com.fr.workplace:workplace-api:' + apiVersion implementation 'com.fr.carina:fine-carina:' + apiVersion + implementation 'com.fr.auth:fine-auth-api:' + apiVersion + implementation 'com.fr.license:fine-license-api:' + apiVersion + implementation 'com.fr.workplace:workplace:' + apiVersion implementation 'com.fr.cluster:fine-cluster-api:' + apiVersion implementation 'com.install4j:install4j-runtime:8.0.4' implementation 'com.fr.third:jxbrowser:6.23' diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index 24b79e418c..6619c11c11 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -1,6 +1,6 @@ package com.fr.design.env; -import com.fr.cluster.engine.rpc.remote.ClusterOperator; +import com.fanruan.workplace.http.HttpWorkspaceProxyPool; import com.fr.design.i18n.Toolkit; import com.fr.base.operator.common.CommonOperator; import com.fr.rpc.ExceptionHandler; @@ -12,7 +12,6 @@ import com.fr.workspace.connect.WorkspaceClient; import com.fr.workspace.connect.WorkspaceConnection; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.server.authority.decision.DecisionOperator; -import com.fr.workspace.engine.rpc.WorkspaceProxyPool; import com.fr.workspace.pool.WorkObjectPool; import javax.swing.SwingWorker; @@ -96,15 +95,8 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isCluster() { - if (cluster == null) { - cluster = WorkContext.getCurrent().get(ClusterOperator.class, new ExceptionHandler() { - @Override - public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { - return false; - } - }).isCluster(); - } - return cluster; + // 集群判断方式放到远程那边一起改 + return false; } @Override @@ -114,17 +106,20 @@ public class RemoteWorkspace implements Workspace { } @Override + @Deprecated public T get(Class type) { return client.getPool().get(type); } @Override + @Deprecated public T get(Class type, ExceptionHandler exceptionHandler){ if(exceptionHandler != null) { WorkObjectPool objectPool = client.getPool(); - if (objectPool instanceof WorkspaceProxyPool) { - return ((WorkspaceProxyPool) objectPool).get(type, exceptionHandler); + // 不再建议这样用啦,这里只是为了保留一定的兼容能力,直接用类似于TemplateRepository.getInstance().xxx()的方式吧 + if (objectPool instanceof HttpWorkspaceProxyPool) { + return objectPool.get(type, exceptionHandler); }else { return client.getPool().get(type); } diff --git a/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java b/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java index 0ec65001c9..7892d5ce78 100644 --- a/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java +++ b/designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java @@ -1,7 +1,7 @@ package com.fr.design.extra; +import com.fanruan.cloud.FanruanCloud; import com.fr.concurrent.NamedThreadFactory; -import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.UIDialog; import com.fr.design.extra.exe.PluginLoginExecutor; @@ -82,7 +82,7 @@ public class LoginWebBridge { */ public void setMessageCount(int count) { if (count == MIN_MESSAGE_COUNT) { - MarketConfig.getInstance().setInShowBBsName(DesignerEnvManager.getEnvManager().getDesignerLoginUsername()); + FanruanCloud.marketService().setInShowBBsName(DesignerEnvManager.getEnvManager().getDesignerLoginUsername()); return; } this.messageCount = count; @@ -90,7 +90,7 @@ public class LoginWebBridge { sb.append(StringUtils.BLANK).append(DesignerEnvManager.getEnvManager().getDesignerLoginUsername()) .append("(").append(this.messageCount) .append(")").append(StringUtils.BLANK); - MarketConfig.getInstance().setInShowBBsName(sb.toString()); + FanruanCloud.marketService().setInShowBBsName(sb.toString()); } public void setQQDialog(UIDialog qqDialog) { diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginHelper.java b/designer-base/src/main/java/com/fr/design/extra/PluginHelper.java new file mode 100644 index 0000000000..8a96ae97a0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/PluginHelper.java @@ -0,0 +1,63 @@ +package com.fr.design.extra; + + +import com.fanruan.carina.Carina; +import com.fanruan.plugin.design.loader.PluginResourceLoaderSingletonShell; +import com.fanruan.plugin.design.loader.UPMResourceLoaderSingletonShell; +import com.fanruan.plugin.design.store.PluginStoreProvider; +import com.fanruan.plugin.design.store.PluginStoreSingletonShell; +import com.fr.decision.webservice.v10.plugin.helper.category.ResourceLoader; + +import java.util.List; + +/** + * 用于设计器调用插件内部资源 + *

对应的资源需要提前注册进环境里

+ * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/14 + */ +public class PluginHelper { + private PluginStoreProvider storeProvider; + private ResourceLoader upmLoader; + private ResourceLoader pluginLoader; + private static final PluginHelper INSTANCE = new PluginHelper(); + + private PluginHelper() { + storeProvider = Carina.getApplicationContext().singleton(PluginStoreSingletonShell.class).get(); + upmLoader = Carina.getApplicationContext().singleton(UPMResourceLoaderSingletonShell.class).get(); + pluginLoader = Carina.getApplicationContext().singleton(PluginResourceLoaderSingletonShell.class).get(); + } + + /** + * 获取插件helper单例 + */ + public static PluginHelper getInstance() { + return INSTANCE; + } + + public PluginStoreProvider getStoreProvider() { + return storeProvider; + } + + public void setStoreProvider(PluginStoreProvider storeProvider) { + this.storeProvider = storeProvider; + } + + public ResourceLoader getUpmLoader() { + return upmLoader; + } + + public void setUpmLoader(ResourceLoader upmLoader) { + this.upmLoader = upmLoader; + } + + public ResourceLoader getPluginLoader() { + return pluginLoader; + } + + public void setPluginLoader(ResourceLoader pluginLoader) { + this.pluginLoader = pluginLoader; + } +} diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java b/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java index f455686415..1ba6194127 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java @@ -1,5 +1,6 @@ package com.fr.design.extra; +import com.fanruan.cloud.FanruanCloud; import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; @@ -548,7 +549,7 @@ public class PluginWebBridge { * 清除用户信息 */ public void clearUserInfo() { - MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); + FanruanCloud.marketService().setInShowBBsName(StringUtils.EMPTY); } public void getPackInfo(final JSObject callback){ diff --git a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java index 97e99f22b3..6a015bebbf 100644 --- a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java @@ -14,8 +14,6 @@ import com.fr.general.IOUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; -import com.fr.plugin.PluginStoreConfig; -import com.fr.plugin.PluginStoreConstants; import com.fr.stable.CommonUtils; import com.fr.stable.EnvChangedListener; import com.fanruan.product.ProductConstants; @@ -43,14 +41,14 @@ public class WebViewDlgHelper { private static final String LATEST = "latest"; private static final String SHOP_SCRIPTS = "shop_scripts"; private static final int VERSION_8 = 8; - private static String installHome = PluginStoreConstants.getLocalInstallHome(); + private static String installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome(); private static final String MAIN_JS_PATH = "/scripts/plugin.html"; static { GeneralContext.addEnvChangedListener(new EnvChangedListener() { @Override public void envChanged() { - installHome = PluginStoreConstants.getLocalInstallHome(); + installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome(); } }); } @@ -73,9 +71,9 @@ public class WebViewDlgHelper { return; } // 检测更新前先刷新一下版本号 - PluginStoreConstants.refreshProps(); + PluginHelper.getInstance().getStoreProvider().refreshProps(); - String jarVersion = PluginStoreConfig.getInstance().getEnvVersion(); + String jarVersion = PluginHelper.getInstance().getStoreProvider().getEnvVersion(); if (ComparatorUtils.equals(jarVersion, ProductConstants.VERSION)) { updateShopScripts(SHOP_SCRIPTS); showPluginDlg(); @@ -264,7 +262,7 @@ public class WebViewDlgHelper { IOUtils.unzip(scriptZip, installHome); CommonUtils.deleteFile(scriptZip); } - PluginStoreConstants.refreshProps(); // 下载完刷新一下版本号等 + PluginHelper.getInstance().getStoreProvider().refreshProps(); // 下载完刷新一下版本号等 FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), JOptionPane.INFORMATION_MESSAGE); } } catch (InterruptedException e) { @@ -284,7 +282,7 @@ public class WebViewDlgHelper { protected Void doInBackground() throws Exception { String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update"); if (url != null) { - String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConfig.getInstance().getVersion()); + String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginHelper.getInstance().getStoreProvider().getVersion()); JSONObject resultJSONObject = new JSONObject(text); String isLatest = resultJSONObject.optString("result"); if (!ComparatorUtils.equals(isLatest, LATEST)) { diff --git a/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java b/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java index 6a1b32aaa3..ef3bf5ea56 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java +++ b/designer-base/src/main/java/com/fr/design/formula/FunctionConstants.java @@ -23,12 +23,15 @@ import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; import com.fr.plugin.ExtraClassManager; +import com.fr.plugin.injectable.PluginModule; import com.fr.stable.EncodeConstants; import com.fr.stable.OperatingSystem; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.fun.FunctionDefContainer; import com.fr.stable.fun.mark.Mutable; +import com.fr.stable.plugin.ExtraClassManagerProvider; +import com.fr.stable.script.ExtraFunctionManager; import com.fr.stable.script.Function; import com.fr.stable.script.FunctionDef; @@ -243,7 +246,8 @@ public final class FunctionConstants { @Override public NameAndDescription[] getDescriptions() { - FunctionDef[] fs = ExtraClassManager.getInstance().getFunctionDef(); + ExtraClassManagerProvider pluginProvider = PluginModule.getAgent(PluginModule.ExtraCore); + FunctionDef[] fs = pluginProvider.autonomy(ExtraFunctionManager.class).getFunctionDef(); int count = fs.length; FunctionDefNAD[] nads = new FunctionDefNAD[count]; for (int i = 0; i < count; i ++) { diff --git a/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java b/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java index fb21021179..3d754ba0ac 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java +++ b/designer-base/src/main/java/com/fr/design/gui/date/UICalendarPanel.java @@ -1,5 +1,6 @@ package com.fr.design.gui.date; +import com.fanruan.product.ProductConstantsBase; import com.fr.base.BaseUtils; import com.fr.base.background.GradientBackground; import com.fr.design.carton.MonthlyCartonFile; @@ -13,7 +14,6 @@ import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.general.GeneralUtils; import com.fr.stable.Constants; -import com.fr.stable.ProductConstantsBase; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java index cd2e3531b6..4382649052 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.share.collect; +import com.fanruan.cloud.FanruanCloud; import com.fr.base.io.XMLReadHelper; import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; @@ -529,7 +530,7 @@ public class ComponentCollector implements XMLable { public String generateTotalInfo() { collectCmpNumber(); JSONObject jo = JSONObject.create(); - jo.put("userId", MarketConfig.getInstance().getBBSAttr().getBbsUid()); + jo.put("userId", FanruanCloud.marketService().getBbsUid()); jo.put("uuid", uuid); jo.put("cmpBoardClickDaily", cmpBoardClickDaily()); jo.put("pluginVersion", GeneralUtils.getVersion()); diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index 033e2cb07f..6bad24c514 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -1,5 +1,6 @@ package com.fr.design.update.ui.dialog; +import com.fanruan.product.ProductConstants; import com.fr.decision.update.data.UpdateConstants; import com.fr.decision.update.info.UpdateCallBack; import com.fr.decision.update.info.UpdateProgressCallBack; diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index 576c5a9b96..9cff7ae603 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -1,9 +1,8 @@ package com.fr.design.upm; -import com.fr.decision.webservice.v10.plugin.helper.category.impl.BaseResourceLoader; -import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; +import com.fr.design.extra.PluginHelper; import com.fr.design.i18n.Toolkit; import com.fr.design.login.utils.DesignerLoginUtils; import com.fr.design.mainframe.DesignerContext; @@ -16,8 +15,10 @@ import com.fr.general.CommonIOUtils; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; -import com.fr.plugin.PluginStoreConstants; +import com.fr.stable.CommonUtils; import com.fr.stable.StableUtils; +import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; @@ -35,8 +36,9 @@ public class UpmFinder { private static final String UPM_DIR = "/upm"; private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html"; private static final String JXBROWSER = "com.teamdev.jxbrowser.browser.Browser"; - - public static String installHome = PluginStoreConstants.getLocalInstallHome(); + public static final String TEMP_FILE = "cache/temp.zip"; + public static final String SCRIPT_DOWNLOAD_PATH = CommonUtils.pathJoin(WorkContext.getCurrent().getPath(), TEMP_FILE); + public static String installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome(); private static UIDialog dialog = null; @@ -44,8 +46,8 @@ public class UpmFinder { EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { @Override public void on(Event event, Workspace param) { - installHome = PluginStoreConstants.getLocalInstallHome(); - UpmResourceLoader.INSTANCE.checkOldShopFile(); + installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome(); + PluginHelper.getInstance().getUpmLoader().checkOldShopFile(); } }); } @@ -85,7 +87,7 @@ public class UpmFinder { Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (val == JOptionPane.OK_OPTION) { try { - UpmResourceLoader.INSTANCE.download(); + PluginHelper.getInstance().getUpmLoader().download(); installUpmResource(); FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Shop_Installed"), @@ -107,8 +109,8 @@ public class UpmFinder { } private static void installUpmResource() { - String installHome = PluginStoreConstants.getLocalInstallHome(); - File scriptZip = new File(BaseResourceLoader.SCRIPT_DOWNLOAD_PATH); + String installHome = PluginHelper.getInstance().getStoreProvider().getLocalInstallHome(); + File scriptZip = new File(SCRIPT_DOWNLOAD_PATH); if (scriptZip.exists()) { IOUtils.unzip(scriptZip, installHome); CommonIOUtils.deleteFile(scriptZip); diff --git a/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java b/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java index 48dfecd7b3..da631cfdb8 100644 --- a/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java +++ b/designer-base/src/main/java/com/fr/env/detect/ui/EnvDetectorDialog.java @@ -25,8 +25,6 @@ import com.fr.env.detect.bean.DetectorStatus; import com.fr.env.detect.bean.DetectorType; import com.fr.log.FineLoggerFactory; import com.fr.design.carton.FeedbackToolboxDialog; -import com.fr.stable.ProductConstantsBase; -import com.fr.stable.StableUtils; import org.jetbrains.annotations.NotNull; import javax.swing.BorderFactory; diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServer.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServer.java index e70804c4dc..efc2ebd594 100644 --- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServer.java +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServer.java @@ -14,23 +14,24 @@ public abstract class FineEmbedServer { private static volatile boolean onStarting = false; public synchronized static void start() { - onStarting = true; - EventDispatcher.fire(EmbedServerEvent.BeforeStart); - ModuleContext.getModule(FineEmbedServerActivator.class).start(); - onStarting = false; - EventDispatcher.fire(EmbedServerEvent.AfterStart); + // // 内置服务器先去除 + // onStarting = true; + // EventDispatcher.fire(EmbedServerEvent.BeforeStart); + // ModuleContext.getModule(FineEmbedServerActivator.class).start(); + // onStarting = false; + // EventDispatcher.fire(EmbedServerEvent.AfterStart); } public synchronized static void stop() { - - EventDispatcher.fire(EmbedServerEvent.BeforeStop); - ModuleContext.getModule(FineEmbedServerActivator.class).stop(); - EventDispatcher.fire(EmbedServerEvent.AfterStop); + // //内置服务器先去除 + // EventDispatcher.fire(EmbedServerEvent.BeforeStop); + // ModuleContext.getModule(FineEmbedServerActivator.class).stop(); + // EventDispatcher.fire(EmbedServerEvent.AfterStop); } public static boolean isRunning() { - return ModuleContext.getModule(FineEmbedServerActivator.class).isRunning(); + return false; } public static boolean isOnStarting() { diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java index 24946dec0b..1ad9d8af1a 100644 --- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java @@ -11,7 +11,6 @@ import com.fr.startup.FineWebApplicationInitializer; import com.fr.third.guava.collect.Sets; import com.fr.third.springframework.web.SpringServletContainerInitializer; import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import com.fr.web.socketio.WebSocketEndpoint; import com.fr.workspace.WorkContext; import org.apache.catalina.Context; import org.apache.catalina.LifecycleException; @@ -95,7 +94,8 @@ public class FineEmbedServerActivator extends Activator { Set> classes = new HashSet>(); classes.add(FineWebApplicationInitializer.class); context.addServletContainerInitializer(initializer, classes); - context.addServletContainerInitializer(new WsSci(), Sets.newHashSet(WebSocketEndpoint.class)); + // 后面本地设计的内置服务器考虑用XST + // context.addServletContainerInitializer(new WsSci(), Sets.newHashSet(WebSocketEndpoint.class)); } // tomcat的maxPostSize会影响到post参数获取,默认2M diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java index 43a770beae..37f178e196 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/GisLayerPane.java @@ -3,14 +3,17 @@ package com.fr.van.chart.map.designer.type; import com.fr.base.Utils; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.chart.mode.ChartEditContext; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; import com.fr.plugin.chart.base.GisLayer; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.server.MapLayerConfigManager; @@ -29,6 +32,7 @@ import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.event.ItemEvent; +import java.util.Locale; /** * @author Bjorn @@ -39,8 +43,16 @@ public class GisLayerPane extends JPanel implements UIObserver { private UIButtonGroup gisButton; private JPanel layerPaneCheckPane; - private UIComboBox gisGaoDeLayer; - private UIComboBox gisLayer; + + /** + * 标准图层 + */ + private UIComboBox standardLayers; + + /** + * 自定义图层 + */ + private UIComboBox customLayers; private JPanel layerCardPane; private WMSLayerPane wmsLayerPane; @@ -48,7 +60,7 @@ public class GisLayerPane extends JPanel implements UIObserver { private UIComboBox zoomLevel; - private String[] layers = MapLayerConfigManager.getLayerItems(); + private String[] layers = MapLayerConfigManager.getCustomLayerItems(); public GisLayerPane() { initComps(); @@ -86,15 +98,12 @@ public class GisLayerPane extends JPanel implements UIObserver { gisButton = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), Toolkit.i18nText("Fine-Design_Form_Widget_Style_Standard"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); gisButton.setSelectedIndex(ChartEditContext.supportTheme() ? 0 : 1); - gisGaoDeLayer = new UIComboBox(MapLayerConfigManager.getGaoDeLayerItems()); gisButton.addActionListener(event -> { refreshZoomLevel(); checkLayerCardPane(); }); - gisGaoDeLayer.addItemListener(event -> refreshZoomLevel()); - - initCustomGISLayerPane(); + initLayer(); initLayerCardPane(); layerPaneCheckPane = new JPanel(new CardLayout()) { @@ -104,15 +113,15 @@ public class GisLayerPane extends JPanel implements UIObserver { return new Dimension(0, 0); } if (isStandardGis()) { - return gisGaoDeLayer.getPreferredSize(); + return standardLayers.getPreferredSize(); } else { - return gisLayer.getPreferredSize(); + return customLayers.getPreferredSize(); } } }; layerPaneCheckPane.add(new JPanel(), "auto"); - layerPaneCheckPane.add(gisGaoDeLayer, "standard"); - layerPaneCheckPane.add(gisLayer, "custom"); + layerPaneCheckPane.add(standardLayers, "standard"); + layerPaneCheckPane.add(customLayers, "custom"); double p = TableLayout.PREFERRED; @@ -142,7 +151,7 @@ public class GisLayerPane extends JPanel implements UIObserver { if (isStandardGis() || isAuto()) { return new Dimension(0, 0); } - String itemName = Utils.objectToString(gisLayer.getSelectedItem()); + String itemName = Utils.objectToString(customLayers.getSelectedItem()); if (MapLayerConfigManager.isCustomLayer(itemName)) { return tileLayerPane.getPreferredSize(); } else if (MapLayerConfigManager.isCustomWmsLayer(itemName)) { @@ -163,10 +172,12 @@ public class GisLayerPane extends JPanel implements UIObserver { } } - private void initCustomGISLayerPane() { - gisLayer = new UIComboBox(layers); + private void initLayer() { + standardLayers = new UIComboBox(MapLayerConfigManager.getStandardLayerItems()); + customLayers = new UIComboBox(layers); - gisLayer.addItemListener(e -> + standardLayers.addItemListener(event -> refreshZoomLevel()); + customLayers.addItemListener(e -> { if (e.getStateChange() == ItemEvent.SELECTED) { checkCustomLayerCardPane(); @@ -175,7 +186,7 @@ public class GisLayerPane extends JPanel implements UIObserver { } ); - gisLayer.addPopupMenuListener(new PopupMenuListener() { + customLayers.addPopupMenuListener(new PopupMenuListener() { public void popupMenuCanceled(PopupMenuEvent e) { } @@ -184,12 +195,12 @@ public class GisLayerPane extends JPanel implements UIObserver { public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - String selected = Utils.objectToString(gisLayer.getSelectedItem()); + String selected = Utils.objectToString(customLayers.getSelectedItem()); ZoomLevel zoomSelected = (ZoomLevel) zoomLevel.getSelectedItem(); - gisLayer.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getLayerItems())); + customLayers.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getCustomLayerItems())); - gisLayer.setSelectedItem(selected); + customLayers.setSelectedItem(selected); zoomLevel.setSelectedItem(zoomSelected); } }); @@ -201,15 +212,15 @@ public class GisLayerPane extends JPanel implements UIObserver { if (isAuto()) { levels = MapStatusPane.ZOOM_LEVELS; } else if (isStandardGis()) { - if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { + if (standardLayers.getSelectedIndex() == standardLayers.getItemCount() - 1) { levels = MapStatusPane.ZOOM_LEVELS; } else { levels = MapStatusPane.GAODE_ZOOM_LEVELS; } } else { - if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_Blue"))) { + if (ComparatorUtils.equals(customLayers.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_Blue"))) { levels = MapStatusPane.BLUE_ZOOM_LEVELS; - } else if (ComparatorUtils.equals(gisLayer.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_GaoDe"))) { + } else if (ComparatorUtils.equals(customLayers.getSelectedItem(), Toolkit.i18nText("Fine-Design_Chart_Layer_GaoDe"))) { levels = MapStatusPane.GAODE_ZOOM_LEVELS; } else { levels = MapStatusPane.ZOOM_LEVELS; @@ -233,31 +244,24 @@ public class GisLayerPane extends JPanel implements UIObserver { private void checkCustomLayerCardPane() { CardLayout cardLayout = (CardLayout) layerCardPane.getLayout(); - cardLayout.show(layerCardPane, Utils.objectToString(gisLayer.getSelectedItem())); + cardLayout.show(layerCardPane, Utils.objectToString(customLayers.getSelectedItem())); } public void resetGisLayer(VanChartMapPlot mapPlot) { - -// if (ChartEditContext.supportTheme()) { - GisLayer defaultGisLayer = mapPlot.getDefaultGisLayer(); - mapPlot.setGisLayer(defaultGisLayer); - populate(defaultGisLayer); -// } else { -// GaoDeGisType gaoDeGisType = mapPlot.getDefaultGisLayerType(); -// -// mapPlot.getGisLayer().setGisLayerType(GISLayerType.GAO_DE_API); -// mapPlot.getGisLayer().setLayerName(gaoDeGisType.getTypeName()); -// mapPlot.getGisLayer().setGaoDeGisType(gaoDeGisType); -// populate(mapPlot.getGisLayer()); -// } + GisLayer defaultGisLayer = mapPlot.getDefaultGisLayer(); + mapPlot.setGisLayer(defaultGisLayer); + populate(defaultGisLayer); } public void populate(GisLayer layer) { switch (layer.getGisLayerType()) { case AUTO: gisButton.setSelectedIndex(0); + layer.setGisLayerType(GISLayerType.AUTO); + layer.setLayerName(GISLayerType.getLocString(GISLayerType.AUTO)); break; case GAO_DE_API: + populateStandardGis(layer); case LAYER_NULL: populateStandardGis(layer); break; @@ -272,16 +276,22 @@ public class GisLayerPane extends JPanel implements UIObserver { private void populateStandardGis(GisLayer layer) { gisButton.setSelectedIndex(1); + String layerName = layer.getLayerName(); if (layer.getGisLayerType() == GISLayerType.LAYER_NULL) { - gisGaoDeLayer.setSelectedIndex(gisGaoDeLayer.getItemCount() - 1); + standardLayers.setSelectedIndex(standardLayers.getItemCount() - 1); } else { - gisGaoDeLayer.setSelectedItem(layer.getGaoDeGisType().getTypeName()); + if (Locale.CHINA.equals(GeneralContext.getLocale())) { + standardLayers.setSelectedItem(layerName); + layer.setGaoDeGisType(GaoDeGisType.parseByLocaleName(layerName)); + } else { + standardLayers.setSelectedItem(layerName); + } } } private void populateCustomGis(GisLayer layer) { gisButton.setSelectedIndex(2); - gisLayer.setSelectedItem(layer.getShowItemName()); + customLayers.setSelectedItem(layer.getShowItemName()); switch (layer.getGisLayerType()) { case CUSTOM_WMS_LAYER: @@ -297,6 +307,7 @@ public class GisLayerPane extends JPanel implements UIObserver { if (isAuto()) { layer.setGisLayerType(GISLayerType.AUTO); layer.setLayerName(GISLayerType.getLocString(GISLayerType.AUTO)); + adaptEditingTemplateTheme(layer); } else if (isStandardGis()) { updateStandardGis(layer); } else { @@ -305,9 +316,9 @@ public class GisLayerPane extends JPanel implements UIObserver { } private void updateStandardGis(GisLayer layer) { - String layerName = Utils.objectToString(gisGaoDeLayer.getSelectedItem()); + String layerName = Utils.objectToString(standardLayers.getSelectedItem()); layer.setLayerName(layerName); - if (gisGaoDeLayer.getSelectedIndex() == gisGaoDeLayer.getItemCount() - 1) { + if (standardLayers.getSelectedIndex() == standardLayers.getItemCount() - 1) { layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); } else { layer.setGisLayerType(GISLayerType.GAO_DE_API); @@ -316,7 +327,7 @@ public class GisLayerPane extends JPanel implements UIObserver { } private void updateCustomGis(GisLayer layer) { - String layerName = Utils.objectToString(gisLayer.getSelectedItem()); + String layerName = Utils.objectToString(customLayers.getSelectedItem()); layer.setLayerName(layerName); layer.setGisLayerType(MapLayerConfigManager.getGisLayerType(layerName)); @@ -329,4 +340,21 @@ public class GisLayerPane extends JPanel implements UIObserver { break; } } + + /** + * 切换图层时根据主题切换图层名称 + * + * @param layer 图层 + */ + private void adaptEditingTemplateTheme(GisLayer layer) { + if (Locale.CHINA.equals(GeneralContext.getLocale())) { + return; + } + JTemplate currentEditingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (JTemplate.isValid(currentEditingTemplate)) { + boolean dark = currentEditingTemplate.getTemplateTheme().isDark(); + String name = dark ? Toolkit.i18nText("Fine-Design_Chart_Layer_Black") : Toolkit.i18nText("Fine-Design_Chart_Layer_MapBox"); + layer.setLayerName(name); + } + } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentUploader.java b/designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentUploader.java index 36014905ba..ec7e705add 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentUploader.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/generate/task/ComponentUploader.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.share.generate.task; +import com.fanruan.cloud.FanruanCloud; import com.fr.config.MarketConfig; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.share.config.ComponentReuseConfigManager; @@ -102,8 +103,8 @@ public class ComponentUploader implements ComponentBanner { private boolean login(CloseableHttpClient client) throws IOException { - String bbsUsername = MarketConfig.getInstance().getBbsUsername(); - String bbsPassword = MarketConfig.getInstance().getBbsPassword(); + String bbsUsername = FanruanCloud.marketService().getBbsUsername(); + String bbsPassword = FanruanCloud.marketService().getBbsPassword(); List pairs = new ArrayList<>(); pairs.add(new BasicNameValuePair(KEY_USERNAME, bbsUsername)); pairs.add(new BasicNameValuePair(KEY_PASSWORD, bbsPassword)); diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignConfConfigComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignConfConfigComponent.java new file mode 100644 index 0000000000..9df155744a --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignConfConfigComponent.java @@ -0,0 +1,38 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.JPAEntityScan; +import com.fanruan.carina.annotions.Start; +import com.fanruan.carina.annotions.Stop; + +/** + * 设计器Conf_config模块 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name = "design_conf_config") +@JPAEntityScan("com.fr.config.entity") +@DependsOn(dependencies = {"design_dao", "design_core_supplemental"}) +public class DesignConfConfigComponent extends ConfConfigComponent{ + + + /** + * start + */ + @Start + public void start() { + super.start(); + } + + + /** + * stop + */ + @Stop + public void stop() { + super.stop(); + } +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignCoreSupplementalComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignCoreSupplementalComponent.java new file mode 100644 index 0000000000..46724cf582 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignCoreSupplementalComponent.java @@ -0,0 +1,46 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.Start; +import com.fanruan.carina.annotions.Stop; +import com.fanruan.carina.annotions.Supplemental; + + +/** + * 设计器core_supplemental模块 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name = "design_core_supplemental") +@DependsOn(dependencies = {"env"}) +public class DesignCoreSupplementalComponent extends CoreSupplementalComponent{ + + + /** + * prepare + */ + @Supplemental + public void supplemental() { + super.supplemental(); + } + + + /** + * start + */ + @Start + public void start() { + super.start(); + } + + /** + * stop + */ + @Stop + public void stop() { + super.stop(); + } +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignEnvComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignEnvComponent.java new file mode 100644 index 0000000000..86f9c7cbb8 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignEnvComponent.java @@ -0,0 +1,19 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.ActivatorRefer; +import com.fanruan.carina.annotions.FineComponent; +import com.fr.env.EnvPrepare; +import com.fr.start.module.DesignerWorkspaceProvider; + +/** + * 设计器基础环境准备组件 + *

主要负责创建切换工作环境

+ * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name = "env") +@ActivatorRefer(refer = {DesignerWorkspaceProvider.class, EnvPrepare.class}) +public class DesignEnvComponent { +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignFunctionComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignFunctionComponent.java new file mode 100644 index 0000000000..3e83d1ddd7 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignFunctionComponent.java @@ -0,0 +1,23 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.ActivatorRefer; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fr.chart.activator.ChartBaseActivator; +import com.fr.form.module.FormBaseActivator; +import com.fr.report.module.ReportBaseActivator; +import com.fr.workspace.server.vcs.VcsFolderManagerActivator; + +/** + * 设计器基础功能组件 + *

主要是图表、report、vcs、form相关的基础初始化

+ * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/27 + */ +@FineComponent(name = "design_function") +@DependsOn(dependencies = {"design_core_supplemental", "design_dao", "design_conf_config", "design_update"}) +@ActivatorRefer(refer = {ChartBaseActivator.class, ReportBaseActivator.class, VcsFolderManagerActivator.class, FormBaseActivator.class}) +public class DesignFunctionComponent { +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignLoggerComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignLoggerComponent.java new file mode 100644 index 0000000000..875dab5c2d --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignLoggerComponent.java @@ -0,0 +1,38 @@ +package com.fanruan.boot; + + +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.Start; +import com.fanruan.carina.annotions.Stop; + + +/** + * 设计器日志模块 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name = "design_logger") +@DependsOn(dependencies = {"design_core_supplemental", "design_dao", "design_conf_config"}) +public class DesignLoggerComponent extends LoggerComponent{ + + + /** + * start + */ + @Start + public void start() { + super.start(); + } + + + /** + * stop + */ + @Stop + public void stop() { + super.stop(); + } +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignSerializationComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignSerializationComponent.java new file mode 100644 index 0000000000..d73d2f92f1 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignSerializationComponent.java @@ -0,0 +1,24 @@ +package com.fanruan.boot; + + +import com.fanruan.carina.annotions.ActivatorRefer; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; + +import com.fr.json.serialization.JsonSerializationActivator; + +import com.fr.serialization.SerializationActivator; + + +/** + * 设计器序列化模块初始化(通用+json) + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/24 + */ +@FineComponent(name = "design_serialization") +@DependsOn(dependencies = {"design_start_up", "class"}) +@ActivatorRefer(refer = {SerializationActivator.class, JsonSerializationActivator.class}) +public class DesignSerializationComponent { +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignTenantComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignTenantComponent.java new file mode 100644 index 0000000000..1f8c1d8f2e --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignTenantComponent.java @@ -0,0 +1,51 @@ +package com.fanruan.boot; + +import com.fanruan.carina.Carina; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.Start; +import com.fanruan.carina.annotions.Stop; +import com.fr.tenant.config.TenantConfigProvider; +import com.fr.tenant.context.PlatformScaffoldTenantStarter; +import com.fr.tenant.context.TenantContext; +import com.fr.tenant.context.provider.CurrentTenantKey; +import com.fr.tenant.store.impl.DefaultTenantStorage; + +import java.util.ArrayList; + +/** + * 设计器多租户模块 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/24 + */ +@FineComponent(name = "design_tenant") +@DependsOn(dependencies = {"design_start_up"}) +public class DesignTenantComponent { + + /** + * start + */ + @Start + public void start() { + TenantContext.registerStorage(new DefaultTenantStorage()); + TenantContext.registerConfigProvider(new TenantConfigProvider() { + @Override + public boolean isMultiTenantOpen() { + return false; + } + }); + PlatformScaffoldTenantStarter.start(new ArrayList<>(Carina.getApplicationContext().group(CurrentTenantKey.class).getAll())); + + } + + + /** + * stop + */ + @Stop + public void stop() { + PlatformScaffoldTenantStarter.stop(); + } +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignUpdateComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignUpdateComponent.java new file mode 100644 index 0000000000..7fbba69867 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignUpdateComponent.java @@ -0,0 +1,19 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.ActivatorRefer; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fr.start.module.optimized.DesignUpdateActivator; + +/** + * 设计器更新模块 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/27 + */ +@FineComponent(name = "design_update") +@ActivatorRefer(refer = DesignUpdateActivator.class) +@DependsOn(dependencies = {"design_core_supplemental", "design_dao", "design_conf_config", "design_plugin"}) +public class DesignUpdateComponent { +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignWorkContextComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignWorkContextComponent.java new file mode 100644 index 0000000000..191cb6262a --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignWorkContextComponent.java @@ -0,0 +1,99 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.Start; +import com.fanruan.carina.annotions.Stop; +import com.fanruan.carina.annotions.Supplemental; +import com.fanruan.workplace.standard.ServerInfo; +import com.fanruan.workplace.standard.ServerInfoOperator; +import com.fr.decision.service.context.ServiceContext; +import com.fr.log.FineLoggerFactory; +import com.fr.security.encryption.storage.StorageEncryptors; +import com.fr.security.encryption.storage.StorageTransfer; +import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; +import com.fr.workspace.base.WorkspaceAPI; +import com.fr.workspace.base.WorkspaceKey; +import com.fr.workspace.engine.FineWorkspaceFactory; +import com.fr.workspace.engine.base.FineObjectPool; +import com.fr.workspace.engine.client.FineWorkspaceConnector; +import com.fr.workspace.engine.client.heartbeart.FineWorkspaceHeartbeat; +import com.fr.workspace.engine.client.heartbeart.WorkspaceHeartbeat; +import com.fr.workspace.engine.resource.FineWorkResource; +import com.fr.workspace.engine.resource.FineWorkResourceAdaptor; +import com.fr.workspace.pool.WorkRPCRegister; +import com.fr.workspace.pool.WorkRPCType; +import com.fr.workspace.resource.WorkResource; + +/** + * 设计器工作环境调用类初始化模块,主要负责将各个模块注册的方法注入进来 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name = "design_workcontext") +@DependsOn(dependencies = {"design_start_up", "i18n", "class", "design_serialization"}) +public class DesignWorkContextComponent { + + private static final String VERSION_NUM = "01"; + + + /** + * prepare + */ + @Supplemental + public void prepare() { + // 纯启动部分的代码不涉及Repository的更改,下一批提交会改掉 + ServiceContext.group(WorkspaceKey.class).addAll( + WorkRPCRegister.wrap(ServerInfoOperator.class, new ServerInfo()), + WorkRPCRegister.wrap(WorkRPCType.Local, WorkResource.class, FineWorkResource.getInstance()), + WorkRPCRegister.wrap(WorkspaceHeartbeat.class, new FineWorkspaceHeartbeat()), + WorkRPCRegister.wrap(StorageTransfer.class, new StorageEncryptors()) + ); + } + + /** + * start + */ + @Start + public void start() { + for (WorkRPCRegister workRPCRegister : ServiceContext.group(WorkspaceKey.class).getAll()) { + validate(workRPCRegister.getClazz()); + FineObjectPool.getInstance().add(workRPCRegister.getClazz(), workRPCRegister.getType(), workRPCRegister.getObject()); + } + + + WorkContext.setConnector(FineWorkspaceConnector.getInstance()); + WorkContext.setFactory(FineWorkspaceFactory.getInstance()); + WorkContext.setWorkResource(new FineWorkResourceAdaptor()); + + WorkContext.setVersion(VERSION_NUM + "#" + ServiceContext.group(WorkspaceKey.class).getAll().size()); + } + + + /** + * stop + */ + @Stop + public void stop() { + + FineObjectPool.getInstance().reset(); + WorkContext.setConnector(null); + WorkContext.setFactory(null); + WorkContext.setWorkResource(null); + WorkContext.setVersion(StringUtils.EMPTY); + } + + + private void validate(Class clazz) { + + if (clazz == null) { + return; + } + if (clazz.getAnnotation(WorkspaceAPI.class) == null) { + FineLoggerFactory.getLogger().warn("workspace service {} not annotated with @Workspace.", clazz); + } + } +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignWorkspaceComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignWorkspaceComponent.java new file mode 100644 index 0000000000..ddf48a7ba6 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignWorkspaceComponent.java @@ -0,0 +1,21 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.ActivatorRefer; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; + +import com.fr.start.module.DesignerWorkspaceActivator; +/** + * 设计器工作环境组件 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name = "workspace_after") +@ActivatorRefer(refer = DesignerWorkspaceActivator.class) +@DependsOn(dependencies = "design") +public class DesignWorkspaceComponent { + + +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignWorkspaceRegisterComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignWorkspaceRegisterComponent.java new file mode 100644 index 0000000000..047fd259f1 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignWorkspaceRegisterComponent.java @@ -0,0 +1,19 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.ActivatorRefer; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fr.startup.WorkspaceRegister; + +/** + * 用于注册工作环境需要的一些额外的方法与类 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name = "design_register") +@DependsOn(dependencies = "workcontext") +@ActivatorRefer(refer = WorkspaceRegister.class) +public class DesignWorkspaceRegisterComponent { +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignerComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignerComponent.java new file mode 100644 index 0000000000..31a4d0c7f7 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignerComponent.java @@ -0,0 +1,24 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.ActivatorRefer; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fr.design.chart.ChartDesignerActivator; +import com.fr.design.mainframe.app.DesignerAppActivator; +import com.fr.design.record.analyzer.DesignerAnalyzerActivator; +import com.fr.start.module.DesignerActivator; +import com.fr.start.module.DesignerESDActivator; + +/** + * 设计器模块 + *

主要负责设计器的主要功能逻辑初始化

+ * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name = "design") +@DependsOn(dependencies = {"design_core_supplemental", "design_dao", "design_conf_config", "design_function"}) +@ActivatorRefer(refer = {DesignerActivator.class, DesignerAppActivator.class, ChartDesignerActivator.class, DesignerESDActivator.class, DesignerAnalyzerActivator.class}) +public class DesignerComponent { +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignerDaoComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignerDaoComponent.java new file mode 100644 index 0000000000..62f250a6fa --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignerDaoComponent.java @@ -0,0 +1,38 @@ +package com.fanruan.boot; + + +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.Start; +import com.fanruan.carina.annotions.Stop; + + +/** + * 设计器dao层模块 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name ="design_dao") +@DependsOn(dependencies = {"design_core_supplemental"}) +public class DesignerDaoComponent extends DAOComponent{ + + + /** + * start + */ + @Start + public void start() { + super.start(); + } + + /** + * stop + */ + @Stop + public void stop() { + super.stop(); + } + +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignerInitComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignerInitComponent.java new file mode 100644 index 0000000000..ab4448b07a --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignerInitComponent.java @@ -0,0 +1,28 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.ActivatorRefer; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fr.start.module.DesignerInitActivator; +import com.fr.start.module.optimized.DesignerStartupPageActivator; + +/** + * 设计器界面初始化模块 + *

负责设计器基础界面初始化+设计器启动页初始化

+ *

设计器启动两个阶段中的第一阶段,到该模块加载完表示设计器基础的前置初始化(界面、国际化等杂七杂八的东西)全部结束了,后面要正式开始数据与功能模块的初始化

+ * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/27 + */ +@FineComponent(name = "design_init") +@DependsOn(dependencies = {"design_start_up", "design_tenant", "design_workcontext", "design_xml", "design_serialization"}) +@ActivatorRefer(refer = { + DesignerInitActivator.class, + DesignerStartupPageActivator.class, +}) +public class DesignerInitComponent { + + + +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignerShowComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignerShowComponent.java new file mode 100644 index 0000000000..a30c636053 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignerShowComponent.java @@ -0,0 +1,43 @@ +package com.fanruan.boot; + +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.Start; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.config.ServerPreferenceConfig; +import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.core.ActionFactory; +import com.fr.design.constants.DesignerLaunchStatus; +import com.fr.quickeditor.chartquick.BasicChartQuickEditor; +import com.fr.start.DesignerInitial; +import com.fr.start.common.DesignerStartupExecutor; +import com.fr.workspace.WorkContext; + +/** + * 设计器启动最后一阶段入口 + *

从该Component start进去后会从dao、config初始化,基础功能模块初始化完毕后会show设计器面板

+ * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/28 + */ +@FineComponent(name = "design_show") +@DependsOn(dependencies = "workspace_after") +public class DesignerShowComponent { + + /** + * start + */ + @Start + public void start() { + DesignerInitial.prepare(); + DesignerStartupExecutor.getInstance().execute(() -> DesignerLaunchStatus.setStatus(DesignerLaunchStatus.DESIGNER_INIT_COMPLETE)); + + //生成BasicChartQuickEditor对象,需要用到ChartDesignerActivator的注册信息(DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class);) + //所以不能在registerCellEditor函数中进行注册 + ActionFactory.registerCellEditor(ChartCollection.class, new BasicChartQuickEditor()); + if (DesignerEnvManager.getEnvManager().isUseOptimizedUPM4Adapter() && WorkContext.getCurrent().isLocal()) { + ServerPreferenceConfig.getInstance().setUseOptimizedUPM(DesignerEnvManager.getEnvManager().isUseOptimizedUPM4Adapter()); + } + } +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/DesignerStartupComponent.java b/designer-realize/src/main/java/com/fanruan/boot/DesignerStartupComponent.java new file mode 100644 index 0000000000..2223938988 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/DesignerStartupComponent.java @@ -0,0 +1,194 @@ +package com.fanruan.boot; + +import com.fanruan.carina.Carina; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.Start; +import com.fanruan.carina.annotions.Stop; +import com.fanruan.boot.key.StartupArgsShell; +import com.fanruan.product.BuildContext; +import com.fr.base.OptimizeUtil; +import com.fr.config.dao.DaoSelectorFactory; +import com.fr.config.dao.PropertiesConstants; +import com.fr.decision.webservice.v10.encryption.EncryptionConstants; +import com.fr.design.DesignerEnvManager; +import com.fr.design.RestartHelper; +import com.fr.design.dialog.TipDialog; +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; +import com.fr.design.file.TemplateResourceManager; +import com.fr.design.fun.impl.GlobalListenerProviderManager; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; +import com.fr.design.mainframe.messagecollect.StartupMessageCollector; +import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; +import com.fr.design.utils.DesignUtils; +import com.fr.env.utils.WorkspaceUtils; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.event.Null; +import com.fr.exit.DesignerExiter; +import com.fr.file.TmpFileUtils; +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.log.FineLoggerFactory; +import com.fr.record.analyzer.EnableMetrics; +import com.fr.record.analyzer.Metrics; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; +import com.fr.start.DesignerProcessType; +import com.fr.start.ServerStarter; +import com.fr.start.common.DesignerStartupContext; +import com.fr.start.event.LazyStartupEvent; +import com.fr.start.module.StartupArgs; +import com.fr.start.preload.PreLoadService; +import com.fr.start.server.FineEmbedServer; +import com.fr.third.guava.base.Stopwatch; +import com.fr.value.NotNullLazyValue; +import org.jetbrains.annotations.NotNull; + +import java.io.File; +import java.util.concurrent.TimeUnit; + +/** + * 设计器启动检查模块 + *

负责设计器启动的前置清理与检查,是一切设计器模块的起点

+ * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/24 + */ +@EnableMetrics +@FineComponent(name = "design_start_up") +public class DesignerStartupComponent { + + private NotNullLazyValue startupArgsValue = new NotNullLazyValue() { + @NotNull + @Override + protected StartupArgs compute() { + return Carina.getApplicationContext().singleton(StartupArgsShell.class).get(); + } + }; + + /** + * start准备 + */ + public void beforeAllStart() { + + BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); + + registerDaoSelector(); + + Stopwatch beforeWatch = Stopwatch.createStarted(); + PreLoadService.getInstance().waitForCommon(); + FineLoggerFactory.getLogger().debug( "DesignerStartup cost {} ms to wait load", beforeWatch.elapsed(TimeUnit.MILLISECONDS)); + + if (DesignUtils.isStarted()) { + // 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了 + final String[] args = startupArgsValue.getValue().get(); + if (ArrayUtils.isNotEmpty(args)) { + DesignUtils.clientSend(args); + } + FineLoggerFactory.getLogger().info("The Designer Has Been Started"); + if (args.length == 0) { + TipDialog dialog = new TipDialog(null, + DesignerProcessType.INSTANCE.obtain(), + Toolkit.i18nText("Fine-Design_Last_Designer_Process_Not_Exist"), + Toolkit.i18nText("Fine-Design_End_Occupied_Process"), + Toolkit.i18nText("Fine-Design_Basic_Cancel")) { + @Override + protected void endEvent() { + dispose(); + DesignUtils.clientSend(new String[]{"end"}); + RestartHelper.restart(); + } + + @Override + protected void cancelEvent() { + dispose(); + } + }; + dialog.setVisible(true); + StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getId(), + DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getMessage(), + StringUtils.EMPTY); + FineLoggerFactory.getLogger().error( "{}: {}", DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getId(), DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getMessage()); + } + DesignerExiter.getInstance().execute(); + } + + } + + /** + * start + */ + @Start + @Metrics + public void start() { + beforeAllStart(); + + //清空临时文件 + TmpFileUtils.cleanUpInnerTmpFiles(); + RestartHelper.deleteRecordFilesWhenStart(); + + CloudCenter.getInstance(); + + // 创建监听服务 + DesignUtils.createListeningServer(DesignUtils.getPort(), startFileSuffix()); + + // 在插件引擎模块起来前 初始化下插件接口监听 + TemplateResourceManager.getResource(); + + initLanguage(); + } + + private void registerDaoSelector() { + // 注入设计器db cache 是否可用 + DesignerWorkspaceInfo info = WorkspaceUtils.getWorkspaceInfo(); + if (info.getType() == DesignerWorkspaceType.Remote) { + DaoSelectorFactory.registerDaoSelector(() -> false); + } else { + String webInfPath = WorkspaceUtils.getWorkspaceInfo().getPath(); + String dbConfigPath = StableUtils.pathJoin(webInfPath, ProjectConstants.CONFIG_DIRECTORY, + EncryptionConstants.PROPERTY_NAME); + String entityPath = generatePath(webInfPath, PropertiesConstants.ENTITY_PROP); + String xmlEntityPath = generatePath(webInfPath, PropertiesConstants.XML_ENTITY_PROP); + String classNamePath = generatePath(webInfPath, PropertiesConstants.CLASS_NAME_PROP); + // 校验 平台迁移文件/缓存文件 + boolean existPropCache = new File(entityPath).exists() && new File(xmlEntityPath).exists() && new File(classNamePath).exists(); + DaoSelectorFactory.registerDaoSelector(() -> DesignerEnvManager.getEnvManager().isPropertiesUsable() + && OptimizeUtil.isOpen() + && existPropCache + // demo启动时 前后目录可能会不一致 造成读取缓存失败 + && !startupArgsValue.getValue().isDemo() + && !new File(dbConfigPath).exists()); + + } + } + + private String generatePath(String webInfPath, String name) { + return StableUtils.pathJoin(webInfPath, ProjectConstants.EMBED_DB_DIRECTORY, + ProjectConstants.PROPERTIES_CACHE_FOR_CONFIG, name); + } + + + /** + * stop + */ + @Stop + public void stop() { + // void + } + + private void initLanguage() { + //这两句的位置不能随便调换,因为会影响语言切换的问题 + GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLanguage()); + } + + private String[] startFileSuffix() { + + return new String[]{".cpt", ".xls", ".xlsx", ".frm", ".form", ".cht", ".chart"}; + } +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/PreLoadComponent.java b/designer-realize/src/main/java/com/fanruan/boot/PreLoadComponent.java new file mode 100644 index 0000000000..3fbc401f78 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/PreLoadComponent.java @@ -0,0 +1,118 @@ +package com.fanruan.boot; + +import com.fanruan.carina.Carina; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.Start; +import com.fanruan.carina.annotions.Stop; +import com.fanruan.product.BuildContext; +import com.fanruan.product.ProductConstants; +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.log.FineLoggerFactory; +import com.fr.measure.DBMeterFactory; +import com.fr.record.DefaultDBMeter; +import com.fr.stable.StringUtils; +import com.fr.stable.xml.StableXMLUtils; +import com.fr.license.function.VT4FR; +import javax.servlet.ServletContext; + + +/** + * 设计器preload模块,主要负责最开始的环境信息与日志处理 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/24 + */ +@FineComponent(name = "design_pre_load") +@DependsOn(dependencies = {"design_start_up", "design_tenant"}) +public class PreLoadComponent { + + /** + * start + */ + @Start + @SuppressWarnings("all") + public void start() { + try { + // PreLoadActivator + startBasic(); + // DefaultLogActivator + startLog(); + } catch (RuntimeException e) { + throw e; + } finally { + //防止还有什么莫名其妙的 bug 影响到注册的启动。 + VT4FR.values(); + } + } + + + private void startBasic() { + BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); + Inter.getInstance(); + StableXMLUtils.load(); + checkWebAppName(); + checkWebContextName(); + } + + private void startLog() { + FineLoggerFactory.registerLogger(FRLogger.getLogger()); + DBMeterFactory.register(new DefaultDBMeter()); + } + + /** + * stop + */ + @Stop + public void stop() { + stopLog(); + + } + + private void stopLog() { + FineLoggerFactory.reset(); + DBMeterFactory.remove(); + } + + + /** + * war包部署时登录进入平台后才设置com.fr.stable.ProductConstants.WEB_APP_NAME,而证书检查在启动时就开始进行, + * 此时ProductConstants.WEB_APP_NAME == null, LicenseMatchInfo的isAppNameMatch会被设置为false,导致war包部署重启证书不生效 + */ + private void checkWebAppName() { + ServletContext context = Carina.getApplicationContext().getServletContext(); + + if (context != null) { + if (ProductConstants.getWebAppName() == null) { + String contextPath = context.getContextPath(); + if (StringUtils.isNotEmpty(contextPath)) { + if (contextPath.startsWith("/")) { + contextPath = contextPath.substring(1); + } + + ProductConstants.setWebAppName(contextPath); + } + } + } + } + + private void checkWebContextName() { + ServletContext context = Carina.getApplicationContext().getServletContext(); + + if (context != null) { + if (ProductConstants.getWebContextName() == null) { + String contextPath = context.getContextPath(); + if (null != contextPath) { + if (contextPath.startsWith("/")) { + contextPath = contextPath.substring(1); + } + + ProductConstants.setWebContextName(contextPath); + } + } + } + } + +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/XMLableComponent.java b/designer-realize/src/main/java/com/fanruan/boot/XMLableComponent.java new file mode 100644 index 0000000000..e9f237b802 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/XMLableComponent.java @@ -0,0 +1,23 @@ +package com.fanruan.boot; + + +import com.fanruan.carina.annotions.ActivatorRefer; +import com.fanruan.carina.annotions.DependsOn; +import com.fanruan.carina.annotions.FineComponent; +import com.fr.register.XMLableActivator; + + +/** + * XML模块 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/27 + */ +@FineComponent(name = "design_xml") +@DependsOn(dependencies = {"design_start_up"}) +@ActivatorRefer(refer = {XMLableActivator.class}) +public class XMLableComponent { + + +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/key/ActivatorContextGroup.java b/designer-realize/src/main/java/com/fanruan/boot/key/ActivatorContextGroup.java new file mode 100644 index 0000000000..d8a571a539 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/key/ActivatorContextGroup.java @@ -0,0 +1,14 @@ +package com.fanruan.boot.key; + +import com.fr.decision.service.context.MutableGroup; +import com.fr.module.engine.base.ActivatorContext; + +/** + * 传输启动器上下文的group + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/27 + */ +public class ActivatorContextGroup extends MutableGroup { +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/key/StartupArgsShell.java b/designer-realize/src/main/java/com/fanruan/boot/key/StartupArgsShell.java new file mode 100644 index 0000000000..7b4da84362 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/key/StartupArgsShell.java @@ -0,0 +1,14 @@ +package com.fanruan.boot.key; + +import com.fr.decision.service.context.SingletonShell; +import com.fr.start.module.StartupArgs; + +/** + * StartupArgsShell + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/24 + */ +public class StartupArgsShell extends SingletonShell { +} diff --git a/designer-realize/src/main/java/com/fr/design/present/CurrencyLinePane.java b/designer-realize/src/main/java/com/fr/design/present/CurrencyLinePane.java index 6a98189d9e..cf278b6df4 100644 --- a/designer-realize/src/main/java/com/fr/design/present/CurrencyLinePane.java +++ b/designer-realize/src/main/java/com/fr/design/present/CurrencyLinePane.java @@ -1,6 +1,6 @@ package com.fr.design.present; -import com.fr.code.bar.BarcodeException; +import com.fr.barcode.core.BarcodeException; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.LayoutConstants; diff --git a/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java b/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java index 92885a3b3c..7c5ca7b83a 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/EditReportServerParameterPane.java @@ -5,6 +5,7 @@ package com.fr.design.webattr; import com.fr.base.ConfigManager; import com.fr.base.print.PrintSettingsAttrMark; +import com.fr.config.ExportPrintConfig; import com.fr.config.PrintConfig; import com.fr.config.ServerPreferenceConfig; import com.fr.design.gui.frpane.LoadingBasicPane; @@ -117,7 +118,7 @@ public class EditReportServerParameterPane extends LoadingBasicPane { jsPane.update(webAttr); printSettings = printSettingPane.updateBean(); - PrintConfig.getInstance().setPrintSettings(printSettings); + ExportPrintConfig.getInstance().setPrintSettings(printSettings); reportServerPreferenceConfig.setErrorTemplate(this.errorTemplatePane.updateBean()); if (serverFitAttrPane != null) { diff --git a/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java b/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java new file mode 100644 index 0000000000..57baaa2f92 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/CarinaDesigner.java @@ -0,0 +1,83 @@ +package com.fr.start; + +import com.fanruan.boot.key.StartupArgsShell; +import com.fanruan.carina.Carina; +import com.fanruan.carina.context.CarinaApplicationContext; +import com.fanruan.carina.standard.PartitionManager; +import com.fanruan.carina.standard.PartitionManagerImpl; +import com.fr.design.DesignerEnvManager; +import com.fr.design.carton.SwitchForSwingChecker; +import com.fr.design.deeplink.DeepLinkManager; +import com.fr.design.monitor.DesignerLifecycleMonitorContext; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.log.FineLoggerFactory; +import com.fr.module.engine.event.LifecycleErrorEvent; +import com.fr.runtime.FineRuntime; +import com.fr.stable.lifecycle.FineLifecycleFatalError; +import com.fr.start.common.DesignerStartupContext; +import com.fr.start.module.StartupArgs; +import com.fr.workspace.WorkContext; + +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +/** + * Designer + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/14 + */ +public class CarinaDesigner extends MainDesigner{ + + public CarinaDesigner(String[] args) { + super(args); + } + + /** + * main + */ + public static void main(String[] args) { + + DesignerStartupContext.getRecorder().start(); + PartitionManager manager = new PartitionManagerImpl(); + CarinaApplicationContext carinaApplicationContext = new DesignContext(new EmptyServletContext(), manager, new Properties()); + Carina.setApplicationContext(carinaApplicationContext); + Carina.setPartitionManager(manager); + DesignLauncher.setContext(carinaApplicationContext); + DesignerEnvManager.getEnvManager(); + + startPreload0(); + + DesignerLifecycleMonitorContext.getMonitor().beforeStart(); + //启动运行时 + FineRuntime.start(); + //等 FineRuntime 启动后启动 + DeepLinkManager.getInstance().start(args); + + startPreload1(); + + DesignerSubListener.getInstance().start(); + EventDispatcher.listen(LifecycleErrorEvent.SELF, new Listener() { + @Override + public void on(Event event, FineLifecycleFatalError param) { + LifecycleFatalErrorHandler.getInstance().handle(param); + } + }); + DesignLauncher launch = new DesignLauncher("/com/fr/config/starter/designer-startup-carina.xml"); + try { + FineLoggerFactory.getLogger().debug("Designer prepared.Time used {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS)); + Carina.getApplicationContext().singleton(StartupArgsShell.class).set(new StartupArgs(args)); + launch.launch(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + FineLoggerFactory.getLogger().info("Designer started.Time used {} ms", DesignerStartupContext.getRecorder().getTime(TimeUnit.MILLISECONDS)); + + SwitchForSwingChecker.initThreadMonitoring(); + } + +} diff --git a/designer-realize/src/main/java/com/fr/start/DesignContext.java b/designer-realize/src/main/java/com/fr/start/DesignContext.java new file mode 100644 index 0000000000..f08df80179 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/DesignContext.java @@ -0,0 +1,42 @@ +package com.fr.start; + +import com.fanruan.carina.context.CarinaApplicationContext; +import com.fanruan.carina.standard.PartitionManager; +import com.fanruan.carina.standard.PartitionManagerImpl; + +import javax.servlet.ServletContext; + +import java.util.Properties; + +/** + * 设计器上下文环境 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/14 + */ +public class DesignContext extends CarinaApplicationContext { + private String designWebInfPath; + + public DesignContext() { + super(new EmptyServletContext(), new PartitionManagerImpl(), new Properties()); + } + + public DesignContext(ServletContext servletContext, PartitionManager manager, Properties carinaApplicationProperties) { + super(servletContext, manager, carinaApplicationProperties); + } + + + @Override + public String getWebInfPath() { + return designWebInfPath; + } + + public String getDesignWebInfPath() { + return designWebInfPath; + } + + public void setDesignWebInfPath(String designWebInfPath) { + this.designWebInfPath = designWebInfPath; + } +} diff --git a/designer-realize/src/main/java/com/fr/start/DesignLauncher.java b/designer-realize/src/main/java/com/fr/start/DesignLauncher.java new file mode 100644 index 0000000000..e2f776231b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/DesignLauncher.java @@ -0,0 +1,88 @@ +package com.fr.start; + +import com.fanruan.boot.DiscoveryProperties; +import com.fanruan.carina.Carina; +import com.fanruan.carina.context.CarinaApplicationContext; +import com.fanruan.carina.exceptions.CarinaException; +import com.fanruan.carina.launch.XmlCarinaLauncher; +import com.fanruan.carina.lifecycle.bootstrap.BootstrapFactory; +import com.fanruan.discovery.DiscoveryFactory; + +import javax.servlet.ServletContext; +import java.util.Properties; + +/** + * 设计器启动的launcher,用来自定义具体的launcher逻辑 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/27 + */ +public class DesignLauncher extends XmlCarinaLauncher { + private static CarinaApplicationContext context; + public DesignLauncher(String path) { + super(context.getPartitionManager(), context.getServletContext(), context.getCarinaApplicationProperties(), path); + } + + @Override + protected boolean validate(Class clz) { + return true; + } + + @Override + protected CarinaApplicationContext createApplicationContext(ServletContext servletContext, Properties carinaApplicationProperties) { + return context; + } + + + @Override + protected void initServiceDiscovery() throws CarinaException { + try { + Carina.properties(DiscoveryProperties.class).setServer("local"); + // 服务发现初始化 + DiscoveryFactory.initialize(); + } catch (Exception e) { + throw new CarinaException(e); + } + } + + @Override + protected void initializeSpring() throws CarinaException { + // do nothing + } + + @Override + protected void startListening() { + + } + + @Override + protected void setGlobalInformation() { + + } + + @Override + protected void startComponentsAndServices() throws CarinaException { + try { + BootstrapFactory.get().supplement(); + BootstrapFactory.get().start("design_init"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * 获取context + */ + public static CarinaApplicationContext getContext() { + return context; + } + + + /** + * 设置context + */ + public static void setContext(CarinaApplicationContext context) { + DesignLauncher.context = context; + } +} diff --git a/designer-realize/src/main/java/com/fr/start/EmptyServletContext.java b/designer-realize/src/main/java/com/fr/start/EmptyServletContext.java new file mode 100644 index 0000000000..89b1f72ef2 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/EmptyServletContext.java @@ -0,0 +1,290 @@ +package com.fr.start; + +import com.fr.stable.StringUtils; + +import javax.servlet.Filter; +import javax.servlet.FilterRegistration; +import javax.servlet.RequestDispatcher; +import javax.servlet.Servlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; +import javax.servlet.SessionCookieConfig; +import javax.servlet.SessionTrackingMode; +import javax.servlet.descriptor.JspConfigDescriptor; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; +import java.util.EventListener; +import java.util.Map; +import java.util.Set; + +/** + * EmptyServletContext + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/5/15 + */ +public class EmptyServletContext implements ServletContext { + @Override + public String getContextPath() { + return StringUtils.EMPTY; + } + + @Override + public ServletContext getContext(String s) { + return null; + } + + @Override + public int getMajorVersion() { + return 0; + } + + @Override + public int getMinorVersion() { + return 0; + } + + @Override + public int getEffectiveMajorVersion() { + return 0; + } + + @Override + public int getEffectiveMinorVersion() { + return 0; + } + + @Override + public String getMimeType(String s) { + return null; + } + + @Override + public Set getResourcePaths(String s) { + return null; + } + + @Override + public URL getResource(String s) throws MalformedURLException { + return null; + } + + @Override + public InputStream getResourceAsStream(String s) { + return null; + } + + @Override + public RequestDispatcher getRequestDispatcher(String s) { + return null; + } + + @Override + public RequestDispatcher getNamedDispatcher(String s) { + return null; + } + + @Override + public Servlet getServlet(String s) throws ServletException { + return null; + } + + @Override + public Enumeration getServlets() { + return null; + } + + @Override + public Enumeration getServletNames() { + return null; + } + + @Override + public void log(String s) { + + } + + @Override + public void log(Exception e, String s) { + + } + + @Override + public void log(String s, Throwable throwable) { + + } + + @Override + public String getRealPath(String s) { + return null; + } + + @Override + public String getServerInfo() { + return null; + } + + @Override + public String getInitParameter(String s) { + return null; + } + + @Override + public Enumeration getInitParameterNames() { + return null; + } + + @Override + public boolean setInitParameter(String s, String s1) { + return false; + } + + @Override + public Object getAttribute(String s) { + return null; + } + + @Override + public Enumeration getAttributeNames() { + return null; + } + + @Override + public void setAttribute(String s, Object o) { + + } + + @Override + public void removeAttribute(String s) { + + } + + @Override + public String getServletContextName() { + return null; + } + + @Override + public ServletRegistration.Dynamic addServlet(String s, String s1) { + return null; + } + + @Override + public ServletRegistration.Dynamic addServlet(String s, Servlet servlet) { + return null; + } + + @Override + public ServletRegistration.Dynamic addServlet(String s, Class aClass) { + return null; + } + + @Override + public T createServlet(Class aClass) throws ServletException { + return null; + } + + @Override + public ServletRegistration getServletRegistration(String s) { + return null; + } + + @Override + public Map getServletRegistrations() { + return null; + } + + @Override + public FilterRegistration.Dynamic addFilter(String s, String s1) { + return null; + } + + @Override + public FilterRegistration.Dynamic addFilter(String s, Filter filter) { + return null; + } + + @Override + public FilterRegistration.Dynamic addFilter(String s, Class aClass) { + return null; + } + + @Override + public T createFilter(Class aClass) throws ServletException { + return null; + } + + @Override + public FilterRegistration getFilterRegistration(String s) { + return null; + } + + @Override + public Map getFilterRegistrations() { + return null; + } + + @Override + public SessionCookieConfig getSessionCookieConfig() { + return null; + } + + @Override + public void setSessionTrackingModes(Set set) { + + } + + @Override + public Set getDefaultSessionTrackingModes() { + return null; + } + + @Override + public Set getEffectiveSessionTrackingModes() { + return null; + } + + @Override + public void addListener(String s) { + + } + + @Override + public void addListener(T t) { + + } + + @Override + public void addListener(Class aClass) { + + } + + @Override + public T createListener(Class aClass) throws ServletException { + return null; + } + + @Override + public JspConfigDescriptor getJspConfigDescriptor() { + return null; + } + + @Override + public ClassLoader getClassLoader() { + return null; + } + + @Override + public void declareRoles(String... strings) { + + } + + @Override + public String getVirtualServerName() { + return null; + } +} diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index d4a8a5493a..6bc4defe2c 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.java @@ -162,7 +162,7 @@ public class MainDesigner extends BaseDesigner { /** * 在 {@link FineRuntime#start()} 运行后 */ - private static void startPreload1() { + protected static void startPreload1() { CompletableFuture initLookAndFeel = CompletableFuture.runAsync(DesignUtils::initLookAndFeel); PreLoadService.getInstance().addUIFuture(initLookAndFeel); @@ -173,7 +173,7 @@ public class MainDesigner extends BaseDesigner { /** * 在 {@link FineRuntime#start()} 运行前 */ - private static void startPreload0() { + protected static void startPreload0() { PreLoadService.getInstance().addRunnable(() -> { if (DesignUtils.isPortOccupied()) { 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 16a923df37..ff94f26c5d 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 @@ -1,5 +1,6 @@ package com.fr.start.module; +import com.fanruan.cloud.FanruanCloud; import com.fr.base.BaseFormula; import com.fr.base.Formula; import com.fr.base.MultiFieldParameter; @@ -10,11 +11,9 @@ import com.fr.base.process.ProcessOperator; import com.fr.base.theme.migrator.FormThemeConfigMigrator; import com.fr.base.theme.migrator.ReportThemeConfigMigrator; import com.fr.chart.chartattr.ChartCollection; -import com.fr.config.MarketConfig; import com.fr.config.ServerPreferenceConfig; import com.fr.decision.update.backup.RecoverManager; -import com.fr.decision.webservice.v10.plugin.helper.category.impl.PluginResourceLoader; -import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; +import com.fr.decision.webservice.v10.plugin.helper.category.ResourceLoader; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.NewFormAction; @@ -36,6 +35,7 @@ import com.fr.design.actions.replace.utils.ReplaceOperator; import com.fr.design.bridge.DesignToolbarProvider; import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.env.DesignerWorkspaceLoader; +import com.fr.design.extra.PluginHelper; import com.fr.design.fit.NewJForm; import com.fr.design.fit.common.TemplateTool; import com.fr.design.form.parameter.FormParaDesigner; @@ -144,6 +144,7 @@ import com.fr.start.BBSGuestPaneProvider; import com.fr.start.common.DesignerStartupExecutor; import com.fr.start.common.DesignerStartupPool; import com.fr.task.Once; +import com.fr.tenant.context.TenantContext; import com.fr.workspace.WorkContext; import com.fr.xml.ReportXMLUtils; @@ -178,7 +179,6 @@ public class DesignerActivator extends Activator implements Prepare { @Override public void start() { - List markers = findMutable(InterMutableKey.Path); for (LocaleMarker marker : markers) { if (marker.match(LocaleScope.DESIGN)) { @@ -215,8 +215,8 @@ public class DesignerActivator extends Activator implements Prepare { CompletableFuture resourcePrepare = CompletableFuture.runAsync(() -> { pushUpdateTask.run(); if (WorkContext.getCurrent().isLocal()) { - PluginResourceLoader.INSTANCE.checkOldShopFile(); - UpmResourceLoader.INSTANCE.checkOldShopFile(); + PluginHelper.getInstance().getPluginLoader().checkOldShopFile(); + PluginHelper.getInstance().getUpmLoader().checkOldShopFile(); } }, DesignerStartupPool.common()); @@ -514,15 +514,15 @@ public class DesignerActivator extends Activator implements Prepare { if (newUid > 0) { return; } - int oldUid = MarketConfig.getInstance().getBbsUid(); + int oldUid = FanruanCloud.marketService().getBbsUid(); if (oldUid > 0) { manager.setDesignerLoginUid(oldUid); - manager.setDesignerLoginUsername(MarketConfig.getInstance().getBbsUsername()); - manager.setDesignerLoginAppId(MarketConfig.getInstance().getBbsAppId()); - manager.setDesignerLoginRefreshToken(MarketConfig.getInstance().getBbsRefreshToken()); + manager.setDesignerLoginUsername(FanruanCloud.marketService().getBbsUsername()); + manager.setDesignerLoginAppId(FanruanCloud.marketService().getBbsAppId()); + manager.setDesignerLoginRefreshToken(FanruanCloud.marketService().getBbsRefreshToken()); manager.setDesignerLastLoginTime(System.currentTimeMillis()); manager.setLastLoginType(DesignerLoginType.NORMAL_LOGIN); - manager.setLastLoginAccount(MarketConfig.getInstance().getBbsUsername()); + manager.setLastLoginAccount(FanruanCloud.marketService().getBbsUsername()); manager.setCurrentVersionFirstLaunch(false); DesignerEnvManager.getEnvManager().saveXMLFile(); } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java index 1c8fee3793..af08df31d6 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java @@ -1,25 +1,34 @@ package com.fr.start.module; +import com.fanruan.boot.key.StartupArgsShell; +import com.fanruan.carina.Carina; import com.fr.design.PluginClassRefreshManager; import com.fr.design.mainframe.app.DesignerAppUtils; +import com.fr.io.repository.base.fs.FileSystemRepository; +import com.fr.io.utils.ResourceIOUtils; import com.fr.module.Activator; +import com.fr.module.extension.Prepare; import com.fr.start.DesignerInitial; /** * 设计器界面初始化 * * @author vito - * @version 10.0 - * Created by vito on 2019/9/25 + * @since 10.0 + * Created on 2019/9/25 */ -public class DesignerInitActivator extends Activator { +public class DesignerInitActivator extends Activator implements Prepare { + @Override + public void prepare() { + ResourceIOUtils.setUnderlying(FileSystemRepository.getSingleton()); + } @Override public void start() { PluginClassRefreshManager.getInstance().load(); DesignerAppUtils.initPluginAllActiveListener(); - DesignerInitial.init(findSingleton(StartupArgs.class).get()); + DesignerInitial.init(Carina.getApplicationContext().singleton(StartupArgsShell.class).get().get()); } @Override diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 834f1ee30a..40036212e9 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -1,6 +1,7 @@ package com.fr.start.module; +import com.fanruan.product.BuildContext; import com.fr.base.OptimizeUtil; import com.fr.concurrent.NamedThreadFactory; import com.fr.config.dao.DaoSelectorFactory; @@ -27,7 +28,6 @@ import com.fr.module.Activator; import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.Metrics; import com.fr.stable.ArrayUtils; -import com.fr.stable.BuildContext; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java index 858eca4977..13d97017b2 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java @@ -1,21 +1,121 @@ package com.fr.start.module; +import com.fr.base.operator.org.OrganizationOperator; +import com.fr.base.rpc.encrypt.EncryptOperator; import com.fr.concurrent.NamedThreadFactory; +import com.fr.decision.service.context.ServiceContext; import com.fr.design.PluginClassRefreshManager; import com.fr.design.file.HistoryTemplateListCache; import com.fr.event.Event; +import com.fr.event.EventDispatcher; import com.fr.event.Listener; +import com.fr.file.filetree.FileNodes; +import com.fr.form.share.ShareComponentOperator; +import com.fr.form.share.ShareEmbeddedConverter; import com.fr.module.Activator; +import com.fr.module.extension.Prepare; +import com.fr.report.lock.DefaultLockInfoOperator; +import com.fr.report.lock.LocalLockInfoOperator; +import com.fr.report.lock.LockInfoOperator; +import com.fr.report.lock.ServerLockInfoOperator; import com.fr.start.server.FineEmbedServer; import com.fr.workspace.Workspace; import com.fr.workspace.WorkspaceEvent; +import com.fr.workspace.base.WorkspaceKey; +import com.fr.workspace.pool.WorkRPCRegister; +import com.fr.workspace.pool.WorkRPCType; +import com.fr.workspace.resource.WorkResource; +import com.fr.workspace.server.ServerFileNodes; +import com.fr.workspace.server.ServerWorkResource; +import com.fr.workspace.server.authority.AuthorityOperator; +import com.fr.workspace.server.authority.FineAuthorityOperator; +import com.fr.workspace.server.authority.decision.DecisionOperator; +import com.fr.workspace.server.authority.decision.FineDecisionOperator; +import com.fr.workspace.server.authority.organization.OrganizationOperatorImpl; +import com.fr.workspace.server.authority.user.DefaultUserAuthority; +import com.fr.workspace.server.authority.user.LocalUserAuthority; +import com.fr.workspace.server.authority.user.ServerUserAuthority; +import com.fr.workspace.server.authority.user.UserAuthority; +import com.fr.workspace.server.check.TemplateChecker; +import com.fr.workspace.server.check.TemplateCheckerImpl; +import com.fr.workspace.server.check.VersionInfoOperator; +import com.fr.workspace.server.check.VersionInfoOperatorImpl; +import com.fr.workspace.server.connection.DBConnectAuth; +import com.fr.workspace.server.connection.LocalDBConnectAuth; +import com.fr.workspace.server.connection.ServerDBConnectAuth; +import com.fr.workspace.server.database.DataBaseTypeOperator; +import com.fr.workspace.server.database.DefaultDatabaseTypeOperator; +import com.fr.workspace.server.database.LocalDatabaseTypeOperator; +import com.fr.workspace.server.database.ServerDatabaseTypeOperator; +import com.fr.workspace.server.encrypt.FineEncryptOperator; +import com.fr.workspace.server.exporter.LocalExportOperator; +import com.fr.workspace.server.exporter.ServerExportOperator; +import com.fr.workspace.server.exporter.TemplateExportOperator; +import com.fr.workspace.server.lock.LocalTplOperator; +import com.fr.workspace.server.lock.ServerTplOperator; +import com.fr.workspace.server.lock.TplOperator; +import com.fr.workspace.server.lock.editlock.DefaultEditLockOperator; +import com.fr.workspace.server.lock.editlock.EditLockOperator; +import com.fr.workspace.server.lock.editlock.LocalEditLockOperator; +import com.fr.workspace.server.lock.editlock.ServerEditLockOperator; +import com.fr.workspace.server.share.DefaultShareComponentOperator; +import com.fr.workspace.server.share.DefaultShareEmbeddedConverter; +import com.fr.workspace.server.socket.FineSocketInfoOperator; +import com.fr.workspace.server.socket.SocketInfoOperator; +import com.fr.workspace.server.socket.SocketTokenVerifierOperator; +import com.fr.workspace.server.socket.SocketVerifierOperator; +import com.fr.workspace.server.socket.SocketWsidVerifierOperator; +import com.fr.workspace.server.theme.NotSupportThemedCellInnerBorderFeature; +import com.fr.workspace.server.theme.SupportThemedCellInnerBorderFeature; +import com.fr.workspace.server.theme.ThemedCellBorderFeature; +import com.fr.workspace.server.vcs.CompatibleVcsOperator; +import com.fr.workspace.server.vcs.VcsOperator; +import com.fr.workspace.server.vcs.VcsOperatorProxy; import java.util.concurrent.ExecutorService; /** - * Created by juhaoyu on 2019-06-14. + * DesignerWorkspaceActivator + * + * @author juhaoyu + * @since 10.0 + * Created on 2019-06-14 */ -public class DesignerWorkspaceActivator extends Activator { +public class DesignerWorkspaceActivator extends Activator implements Prepare { + private Listener beforeSwitch4Min = new Listener(Integer.MIN_VALUE) { + + @Override + public void on(Event event, Workspace current) { + // 切换环境功能要再斟酌一下怎么实现合理一些 + //stopSub(EnvBasedModule.class); + } + }; + private Listener afterSwitch4Max = new Listener(Integer.MAX_VALUE) { + + @Override + public void on(Event event, Workspace current) { + // 切换环境功能要再斟酌一下怎么实现合理一些 + //startSub(EnvBasedModule.class); + } + }; + private Listener beforeSwitch4Max = new Listener(Integer.MAX_VALUE) { + + @Override + public void on(Event event, Workspace workspace) { + PluginClassRefreshManager.getInstance().removePluginListener(); + HistoryTemplateListCache.getInstance().stash(); + PluginClassRefreshManager.getInstance().fireTabChange(); + } + }; + + private Listener afterSwitch4Min = new Listener(Integer.MIN_VALUE) { + + @Override + public void on(Event event, Workspace workspace) { + HistoryTemplateListCache.getInstance().load(); + PluginClassRefreshManager.getInstance().addPluginListener(); + } + }; @Override public void start() { @@ -29,43 +129,14 @@ public class DesignerWorkspaceActivator extends Activator { private void registerEnvListener() { /*切换环境前,关闭所有相关模块,最后执行*/ - listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MIN_VALUE) { - - @Override - public void on(Event event, Workspace current) { - - stopSub(EnvBasedModule.class); - } - }); + EventDispatcher.listen(WorkspaceEvent.BeforeSwitch, beforeSwitch4Min); /*切换环境后,重新启动所有相关模块,最先执行*/ - listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MAX_VALUE) { - - @Override - public void on(Event event, Workspace current) { - - startSub(EnvBasedModule.class); - } - }); + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, afterSwitch4Max); /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ - listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MAX_VALUE) { - - @Override - public void on(Event event, Workspace workspace) { - PluginClassRefreshManager.getInstance().removePluginListener(); - HistoryTemplateListCache.getInstance().stash(); - PluginClassRefreshManager.getInstance().fireTabChange(); - } - }); + EventDispatcher.listen(WorkspaceEvent.BeforeSwitch, beforeSwitch4Max); /*切换环境后,装载一下打开的所有文件对象,优先级低于默认优先级,要后于 启动相关模块部分 被触发*/ - listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MIN_VALUE) { - - @Override - public void on(Event event, Workspace workspace) { - HistoryTemplateListCache.getInstance().load(); - PluginClassRefreshManager.getInstance().addPluginListener(); - } - }); + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, afterSwitch4Min); } private void startServer(Workspace current) { @@ -87,6 +158,51 @@ public class DesignerWorkspaceActivator extends Activator { @Override public void stop() { + EventDispatcher.stopListen(beforeSwitch4Max); + EventDispatcher.stopListen(beforeSwitch4Min); + EventDispatcher.stopListen(afterSwitch4Min); + EventDispatcher.stopListen(afterSwitch4Max); + } + + @Override + public void prepare() { + ServiceContext.group(WorkspaceKey.class).addAll( + WorkRPCRegister.wrap(WorkRPCType.Server, FileNodes.class, new ServerFileNodes()), + WorkRPCRegister.wrap(AuthorityOperator.class, new FineAuthorityOperator()), + WorkRPCRegister.wrap(DecisionOperator.class, new FineDecisionOperator()), + WorkRPCRegister.wrap(SocketInfoOperator.class, new FineSocketInfoOperator()), + WorkRPCRegister.wrap(OrganizationOperator.class, new OrganizationOperatorImpl()), + WorkRPCRegister.wrap(WorkRPCType.Server, WorkResource.class, ServerWorkResource.getInstance()), + WorkRPCRegister.wrap(WorkRPCType.Server, TplOperator.class, ServerTplOperator.getInstance()), + WorkRPCRegister.wrap(WorkRPCType.Local, TplOperator.class, new LocalTplOperator()), + WorkRPCRegister.wrap(WorkRPCType.Server, DBConnectAuth.class, new ServerDBConnectAuth()), + WorkRPCRegister.wrap(WorkRPCType.Local, DBConnectAuth.class, new LocalDBConnectAuth()), + WorkRPCRegister.wrap(WorkRPCType.Local, TemplateExportOperator.class, new LocalExportOperator()), + WorkRPCRegister.wrap(WorkRPCType.Server, TemplateExportOperator.class, new ServerExportOperator()), + WorkRPCRegister.wrap(WorkRPCType.Local, EditLockOperator.class, new LocalEditLockOperator()), + WorkRPCRegister.wrap(WorkRPCType.Server, EditLockOperator.class, ServerEditLockOperator.getInstance()), + WorkRPCRegister.wrap(WorkRPCType.Compatible, EditLockOperator.class, new DefaultEditLockOperator()), + WorkRPCRegister.wrap(EncryptOperator.class, new FineEncryptOperator()), + WorkRPCRegister.wrap(VcsOperator.class, new VcsOperatorProxy()), + WorkRPCRegister.wrap(WorkRPCType.Compatible, VcsOperator.class, new CompatibleVcsOperator()), + WorkRPCRegister.wrap(TemplateChecker.class, new TemplateCheckerImpl()), + WorkRPCRegister.wrap(ShareComponentOperator.class, new DefaultShareComponentOperator()), + WorkRPCRegister.wrap(ShareEmbeddedConverter.class, new DefaultShareEmbeddedConverter()), + WorkRPCRegister.wrap(VersionInfoOperator.class, new VersionInfoOperatorImpl()), + WorkRPCRegister.wrap(WorkRPCType.Server, UserAuthority.class, new ServerUserAuthority()), + WorkRPCRegister.wrap(WorkRPCType.Local, UserAuthority.class, new LocalUserAuthority()), + WorkRPCRegister.wrap(WorkRPCType.Compatible, UserAuthority.class, new DefaultUserAuthority()), + WorkRPCRegister.wrap(WorkRPCType.Local, ThemedCellBorderFeature.class, new SupportThemedCellInnerBorderFeature()), + WorkRPCRegister.wrap(WorkRPCType.Server, ThemedCellBorderFeature.class, new SupportThemedCellInnerBorderFeature()), + WorkRPCRegister.wrap(WorkRPCType.Compatible, ThemedCellBorderFeature.class, new NotSupportThemedCellInnerBorderFeature()), + WorkRPCRegister.wrap(WorkRPCType.Server, LockInfoOperator.class, ServerLockInfoOperator.getInstance()), + WorkRPCRegister.wrap(WorkRPCType.Local, LockInfoOperator.class, new LocalLockInfoOperator()), + WorkRPCRegister.wrap(WorkRPCType.Compatible, LockInfoOperator.class, new DefaultLockInfoOperator()), + WorkRPCRegister.wrap(WorkRPCType.Local, DataBaseTypeOperator.class, new LocalDatabaseTypeOperator()), + WorkRPCRegister.wrap(WorkRPCType.Server, DataBaseTypeOperator.class, new ServerDatabaseTypeOperator()), + WorkRPCRegister.wrap(WorkRPCType.Compatible, DataBaseTypeOperator.class, new DefaultDatabaseTypeOperator()), + WorkRPCRegister.wrap(WorkRPCType.Simple, SocketVerifierOperator.class, new SocketWsidVerifierOperator()), + WorkRPCRegister.wrap(WorkRPCType.Compatible, SocketVerifierOperator.class, new SocketTokenVerifierOperator())); } } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index a440906aff..d4bb496d33 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -1,5 +1,7 @@ package com.fr.start.module; +import com.fanruan.boot.key.StartupArgsShell; +import com.fanruan.carina.Carina; import com.fr.design.DesignerEnvManager; import com.fr.design.EnvChangeEntrance; import com.fr.design.constants.DesignerLaunchStatus; @@ -8,14 +10,13 @@ import com.fr.design.editlock.ServerTableDataLockChangeChecker; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.plugin.remind.PluginErrorDesignReminder; -import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.utils.WorkspaceUtils; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.event.Null; -import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; +import com.fr.start.DesignContext; import com.fr.value.NotNullLazyValue; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; @@ -33,7 +34,7 @@ public class DesignerWorkspaceProvider extends Activator { @NotNull @Override protected StartupArgs compute() { - return findSingleton(StartupArgs.class); + return Carina.getApplicationContext().singleton(StartupArgsShell.class).get(); } }; @@ -49,6 +50,7 @@ public class DesignerWorkspaceProvider extends Activator { try { String current = DesignerEnvManager.getEnvManager().getCurEnvName(); workspaceInfo = WorkspaceUtils.getWorkspaceInfo(); + ((DesignContext)Carina.getApplicationContext()).setDesignWebInfPath(workspaceInfo.getPath()); Workspace workspace = DesignerWorkspaceGenerator.generate(workspaceInfo); boolean checkValid = workspace != null && workspaceInfo.checkValid(); if (!checkValid) { diff --git a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerPluginActivator.java b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerPluginActivator.java index fd6286e33d..d70310a7dc 100644 --- a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerPluginActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerPluginActivator.java @@ -2,7 +2,6 @@ package com.fr.start.module.optimized; import com.fr.module.Activator; import com.fr.module.ModuleContext; -import com.fr.plugin.PluginActivator; import com.fr.start.common.DesignerStartupExecutor; /** @@ -12,13 +11,13 @@ public class DesignerPluginActivator extends Activator { @Override public void start() { - - DesignerStartupExecutor.getInstance().execute(() -> ModuleContext.getModule(PluginActivator.class).start()); + // 无用了,用PluginComponent + //DesignerStartupExecutor.getInstance().execute(() -> ModuleContext.getModule(PluginActivator.class).start()); } @Override public void stop() { - - ModuleContext.getModule(PluginActivator.class).stop(); + // 无用了,用PluginComponent + //ModuleContext.getModule(PluginActivator.class).stop(); } } diff --git a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java index d861fa052a..6a5035015b 100644 --- a/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java @@ -1,5 +1,8 @@ package com.fr.start.module.optimized; +import com.fanruan.boot.key.ActivatorContextGroup; +import com.fanruan.boot.key.StartupArgsShell; +import com.fanruan.carina.Carina; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.DesignerContext; import com.fr.design.ui.util.UIUtil; @@ -36,7 +39,7 @@ public class DesignerStartupPageActivator extends Activator { @NotNull @Override protected StartupArgs compute() { - return findSingleton(StartupArgs.class); + return Carina.getApplicationContext().singleton(StartupArgsShell.class).get(); } }; @@ -63,7 +66,11 @@ public class DesignerStartupPageActivator extends Activator { private void startNonStartupPage() { StopWatch recorder = DesignerStartupContext.getRecorder(); - DesignerStartupPageUtil.enterWorkspace(); + try { + DesignerStartupPageUtil.enterWorkspace(); + } catch (Exception e) { + throw new RuntimeException(e); + } recordStartupEnd(recorder); } @@ -74,8 +81,8 @@ public class DesignerStartupPageActivator extends Activator { // 即时暂停 suspendRecorder(context); - - addMutable(ActivatorContext.KEY, activatorContext); + + Carina.getApplicationContext().group(ActivatorContextGroup.class).add(activatorContext); PreLoadService.getInstance().waitForUI(); @@ -159,7 +166,11 @@ public class DesignerStartupPageActivator extends Activator { DesignerStartupContext.getInstance().setOnWaiting(false); DesignerStartupContext.getInstance().setOnStartup(true); - DesignerStartupPageUtil.enterWorkspace(); + try { + DesignerStartupPageUtil.enterWorkspace(); + } catch (Exception e) { + throw new RuntimeException(e); + } } finally { UIUtil.invokeLaterIfNeeded(() -> { // 换到 awt 线程中关闭,不然异步会出现问题。 diff --git a/designer-realize/src/main/java/com/fr/start/module/optimized/TenantDBAdapter4Designer.java b/designer-realize/src/main/java/com/fr/start/module/optimized/TenantDBAdapter4Designer.java index 9321a56a97..e6d4bb1fd6 100644 --- a/designer-realize/src/main/java/com/fr/start/module/optimized/TenantDBAdapter4Designer.java +++ b/designer-realize/src/main/java/com/fr/start/module/optimized/TenantDBAdapter4Designer.java @@ -1,5 +1,8 @@ package com.fr.start.module.optimized; +import com.fanruan.carina.Carina; +import com.fanruan.dao.shell.DBContextShell; +import com.fr.config.BaseDBEnv; import com.fr.config.dao.DaoSelectorFactory; import com.fr.config.dao.swicter.DaoSwitcher; import com.fr.design.DesignerEnvManager; @@ -8,6 +11,7 @@ import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.event.Null; import com.fr.exit.ConfigToPropMigrator; +import com.fr.stable.db.DBContext; import com.fr.stable.db.tenant.TenantDBAdapter; import com.fr.start.event.LazyStartupEvent; import com.fr.start.server.EmbedServerEvent; @@ -21,6 +25,7 @@ public class TenantDBAdapter4Designer extends TenantDBAdapter { @Override public void start() { + BaseDBEnv.setDBContext((DBContext) Carina.getApplicationContext().singleton(DBContextShell.class).get()); if (DaoSelectorFactory.getDaoSelector().useCacheDao()) { listenEvent(LazyStartupEvent.INSTANCE, new Listener() { @Override diff --git a/designer-realize/src/main/java/com/fr/start/util/DesignerStartupPageUtil.java b/designer-realize/src/main/java/com/fr/start/util/DesignerStartupPageUtil.java index 2fd6abad93..a3902d20bd 100644 --- a/designer-realize/src/main/java/com/fr/start/util/DesignerStartupPageUtil.java +++ b/designer-realize/src/main/java/com/fr/start/util/DesignerStartupPageUtil.java @@ -1,7 +1,7 @@ package com.fr.start.util; -import com.fr.module.ModuleContext; -import com.fr.start.module.DesignerWorkspaceActivator; +import com.fanruan.carina.lifecycle.bootstrap.BootstrapFactory; + /** * created by Harrison on 2022/07/11 @@ -11,21 +11,16 @@ public class DesignerStartupPageUtil { /** * 进入工作目录 */ - public static void enterWorkspace() { - - ModuleContext - .getModule(DesignerWorkspaceActivator.class) - .start(); + public static void enterWorkspace() throws Exception { + BootstrapFactory.get().start("design_show"); + } /** * 退出工作目录 */ - public static void exitWorkspace() { - - ModuleContext - .getModule(DesignerWorkspaceActivator.class) - .stop(); + public static void exitWorkspace() throws Exception { + BootstrapFactory.get().stop("design_show"); } }