From e93e42ee4376465c53efbcaa6b54991e5eee9386 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 7 Jun 2024 11:30:03 +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=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=88=87=E6=8D=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boot/env/DesignEnvChooseComponent.java | 295 ++++++++++++++++++ .../fanruan/boot/env/DesignEnvComponent.java | 285 +++++++++++++++++ .../boot/env/DesignFunctionComponent.java | 41 +++ .../{show => env}/DesignPluginComponent.java | 6 +- ...onent.java => DesignPreLoadComponent.java} | 243 ++++++++++++--- .../init/DesignSerializationComponent.java | 9 +- .../boot/init/DesignWorkContextComponent.java | 52 ++- .../boot/init/DesignerInitComponent.java | 4 +- .../fanruan/boot/init/PreLoadComponent.java | 118 ------- .../fanruan/boot/init/XMLableComponent.java | 23 -- .../boot/pre/DesignConfigComponent.java | 31 -- .../pre/DesignPluginSupplementComponent.java | 27 -- .../boot/pre/DesignPreStartComponent.java | 114 +++++-- .../boot/pre/DesignTenantComponent.java | 51 --- .../boot/show/DesignConfConfigComponent.java | 39 --- .../show/DesignCoreSupplementalComponent.java | 47 --- .../fanruan/boot/show/DesignEnvComponent.java | 19 -- .../fanruan/boot/show/DesignFsComponent.java | 39 --- .../boot/show/DesignFunctionComponent.java | 24 -- .../boot/show/DesignLoggerComponent.java | 39 --- .../boot/show/DesignUpdateComponent.java | 19 -- .../boot/show/DesignWorkspaceComponent.java | 21 -- .../DesignWorkspaceRegisterComponent.java | 19 -- .../fanruan/boot/show/DesignerComponent.java | 24 -- .../boot/show/DesignerDaoComponent.java | 39 --- .../boot/show/DesignerShowComponent.java | 43 --- .../com/fanruan/fs/DesignFileRepository.java | 34 ++ .../fr/start/module/DesignerActivator.java | 2 +- .../start/util/DesignerStartupPageUtil.java | 23 +- 29 files changed, 1020 insertions(+), 710 deletions(-) create mode 100644 designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/boot/env/DesignFunctionComponent.java rename designer-realize/src/main/java/com/fanruan/boot/{show => env}/DesignPluginComponent.java (78%) rename designer-realize/src/main/java/com/fanruan/boot/init/{DesignerStartupComponent.java => DesignPreLoadComponent.java} (50%) delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/init/PreLoadComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/init/XMLableComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/pre/DesignConfigComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/pre/DesignPluginSupplementComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/pre/DesignTenantComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignConfConfigComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignCoreSupplementalComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignEnvComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignFsComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignFunctionComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignLoggerComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignUpdateComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignWorkspaceComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignWorkspaceRegisterComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignerComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignerDaoComponent.java delete mode 100644 designer-realize/src/main/java/com/fanruan/boot/show/DesignerShowComponent.java create mode 100644 designer-realize/src/main/java/com/fanruan/fs/DesignFileRepository.java diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java new file mode 100644 index 0000000000..7c4faa30ad --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvChooseComponent.java @@ -0,0 +1,295 @@ +package com.fanruan.boot.env; + +import com.fanruan.boot.key.StartupArgsShell; +import com.fanruan.carina.Carina; +import com.fanruan.carina.annotions.ActivatorRefer; +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.carina.lifecycle.bootstrap.BootUnit; +import com.fanruan.carina.lifecycle.bootstrap.BootstrapFactory; +import com.fr.base.operator.org.OrganizationOperator; +import com.fr.base.rpc.encrypt.EncryptOperator; +import com.fr.decision.service.context.ServiceContext; +import com.fr.design.DesignerEnvManager; +import com.fr.design.EnvChangeEntrance; +import com.fr.design.PluginClassRefreshManager; +import com.fr.design.constants.DesignerLaunchStatus; +import com.fr.design.editlock.ConnectionLockChangeChecker; +import com.fr.design.editlock.ServerTableDataLockChangeChecker; +import com.fr.design.env.DesignerWorkspaceGenerator; +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.plugin.remind.PluginErrorDesignReminder; +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.file.filetree.FileNodes; +import com.fr.form.share.ShareComponentOperator; +import com.fr.form.share.ShareEmbeddedConverter; +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.DesignContext; +import com.fr.start.module.StartupArgs; +import com.fr.value.NotNullLazyValue; +import com.fr.workspace.WorkContext; +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 org.jetbrains.annotations.NotNull; + +/** + * 环境选择模块 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/6/6 + */ +@FineComponent(name = "design_env_choose") +public class DesignEnvChooseComponent { + private Listener beforeSwitch4Min = new Listener(Integer.MIN_VALUE) { + + @Override + public void on(Event event, Workspace current) { + try { + BootstrapFactory.get().stop("design_env_prepare"); + BootstrapFactory.get().resetStatus("design_env_prepare", BootUnit.State.SUPPLEMENTED); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }; + private Listener afterSwitch4Max = new Listener(Integer.MAX_VALUE) { + + @Override + public void on(Event event, Workspace current) { + try { + BootstrapFactory.get().start("design_function"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }; + 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(); + } + }; + + + private NotNullLazyValue startupArgs = new NotNullLazyValue() { + @NotNull + @Override + protected StartupArgs compute() { + return Carina.getApplicationContext().singleton(StartupArgsShell.class).get(); + } + }; + + @Start + public void start() { + registerEnvListener(); + startEnvChoose(); + afterAllStart(); + } + + + @Stop + public void stop() { + editLockCheckerStop(); + stopListen(); + } + + + @Supplemental + public void prepare() { + supplemental(); + } + + /** + * ----------------------------------------private------------------------------------------ + */ + + private void afterAllStart() { + DesignerLaunchStatus.setStatus(DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE); + } + + + private void startEnvChoose() { + //检查环境 + DesignerEnvManager.checkNameEnvMap(); + + if (startupArgs.getValue().isDemo()) { + DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); + } else { + DesignerWorkspaceInfo workspaceInfo = null; + 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) { + EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(null, workspaceInfo); + } else { + WorkContext.switchTo(workspace); + } + } catch (Throwable e) { + EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(e, workspaceInfo); + } + } + pluginErrorRemind(); + editLockCheckerStart(); + } + + /** + * 注册切换环境前后事件监听 + */ + private void registerEnvListener() { + + /*切换环境前,关闭所有相关模块,最后执行*/ + EventDispatcher.listen(WorkspaceEvent.BeforeSwitch, beforeSwitch4Min); + /*切换环境后,重新启动所有相关模块,最先执行*/ + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, afterSwitch4Max); + /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ + EventDispatcher.listen(WorkspaceEvent.BeforeSwitch, beforeSwitch4Max); + + /*切换环境后,装载一下打开的所有文件对象,优先级低于默认优先级,要后于 启动相关模块部分 被触发*/ + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, afterSwitch4Min); + } + + private void editLockCheckerStart() { + ConnectionLockChangeChecker.getInstance().start(); + ServerTableDataLockChangeChecker.getInstance().start(); + } + + private void pluginErrorRemind() { + EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener() { + @Override + public void on(Event event, Null aNull) { + PluginErrorDesignReminder.getInstance().remindStartFailedPlugins(); + PluginErrorDesignReminder.getInstance().remindInvalidatePlugins(); + } + }); + } + + private void editLockCheckerStop() { + ConnectionLockChangeChecker.getInstance().stop(); + ServerTableDataLockChangeChecker.getInstance().stop(); + } + + private void supplemental() { + 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())); + } + + + private void stopListen() { + EventDispatcher.stopListen(beforeSwitch4Max); + EventDispatcher.stopListen(beforeSwitch4Min); + EventDispatcher.stopListen(afterSwitch4Min); + EventDispatcher.stopListen(afterSwitch4Max); + } + +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java new file mode 100644 index 0000000000..3218172853 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java @@ -0,0 +1,285 @@ +package com.fanruan.boot.env; + +import com.fanruan.boot.FSProperties; +import com.fanruan.boot.LoggerProperties; +import com.fanruan.boot.mem.MemConfigRepositoryBuilder; +import com.fanruan.carina.Carina; +import com.fanruan.carina.annotions.FineComponent; +import com.fanruan.carina.annotions.JPAEntityScan; +import com.fanruan.carina.annotions.Start; +import com.fanruan.carina.annotions.Stop; +import com.fanruan.carina.annotions.Supplemental; +import com.fanruan.config.ConfigProviderFactory; +import com.fanruan.config.realm.ConfigRealm; +import com.fanruan.dao.context.DBContextProvider; +import com.fanruan.dao.context.DBContextStarter; +import com.fanruan.dao.encryption.EncryptionInitializationProvider; +import com.fanruan.dao.encryption.singleton.EncryptionInitializationProviderSingleton; +import com.fanruan.dao.property.DBPropertyProvider; +import com.fanruan.dao.shell.DBContextShell; +import com.fanruan.dao.shell.DBPropertyShell; +import com.fanruan.fs.DesignFileRepository; +import com.fanruan.fs.FSConstants; +import com.fanruan.fs.FileServer; +import com.fanruan.fs.RepositoryFactory; +import com.fanruan.fs.repository.local.LocalFileRepository; +import com.fr.cbb.dialect.security.InsecurityElementFactory; +import com.fr.config.BaseDBEnv; +import com.fr.config.ConfigContext; +import com.fr.config.ConfigEvent; +import com.fr.config.FinalPreferenceConfig; +import com.fr.config.dao.DaoContext; +import com.fr.config.dao.impl.BatchSubmitClassHelperDao; +import com.fr.config.dao.impl.BatchSubmitEntityDao; +import com.fr.config.dao.impl.BatchSubmitXmlEntityDao; +import com.fr.config.dao.impl.hibernate.HibernateClassHelperDao; +import com.fr.config.dao.impl.hibernate.HibernateEntityDao; +import com.fr.config.dao.impl.hibernate.HibernateXmlEnityDao; +import com.fr.config.dao.impl.remote.RemoteClassHelperDao; +import com.fr.config.dao.impl.remote.RemoteEntityDao; +import com.fr.config.dao.impl.remote.RemoteXmlEntityDao; +import com.fr.config.impl.ConfConfigProviderImpl; +import com.fr.config.impl.ConfigInsecurityElementProviderImpl; +import com.fr.decision.service.context.ServiceContext; +import com.fr.env.detect.EnvDetectorCenter; +import com.fr.event.EventDispatcher; +import com.fr.general.FRLogger; +import com.fr.general.log.Log4jUtils; +import com.fr.io.base.ResourcePaths; +import com.fr.io.repository.ResourceRepository; +import com.fr.io.repository.ResourceRepositoryWrapper; +import com.fr.io.utils.ResourceIOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.properties.encryption.EncryptionInitialization; +import com.fr.security.encryption.core.EncryptionScaffold; +import com.fr.security.encryption.provider.SecuritySeedProvider; +import com.fr.security.encryption.storage.keys.LoadSeedSecurityKey; +import com.fr.stable.CarinaGraphDrawHelper; +import com.fr.stable.CoreGraphDrawServiceImpl; +import com.fr.stable.StringUtils; +import com.fr.stable.db.DBContext; +import com.fr.stable.db.properties.FineMicroServicesDBProperties; +import com.fr.stable.project.ProjectConstants; +import com.fr.transaction.Configurations; +import com.fr.transaction.FineConfigurationHelper; +import com.fr.transaction.HibernateTransactor; +import com.fr.transaction.RemoteTransactor; +import com.fr.transaction.TransactorFactory; +import com.fr.workspace.WorkContext; + +import java.net.URI; +import java.util.Objects; + +/** + * 设计器env模块,环境切换的底层模块 + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/6/7 + */ +@FineComponent(name = "design_env_prepare") +@JPAEntityScan("com.fr.config.entity") +public class DesignEnvComponent { + + @Supplemental + public void supplemental() { + supplementalCorePrepare(); + } + + + + + @Start + public void start() throws Exception { + // 1.环境准备 + startEnvPrepare(); + // 2.core准备 + startCorePrepare(); + // 3.dao启动 + startDao(); + // 4.config启动 + startConfConfig(); + // 5.fileServer启动 + startFileServer(); + // 6.logger启动 + startLogger(); + } + + + + @Stop + public void stop() { + stopLogger(); + stopFileServer(); + stopConfConfig(); + stopDao(); + stopCorePrepare(); + stopEnvPrepare(); + } + + + /** + * -------------------private------------------- + */ + + + /** + * ----------- logger -------- + */ + private void startLogger() { + String realPath = Carina.properties(LoggerProperties.class).getXml(); + URI uri = Log4jUtils.buildUserConfigURI(realPath); + FRLogger.getLogger().config(uri); + } + + private void stopLogger() { + FRLogger.getLogger().stop(); + } + + /** + * ----------- file-server -------- + */ + private void startFileServer() throws Exception { + if (WorkContext.getCurrent().isLocal()) { + // 设计器远程下不需要文件系统,走PublicRepo的接口,本地下走基础的磁盘读写 + LocalFileRepository localFileRepository = LocalFileRepository.getSingleton(); + ResourceRepository realRepo = RepositoryFactory.getRepo(); + FSProperties fsProperties = Carina.properties(FSProperties.class); + FileServer.init( + new ResourceRepositoryWrapper(localFileRepository, StringUtils.EMPTY), + new ResourceRepositoryWrapper(realRepo, Carina.getApplicationContext().getMainServletName()), + new ResourceRepositoryWrapper(realRepo, FSConstants.PUBLIC_NAMESPACE), + new ResourceRepositoryWrapper(realRepo.generateTenantsSharedRepo(fsProperties.getTenantsSharedNamespace()), StringUtils.EMPTY)); + + if (StringUtils.isEmpty(fsProperties.getPath()) && Objects.equals(fsProperties.getType(), FSConstants.LOCAL_ENV)) { + fsProperties.setPath(Carina.getApplicationContext().getWebInfPath()); + } + + ResourceIOUtils.setUnderlying(FileServer.local()); + ResourceIOUtils.setIsolationMode(false); + + ResourcePaths.register(ProjectConstants.ASSETS_NAME, true); + ResourcePaths.register(ProjectConstants.SCHEDULE_NAME, false); + } else { + DesignFileRepository repository = new DesignFileRepository(); + FSProperties fsProperties = Carina.properties(FSProperties.class); + FileServer.init(repository, repository, repository, repository.generateTenantsSharedRepo(fsProperties.getTenantsSharedNamespace())); + } + } + + private void stopFileServer() { + ResourceIOUtils.setUnderlying(FileServer.local()); + ResourceIOUtils.setIsolationMode(true); + } + + /** + * -----------dao--------- + */ + private void startDao() { + if (WorkContext.getCurrent().isLocal()) { + // 类似com.fr.config.activator.BaseDBActivator.start里的逻辑 + EncryptionInitializationProvider initializationProvider = Carina.getApplicationContext().singleton(EncryptionInitializationProviderSingleton.class).get(); + if (initializationProvider != null) { + initializationProvider.init(); + } else { + throw new IllegalStateException("no EncryptionInitializationProvider implementation found, this may cause encryption exception."); + } + + DBPropertyProvider dbPropertyProvider = FineMicroServicesDBProperties.getInstance().from(Carina.getApplicationContext().getCarinaApplicationProperties()); + DBContextProvider dbContextProvider = new DBContextStarter(dbPropertyProvider).start(); + + + ServiceContext.singleton(DBPropertyShell.class).set(dbPropertyProvider); + ServiceContext.singleton(DBContextShell.class).set(dbContextProvider); + + + // 这里等另外的模块DBPropertyComponent启动,并且注入后这里的api实例才能安排 + + FineLoggerFactory.getLogger().info("[StateServiceCommon] dao service common started."); + } + } + private void stopDao() { + FineMicroServicesDBProperties.getInstance().clear(); + } + + + /** + * ---------- confconfig ------- + */ + + private void startConfConfig() { + BaseDBEnv.setDBContext((DBContext) Carina.getApplicationContext().singleton(DBContextShell.class).get()); + if (!WorkContext.getCurrent().isLocal()) { + TransactorFactory.setTransactor(new RemoteTransactor()); + //远程 + DaoContext.setXmlEntityDao(new RemoteXmlEntityDao()); + DaoContext.setClassHelperDao(new RemoteClassHelperDao()); + DaoContext.setEntityDao(new RemoteEntityDao()); + } else { + //本地 + TransactorFactory.setTransactor(new HibernateTransactor()); + DaoContext.setClassHelperDao(new BatchSubmitClassHelperDao(new HibernateClassHelperDao())); + DaoContext.setEntityDao(new BatchSubmitEntityDao(new HibernateEntityDao())); + DaoContext.setXmlEntityDao(new BatchSubmitXmlEntityDao(new HibernateXmlEnityDao())); + } + ConfConfigProviderImpl confConfigProvider = new ConfConfigProviderImpl(); + ConfigProviderFactory.getInstance().registerProvider(ConfigRealm.SERVICE, confConfigProvider); + Configurations.setHelper(new FineConfigurationHelper()); + EventDispatcher.fire(ConfigEvent.READY); + // 固化一些配置 + FinalPreferenceConfig.solidify(); + InsecurityElementFactory.setConfigInsecurityElementProvider(ConfigInsecurityElementProviderImpl.INSTANCE); + } + + + private void stopConfConfig() { + DaoContext.setClassHelperDao(null); + DaoContext.setEntityDao(null); + DaoContext.setXmlEntityDao(null); + Configurations.setHelper(null); + } + + /** + * --------- core-supplemental -------- + */ + + private void supplementalCorePrepare() { + Carina.getApplicationContext().singleton(EncryptionInitializationProviderSingleton.class).set(EncryptionInitialization.getInstance()); + } + + + private void startCorePrepare() { + EncryptionScaffold.setSecuritySeedProvider(new SecuritySeedProvider() { + @Override + public byte[] getSeed() { + return LoadSeedSecurityKey.getInstance().loadSeedFile(); + } + + @Override + public void resetSeed() { + LoadSeedSecurityKey.getInstance().reset(); + } + }); + LoadSeedSecurityKey.getInstance().init(); + CarinaGraphDrawHelper.getInstance().registerGraphDrawHelper(new CoreGraphDrawServiceImpl()); + } + + private void stopCorePrepare() { + EncryptionScaffold.setSecuritySeedProvider(new SecuritySeedProvider() {}); + LoadSeedSecurityKey.getInstance().reset(); + } + + + + /** + * --------- EnvPrepare --------- + */ + + private void stopEnvPrepare() { + EnvDetectorCenter.getInstance().destroy(); + } + + private void startEnvPrepare() { + EnvDetectorCenter.getInstance().init(); + } +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/DesignFunctionComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignFunctionComponent.java new file mode 100644 index 0000000000..16f77d0f89 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignFunctionComponent.java @@ -0,0 +1,41 @@ +package com.fanruan.boot.env; + +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.data.DatasourceActivator; +import com.fr.design.chart.ChartDesignerActivator; +import com.fr.design.mainframe.app.DesignerAppActivator; +import com.fr.design.record.analyzer.DesignerAnalyzerActivator; +import com.fr.form.module.FormBaseActivator; +import com.fr.report.module.ReportBaseActivator; +import com.fr.start.module.DesignerActivator; +import com.fr.start.module.DesignerESDActivator; +import com.fr.start.module.optimized.DesignUpdateActivator; +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_plugin"}) +@ActivatorRefer(refer = { + DesignUpdateActivator.class, + DatasourceActivator.class, + ChartBaseActivator.class, + ReportBaseActivator.class, + VcsFolderManagerActivator.class, + FormBaseActivator.class, + DesignerActivator.class, + DesignerAppActivator.class, + ChartDesignerActivator.class, + DesignerESDActivator.class, + DesignerAnalyzerActivator.class}) +public class DesignFunctionComponent { +} diff --git a/designer-realize/src/main/java/com/fanruan/boot/show/DesignPluginComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java similarity index 78% rename from designer-realize/src/main/java/com/fanruan/boot/show/DesignPluginComponent.java rename to designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java index 2b09d85c3f..f395fc9c88 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignPluginComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/DesignPluginComponent.java @@ -1,4 +1,4 @@ -package com.fanruan.boot.show; +package com.fanruan.boot.env; import com.fanruan.boot.PluginComponent; import com.fanruan.carina.annotions.DependsOn; @@ -8,14 +8,14 @@ import com.fanruan.carina.annotions.Start; import javax.servlet.ServletContext; /** - * 设计器插件模块 + * 设计器插件模块,环境切换的中间模块 * * @author Destiny.Lin * @since 11.0 * Created on 2024/5/17 */ @FineComponent(name = "design_plugin") -@DependsOn(dependencies = {"design_core_supplemental", "design_dao", "design_conf_config", "design_logger"}) +@DependsOn(dependencies = {"design_env_prepare"}) public class DesignPluginComponent extends PluginComponent { /** diff --git a/designer-realize/src/main/java/com/fanruan/boot/init/DesignerStartupComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java similarity index 50% rename from designer-realize/src/main/java/com/fanruan/boot/init/DesignerStartupComponent.java rename to designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java index fc48f1e7ed..cc9b9db46d 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/init/DesignerStartupComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/init/DesignPreLoadComponent.java @@ -1,14 +1,20 @@ package com.fanruan.boot.init; +import com.fanruan.boot.ClassFindComponent; +import com.fanruan.boot.ExtraLocaleClassManager; +import com.fanruan.boot.key.StartupArgsShell; 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.carina.annotions.Supplemental; +import com.fanruan.plugin.autonomy.AutonomyClassManagerGroup; import com.fanruan.product.BuildContext; +import com.fanruan.product.ProductConstants; import com.fr.base.OptimizeUtil; import com.fr.config.dao.DaoSelectorFactory; import com.fr.config.dao.PropertiesConstants; +import com.fr.decision.service.context.ServiceContext; import com.fr.decision.webservice.v10.encryption.EncryptionConstants; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; @@ -16,53 +22,60 @@ 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.FRLogger; +import com.fr.general.FrontProviderImpl; import com.fr.general.GeneralContext; +import com.fr.general.I18nActivator; +import com.fr.general.Inter; +import com.fr.general.InterProviderImpl; +import com.fr.invoke.ClassFactory; +import com.fr.license.function.VT4FR; +import com.fr.locale.InterMutableKey; import com.fr.log.FineLoggerFactory; +import com.fr.measure.DBMeterFactory; +import com.fr.record.DefaultDBMeter; import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.Metrics; import com.fr.stable.ArrayUtils; +import com.fr.stable.CommonUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.stable.xml.StableXMLUtils; 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 com.fr.workspace.WorkContext; import org.jetbrains.annotations.NotNull; +import javax.servlet.ServletContext; import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; import java.util.concurrent.TimeUnit; /** - * 设计器启动检查模块 - *

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

+ * 设计器启动时的准备加载阶段 * * @author Destiny.Lin * @since 11.0 - * Created on 2024/5/24 + * Created on 2024/6/7 */ @EnableMetrics -@FineComponent(name = "design_start_up") -public class DesignerStartupComponent { +@FineComponent(name = "design_load") +public class DesignPreLoadComponent { private NotNullLazyValue startupArgsValue = new NotNullLazyValue() { @NotNull @@ -72,6 +85,174 @@ public class DesignerStartupComponent { } }; + @Supplemental + public void supplemental() { + supplementalI18n(); + } + + + + /** + * start + */ + @Start + @Metrics + public void start() { + // 1.清理临时文件+监听 + startPreLoad(); + // 2.ClassFactory注册finder + startClass(); + // 3.国际化 + startI18n(); + } + + + /** + * stop + */ + @Stop + public void stop() { + stopClass(); + stopLog(); + } + + + /** + * ---------------------private----------------------- + */ + + private void startI18n() { + // 扫描默认路径 + I18nActivator.registerI18N(new ArrayList<>(ServiceContext.group(InterMutableKey.class).getAll())); + FrontProviderImpl.init(InterProviderImpl.getInstance()); + } + + + private void supplementalI18n() { + // 国际化插件class自定义管理 + Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).add(new ExtraLocaleClassManager()); + } + + private void stopClass() { + ClassFactory.getInstance().clear(); + } + + private void startClass() { + ClassFactory.getInstance().addFinder(className -> { + File clssesFile = new File(CommonUtils.pathJoin(System.getProperty("carina.home"), + ProjectConstants.CLASSES_NAME)); + ClassLoader urlClassLoader; + try { + urlClassLoader = new URLClassLoader(new URL[]{clssesFile.toURI().toURL()}, ClassFindComponent.class.getClassLoader()); + } catch (MalformedURLException malformedURLException) { + urlClassLoader = ClassLoader.getSystemClassLoader(); + } + return Class.forName(className, true, urlClassLoader); + }); + + ClassFactory.getInstance().addFinder(className -> { + //再找. + // alex:currentEnv可能是null + String envPath = WorkContext.getCurrent().getPath(); + if (envPath == null) { + throw new ClassNotFoundException(className); + } + File clssesFile = new File(StableUtils.pathJoin(envPath, ProjectConstants.CLASSES_NAME)); + ClassLoader urlClassLoader; + try { + urlClassLoader = new URLClassLoader(new URL[]{clssesFile.toURI().toURL()}, StableUtils.class.getClassLoader()); + } catch (MalformedURLException malformedURLException) { + urlClassLoader = ClassLoader.getSystemClassLoader(); + } + return Class.forName(className, true, urlClassLoader); + }); + } + + + @SuppressWarnings("all") + private void startPreLoad() { + try { + beforeAllStart(); + //清空临时文件 + TmpFileUtils.cleanUpInnerTmpFiles(); + RestartHelper.deleteRecordFilesWhenStart(); + CloudCenter.getInstance(); + // 创建监听服务 + DesignUtils.createListeningServer(DesignUtils.getPort(), startFileSuffix()); + // 在插件引擎模块起来前 初始化下插件接口监听 + TemplateResourceManager.getResource(); + initLanguage(); + // 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()); + } + + 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); + } + } + } + } + + + /** * start准备 */ @@ -121,28 +302,6 @@ public class DesignerStartupComponent { } - /** - * 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 是否可用 @@ -174,13 +333,7 @@ public class DesignerStartupComponent { } - /** - * stop - */ - @Stop - public void stop() { - // void - } + private void initLanguage() { //这两句的位置不能随便调换,因为会影响语言切换的问题 diff --git a/designer-realize/src/main/java/com/fanruan/boot/init/DesignSerializationComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/DesignSerializationComponent.java index 8a2d2fe118..647e63ec57 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/init/DesignSerializationComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/init/DesignSerializationComponent.java @@ -4,21 +4,20 @@ package com.fanruan.boot.init; 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.register.XMLableActivator; 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}) +@DependsOn(dependencies = {"design_load"}) +@ActivatorRefer(refer = {SerializationActivator.class, JsonSerializationActivator.class, XMLableActivator.class}) public class DesignSerializationComponent { } diff --git a/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java index 683a3c9974..49fef0bd5e 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/init/DesignWorkContextComponent.java @@ -6,15 +6,25 @@ 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.plugin.autonomy.AutonomyClassManagerGroup; import com.fanruan.workplace.http.RepositoryManager; import com.fanruan.workplace.http.WorkspaceHeartBeatShell; import com.fanruan.workplace.standard.ServerInfo; import com.fanruan.workplace.standard.ServerInfoOperator; +import com.fr.base.operator.common.CommonOperator; +import com.fr.data.operator.DataOperator; +import com.fr.data.operator.DataOperatorProvider; import com.fr.decision.service.context.ServiceContext; import com.fr.design.env.HttpWorkspaceConnector; +import com.fr.env.operator.CommonOperatorImpl; +import com.fr.file.filetree.FileNodes; +import com.fr.file.filetree.LocalFileNodes; import com.fr.security.encryption.storage.StorageEncryptors; import com.fr.security.encryption.storage.StorageTransfer; import com.fr.stable.StringUtils; +import com.fr.stable.script.ExtraFunctionManager; +import com.fr.web.core.ExtraRequestCMDReceiverManager; +import com.fr.web.core.ExtraServiceManager; import com.fr.workspace.WorkContext; import com.fr.workspace.base.WorkspaceKey; import com.fr.workspace.engine.FineWorkspaceFactory; @@ -27,8 +37,10 @@ import com.fr.workspace.pool.WorkRPCRegister; import com.fr.workspace.pool.WorkRPCType; import com.fr.workspace.resource.WorkResource; import com.fr.workspace.server.repository.authority.RemoteAuthorityRepository; +import com.fr.workspace.server.repository.compatible.register.CompatibleRegister; import com.fr.workspace.server.repository.connect.RemoteNetworkRepository; import com.fr.workspace.server.repository.connection.ConnectionRepository; +import com.fr.workspace.server.repository.resource.PublicResourceRepository; import com.fr.workspace.server.repository.resource.WorkResourceRepository; import com.fr.workspace.server.repository.system.SystemInfoRepository; import com.fr.workspace.server.repository.tabledata.TableDataRepository; @@ -37,14 +49,14 @@ import com.fr.workspace.server.repository.vcs.VcsRepository; import com.fr.workspace.server.repository.widget.ShareRepository; /** - * 设计器工作环境调用类初始化模块,主要负责将各个模块注册的方法注入进来 + * 设计器工作空间构建模块 * * @author Destiny.Lin * @since 11.0 - * Created on 2024/5/28 + * Created on 2024/6/7 */ -@FineComponent(name = "design_workcontext") -@DependsOn(dependencies = {"design_pre_load", "i18n", "class", "design_serialization"}) +@FineComponent(name = "design_work_context") +@DependsOn(dependencies = "design_serialization") public class DesignWorkContextComponent { private static final String VERSION_NUM = "01"; @@ -55,15 +67,11 @@ public class DesignWorkContextComponent { */ @Supplemental public void prepare() { - Carina.getApplicationContext().singleton(WorkspaceHeartBeatShell.class).set(new FineWorkspaceHeartbeat()); - 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()) - ); + supplementalExtra(); + supplementalCommon(); } + /** * start */ @@ -78,12 +86,13 @@ public class DesignWorkContextComponent { RepositoryManager.getInstance().pureRegisterRepo4Start(VcsRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(ShareRepository.getInstance()); RepositoryManager.getInstance().pureRegisterRepo4Start(WorkResourceRepository.getInstance()); + RepositoryManager.getInstance().pureRegisterRepo4Start(PublicResourceRepository.getInstance()); RepositoryManager.getInstance().initLocalRepository(); for (WorkRPCRegister workRPCRegister : ServiceContext.group(WorkspaceKey.class).getAll()) { validate(workRPCRegister.getClazz()); FineObjectPool.getInstance().add(workRPCRegister.getClazz(), workRPCRegister.getType(), workRPCRegister.getObject()); } - + CompatibleRegister.registerCompatibleEnv(); WorkContext.setConnector(HttpWorkspaceConnector.getInstance()); WorkContext.setFactory(FineWorkspaceFactory.getInstance()); @@ -113,4 +122,23 @@ public class DesignWorkContextComponent { return; } } + + private void supplementalCommon() { + Carina.getApplicationContext().singleton(WorkspaceHeartBeatShell.class).set(new FineWorkspaceHeartbeat()); + Carina.getApplicationContext().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()), + WorkRPCRegister.wrap(WorkRPCType.Local, FileNodes.class, new LocalFileNodes()), + WorkRPCRegister.wrap(CommonOperator.class, new CommonOperatorImpl()), + WorkRPCRegister.wrap(DataOperatorProvider.class, new DataOperator()) + ); + } + + private void supplementalExtra() { + Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).add(new ExtraRequestCMDReceiverManager()); + Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).add(new ExtraServiceManager()); + Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).add(new ExtraFunctionManager()); + } } diff --git a/designer-realize/src/main/java/com/fanruan/boot/init/DesignerInitComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/DesignerInitComponent.java index c3e7b58209..bfed6c5c22 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/init/DesignerInitComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/init/DesignerInitComponent.java @@ -9,14 +9,14 @@ 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_workcontext", "design_xml", "design_serialization"}) +@DependsOn(dependencies = {"design_work_context"}) @ActivatorRefer(refer = { DesignerInitActivator.class, DesignerStartupPageActivator.class, diff --git a/designer-realize/src/main/java/com/fanruan/boot/init/PreLoadComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/PreLoadComponent.java deleted file mode 100644 index 58ad495620..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/init/PreLoadComponent.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.fanruan.boot.init; - -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/init/XMLableComponent.java b/designer-realize/src/main/java/com/fanruan/boot/init/XMLableComponent.java deleted file mode 100644 index 0ce231b34b..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/init/XMLableComponent.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.fanruan.boot.init; - - -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/pre/DesignConfigComponent.java b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignConfigComponent.java deleted file mode 100644 index 6282d0c85b..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignConfigComponent.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.fanruan.boot.pre; - -import com.fanruan.carina.annotions.FineComponent; -import com.fanruan.carina.annotions.Start; -import com.fanruan.config.ConfigProviderFactory; -import com.fanruan.config.impl.PublicConfigProviderImpl; -import com.fanruan.config.impl.ShareConfigProviderImpl; -import com.fanruan.config.realm.ConfigRealm; -import com.fanruan.config.realm.ConfigRepositoryFactory; -import com.fanruan.boot.mem.MemConfigRepositoryBuilder; - -/** - * 设计器configprovider注册 - * - * @author Destiny.Lin - * @since 11.0 - * Created on 2024/5/29 - */ -@FineComponent(name = "design_universal_config") -public class DesignConfigComponent { - - /** - * start,注册config并设置基础的memConfigBuilder - */ - @Start - public void start() { - ConfigProviderFactory.getInstance().registerProvider(ConfigRealm.SHARE, new ShareConfigProviderImpl()); - ConfigProviderFactory.getInstance().registerProvider(ConfigRealm.PUBLIC, new PublicConfigProviderImpl()); - ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new MemConfigRepositoryBuilder()); - } -} diff --git a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPluginSupplementComponent.java b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPluginSupplementComponent.java deleted file mode 100644 index 62cd3eca3d..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPluginSupplementComponent.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.fanruan.boot.pre; - -import com.fanruan.boot.PluginComponent; -import com.fanruan.carina.annotions.DependsOn; -import com.fanruan.carina.annotions.FineComponent; -import com.fanruan.carina.annotions.Start; -import com.fanruan.carina.annotions.Supplemental; - -/** - * 设计器需要先注册setCarinaPluginProvider,才能做具体的EnvManager的加载 - * - * @author Destiny.Lin - * @since 11.0 - * Created on 2024/5/31 - */ -@FineComponent(name = "design_plugin_supplement") -@DependsOn(dependencies = {"design_tenant", "design_universal_config"}) -public class DesignPluginSupplementComponent extends PluginComponent { - - /** - * start - */ - @Start - public void start() { - super.prepare(); - } -} diff --git a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java index ede19bfe1d..e4db0280b9 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignPreStartComponent.java @@ -1,17 +1,19 @@ package com.fanruan.boot.pre; import com.fanruan.boot.key.StartupArgsShell; +import com.fanruan.boot.mem.MemConfigRepositoryBuilder; 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.Supplemental; -import com.fanruan.carina.context.CarinaApplicationContext; import com.fanruan.carina.lifecycle.bootstrap.BootstrapFactory; -import com.fanruan.carina.standard.PartitionManager; -import com.fanruan.carina.standard.PartitionManagerImpl; -import com.fr.base.StateHubContext; +import com.fanruan.config.ConfigProviderFactory; +import com.fanruan.config.impl.PublicConfigProviderImpl; +import com.fanruan.config.impl.ShareConfigProviderImpl; +import com.fanruan.config.realm.ConfigRealm; +import com.fanruan.config.realm.ConfigRepositoryFactory; import com.fr.base.function.UITerminator; +import com.fr.carina.revert.CarinaRevertManager; +import com.fr.carina.revert.provider.CarinaPluginProvider; import com.fr.design.DesignerEnvManager; import com.fr.design.deeplink.DeepLinkManager; import com.fr.design.fun.OemProcessor; @@ -26,38 +28,58 @@ 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.plugin.ExtraClassManager; import com.fr.runtime.FineRuntime; +import com.fr.stable.fun.ResourcePathTransformer; import com.fr.stable.lifecycle.FineLifecycleFatalError; -import com.fr.start.DesignContext; -import com.fr.start.DesignLauncher; +import com.fr.stable.plugin.ExtraClassManagerProvider; +import com.fr.stable.resource.ResourceLoader; import com.fr.start.DesignerSubListener; -import com.fr.start.EmptyServletContext; import com.fr.start.LifecycleFatalErrorHandler; import com.fr.start.OemHandler; import com.fr.start.SplashContext; import com.fr.start.SplashStrategy; import com.fr.start.common.SplashCommon; import com.fr.start.preload.PreLoadService; - +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 com.fr.web.controller.common.FileContentModificator; +import com.fr.web.controller.plugin.PluginFileContentModificator; +import com.fr.web.file.FileContentProcessorFactory; + +import javax.servlet.http.HttpServletRequest; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; import java.util.concurrent.CompletableFuture; /** - * 设计器启动前处理的模块入口 + * 设计器启动前准备模块 * * @author Destiny.Lin * @since 11.0 - * Created on 2024/5/31 + * Created on 2024/6/7 */ @FineComponent(name = "design_pre_start") -@DependsOn(dependencies = {"design_universal_config", "design_tenant", "design_plugin_supplement"}) public class DesignPreStartComponent { - - /** - * start - */ @Start public void start() { + // 1.注册ConfigFactory与对应的membuilder + startUniversalConfig(); + // 2.start本地租户配置 + startTenant(); + // 3.pluginPrepare,注册插件的反向依赖 + startPluginPrepare(); + // 4.正式启动 + startPre(); + } + + private void startPre() { DesignerEnvManager.getEnvManager(); startPreload0(); @@ -85,6 +107,63 @@ public class DesignPreStartComponent { } } + private void startPluginPrepare() { + CarinaRevertManager.setCarinaPluginProvider(new CarinaPluginProvider() { + @Override + public InputStream getResourceAsStream(String name, Class caller) { + return ResourceLoader.getResourceAsStream(name, caller); + } + + @Override + public String transformPath(String path) { + Set set = getResourcePathTransformers(); + for (ResourcePathTransformer transformer : set) { + if (transformer.accept(path)) { + return transformer.transform(path); + } + } + return path; + } + + @Override + public String dealWithFileContentModificator(String content, HttpServletRequest req, String path) { + String modifiedContent = FileContentProcessorFactory.getInstance().modify(content, path, req); + FileContentModificator pluginFileContentModificator = new PluginFileContentModificator(); + if (pluginFileContentModificator.accept(req, path)) { + return pluginFileContentModificator.modify(modifiedContent, req, path); + } + return modifiedContent; + } + + private Set getResourcePathTransformers() { + Set set = new HashSet<>(); + ExtraClassManagerProvider provider = ExtraClassManager.getInstance(); + if (provider != null) { + Set pluginProvided = provider.getArray(ResourcePathTransformer.MARK_STRING); + set.addAll(pluginProvided); + } + return set; + } + }); + } + + private void startTenant() { + TenantContext.registerStorage(new DefaultTenantStorage()); + TenantContext.registerConfigProvider(new TenantConfigProvider() { + @Override + public boolean isMultiTenantOpen() { + return false; + } + }); + PlatformScaffoldTenantStarter.start(new ArrayList<>(Carina.getApplicationContext().group(CurrentTenantKey.class).getAll())); + } + + private void startUniversalConfig() { + ConfigProviderFactory.getInstance().registerProvider(ConfigRealm.SHARE, new ShareConfigProviderImpl()); + ConfigProviderFactory.getInstance().registerProvider(ConfigRealm.PUBLIC, new PublicConfigProviderImpl()); + ConfigRepositoryFactory.getInstance().registerConfigRepositoryBuilder(new MemConfigRepositoryBuilder()); + } + /** @@ -149,5 +228,4 @@ public class DesignPreStartComponent { return new SplashCommon(); } - } diff --git a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignTenantComponent.java b/designer-realize/src/main/java/com/fanruan/boot/pre/DesignTenantComponent.java deleted file mode 100644 index fa38d30d3c..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/pre/DesignTenantComponent.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.fanruan.boot.pre; - -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 = {}) -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/show/DesignConfConfigComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignConfConfigComponent.java deleted file mode 100644 index 83fbf29743..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignConfConfigComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.fanruan.boot.show; - -import com.fanruan.boot.ConfConfigComponent; -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/show/DesignCoreSupplementalComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignCoreSupplementalComponent.java deleted file mode 100644 index e6679d43ef..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignCoreSupplementalComponent.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.fanruan.boot.show; - -import com.fanruan.boot.CoreSupplementalComponent; -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/show/DesignEnvComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignEnvComponent.java deleted file mode 100644 index bc1313d978..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignEnvComponent.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fanruan.boot.show; - -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/show/DesignFsComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignFsComponent.java deleted file mode 100644 index 43555a7fbb..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignFsComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.fanruan.boot.show; - -import com.fanruan.boot.FileServerComponent; -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.fs.FileServer; -import com.fr.io.utils.ResourceIOUtils; - -/** - * 设计器文件系统初始化 - * - * @author Destiny.Lin - * @since 11.0 - * Created on 2024/6/4 - */ -@FineComponent(name = "design_fs") -@DependsOn(dependencies = {"design_conf_config"}) -public class DesignFsComponent extends FileServerComponent { - - /** - * start - */ - @Start - public void start() throws Exception { - super.start(); - } - - - /** - * start - */ - @Stop - private void stop() { - ResourceIOUtils.setUnderlying(FileServer.local()); - ResourceIOUtils.setIsolationMode(true); - } -} diff --git a/designer-realize/src/main/java/com/fanruan/boot/show/DesignFunctionComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignFunctionComponent.java deleted file mode 100644 index 379d507c51..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignFunctionComponent.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.fanruan.boot.show; - -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.data.DatasourceActivator; -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 = {DatasourceActivator.class, ChartBaseActivator.class, ReportBaseActivator.class, VcsFolderManagerActivator.class, FormBaseActivator.class}) -public class DesignFunctionComponent { -} diff --git a/designer-realize/src/main/java/com/fanruan/boot/show/DesignLoggerComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignLoggerComponent.java deleted file mode 100644 index c7842f6a53..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignLoggerComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.fanruan.boot.show; - - -import com.fanruan.boot.LoggerComponent; -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/show/DesignUpdateComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignUpdateComponent.java deleted file mode 100644 index 764e6c54a6..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignUpdateComponent.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fanruan.boot.show; - -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/show/DesignWorkspaceComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignWorkspaceComponent.java deleted file mode 100644 index 4f7b447d33..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignWorkspaceComponent.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.fanruan.boot.show; - -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/show/DesignWorkspaceRegisterComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignWorkspaceRegisterComponent.java deleted file mode 100644 index af9b62b737..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignWorkspaceRegisterComponent.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fanruan.boot.show; - -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/show/DesignerComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignerComponent.java deleted file mode 100644 index db3659e5b4..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignerComponent.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.fanruan.boot.show; - -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_fs", "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/show/DesignerDaoComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignerDaoComponent.java deleted file mode 100644 index fad7dfd14e..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignerDaoComponent.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.fanruan.boot.show; - - -import com.fanruan.boot.DAOComponent; -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/show/DesignerShowComponent.java b/designer-realize/src/main/java/com/fanruan/boot/show/DesignerShowComponent.java deleted file mode 100644 index f9789f2964..0000000000 --- a/designer-realize/src/main/java/com/fanruan/boot/show/DesignerShowComponent.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.fanruan.boot.show; - -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/fs/DesignFileRepository.java b/designer-realize/src/main/java/com/fanruan/fs/DesignFileRepository.java new file mode 100644 index 0000000000..07c68918fa --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/fs/DesignFileRepository.java @@ -0,0 +1,34 @@ +package com.fanruan.fs; + +import com.fanruan.fs.repository.local.LocalFileRepository; +import com.fr.decision.service.context.ServiceContext; +import com.fr.io.repository.FineFileEntry; +import com.fr.stable.project.ProjectConstants; +import com.fr.workspace.server.entity.resource.ResourceBean; +import com.fr.workspace.server.repository.resource.PublicResourceRepository; + + +/** + * DesignFileRepository + *

设计器需要用的方法在这里重写即可

+ * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/6/6 + */ +public class DesignFileRepository extends LocalFileRepository { + + public DesignFileRepository() { + super(ProjectConstants.LOCAL_ENV, ServiceContext.getWebInfPath()); + } + + @Override + public String getWorkRoot() { + return PublicResourceRepository.getInstance().getWorkRoot(); + } + + @Override + public FineFileEntry[] listEntry(String dir) { + return PublicResourceRepository.getInstance().listEntry(new ResourceBean(dir)); + } +} 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 2e8d5d3247..0e97fb6f52 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 @@ -204,7 +204,7 @@ public class DesignerActivator extends Activator implements Prepare { } }, SupportOSImpl.BBS_USER_LOGIN_PANE); loadLogAppender(); - DesignerSocketIO.update(); + //DesignerSocketIO.update(); DesignerWorkspaceLoader.init(); storePassport(); AlphaFineHelper.switchConfig4Locale(); 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 a3902d20bd..5fafde6e0d 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,6 +1,15 @@ package com.fr.start.util; import com.fanruan.carina.lifecycle.bootstrap.BootstrapFactory; +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; /** @@ -12,15 +21,25 @@ public class DesignerStartupPageUtil { * 进入工作目录 */ public static void enterWorkspace() throws Exception { - BootstrapFactory.get().start("design_show"); + BootstrapFactory.get().start("design_env_choose"); + BootstrapFactory.get().start("design_function"); + 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()); + } } /** * 退出工作目录 */ public static void exitWorkspace() throws Exception { - BootstrapFactory.get().stop("design_show"); + BootstrapFactory.get().stop("design_function"); + BootstrapFactory.get().stop("design_env_choose"); } }