From 7f682b45fb4cd0b8db9d559de2e0db9a91392824 Mon Sep 17 00:00:00 2001 From: zack Date: Mon, 26 Aug 2019 10:08:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4moduleshell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/env/EnvKit.java | 42 --------------- .../fanruan/api/env/shell/ModuleShell.java | 33 ------------ .../java/com/fanruan/api/ModulePrepare.java | 52 +++++++++++++++++++ src/test/java/com/fanruan/api/Prepare.java | 33 ++++++++---- .../api/report/analy/AnalyKitTest.java | 4 +- 5 files changed, 78 insertions(+), 86 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/env/shell/ModuleShell.java create mode 100644 src/test/java/com/fanruan/api/ModulePrepare.java diff --git a/src/main/java/com/fanruan/api/env/EnvKit.java b/src/main/java/com/fanruan/api/env/EnvKit.java index fc59660..bf24b3e 100644 --- a/src/main/java/com/fanruan/api/env/EnvKit.java +++ b/src/main/java/com/fanruan/api/env/EnvKit.java @@ -1,22 +1,6 @@ package com.fanruan.api.env; -import com.fanruan.api.env.shell.ModuleShell; -import com.fr.base.operator.common.CommonOperator; -import com.fr.chart.activator.ChartBaseActivator; -import com.fr.cluster.engine.activator.standalone.StandaloneModeActivator; -import com.fr.config.activator.BaseDBActivator; -import com.fr.config.activator.ConfigurationActivator; -import com.fr.env.operator.CommonOperatorImpl; -import com.fr.general.I18nResource; -import com.fr.module.Module; -import com.fr.module.tool.ActivatorToolBox; -import com.fr.report.ReportActivator; -import com.fr.report.RestrictionActivator; -import com.fr.report.module.ReportBaseActivator; -import com.fr.scheduler.SchedulerActivator; -import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; -import com.fr.store.StateServerActivator; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.resource.WorkResource; @@ -58,32 +42,6 @@ public class EnvKit { } } - /** - * 创建本地服务器启动模块 - * - * @param envPath 本地工程路径 : D:\\FineReport_10.0\\webapps\\webroot\\WEB-INF - * @return 模块代理对象 使用ModuleShell的start和stop控制模块启停 - */ - public static ModuleShell createLocalStartModule(String envPath) { - Module module = ActivatorToolBox.simpleLink( - new BaseDBActivator(), - new ConfigurationActivator(), - new StandaloneModeActivator(), - new StateServerActivator(), - new SchedulerActivator(), - new ReportBaseActivator(), - new RestrictionActivator(), - new ReportActivator(), - new ChartBaseActivator() - ); - SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); - if (StringUtils.isNotEmpty(envPath)) { - SimpleWork.checkIn(envPath); - } - I18nResource.getInstance(); - return new ModuleShell(module); - } - /** * 退出当前工作目录 */ diff --git a/src/main/java/com/fanruan/api/env/shell/ModuleShell.java b/src/main/java/com/fanruan/api/env/shell/ModuleShell.java deleted file mode 100644 index 9df9f5b..0000000 --- a/src/main/java/com/fanruan/api/env/shell/ModuleShell.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.fanruan.api.env.shell; - -import com.fr.module.Module; - -/** - * 模块封装 - */ -public class ModuleShell { - private Module module; - - public ModuleShell(Module module) { - this.module = module; - } - - /** - * 启动模块 - */ - public void start() { - if (module != null) { - module.start(); - } - } - - /** - * 关闭模块 - */ - public void stop() { - if (module != null) { - module.stop(); - } - } - -} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/ModulePrepare.java b/src/test/java/com/fanruan/api/ModulePrepare.java new file mode 100644 index 0000000..96d63fa --- /dev/null +++ b/src/test/java/com/fanruan/api/ModulePrepare.java @@ -0,0 +1,52 @@ +package com.fanruan.api; + +import com.fr.base.operator.common.CommonOperator; +import com.fr.cluster.engine.activator.standalone.StandaloneModeActivator; +import com.fr.config.activator.BaseDBActivator; +import com.fr.config.activator.ConfigurationActivator; +import com.fr.env.operator.CommonOperatorImpl; +import com.fr.general.I18nResource; +import com.fr.module.Module; +import com.fr.module.tool.ActivatorToolBox; +import com.fr.report.ReportActivator; +import com.fr.report.RestrictionActivator; +import com.fr.report.module.ReportBaseActivator; +import com.fr.scheduler.SchedulerActivator; +import com.fr.store.StateServerActivator; +import com.fr.workspace.simple.SimpleWork; +import org.junit.After; +import org.junit.Before; + +/** + * @ClassName ModulePrepare + * @Author zack + * @Date 2019/8/26 + * @Version 10.0 + */ +public class ModulePrepare { + Module module = null; + + @Before + public void start() { + module = ActivatorToolBox.simpleLink( + new BaseDBActivator(), + new ConfigurationActivator(), + new StandaloneModeActivator(), + new StateServerActivator(), + new SchedulerActivator(), + new ReportBaseActivator(), + new RestrictionActivator(), + new ReportActivator() + ); + SimpleWork.supply(CommonOperator.class, new CommonOperatorImpl()); + I18nResource.getInstance(); + module.start(); + } + + @After + public void stop() { + if (module != null) { + module.stop(); + } + } +} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/Prepare.java b/src/test/java/com/fanruan/api/Prepare.java index d93fd1f..d74dfbf 100644 --- a/src/test/java/com/fanruan/api/Prepare.java +++ b/src/test/java/com/fanruan/api/Prepare.java @@ -1,29 +1,44 @@ package com.fanruan.api; -import com.fanruan.api.env.EnvKit; -import com.fanruan.api.env.shell.ModuleShell; +import com.fr.config.dao.DaoContext; +import com.fr.config.dao.impl.LocalClassHelperDao; +import com.fr.config.dao.impl.LocalEntityDao; +import com.fr.config.dao.impl.LocalXmlEntityDao; +import com.fr.runtime.FineRuntime; +import com.fr.store.StateHubManager; +import com.fr.store.impl.MemoryLock; +import com.fr.store.impl.MemoryStore; +import com.fr.transaction.Configurations; +import com.fr.transaction.LocalConfigurationHelper; import org.junit.After; import org.junit.Before; /** * @author richie * @version 10.0 - * Created by richie on 2019-08-09 + * Created by richie on 2019-08-09 */ public class Prepare { - private ModuleShell module; @Before public void start() { - module = EnvKit.createLocalStartModule(""); - module.start(); + FineRuntime.start(); + DaoContext.setEntityDao(new LocalEntityDao()); + DaoContext.setClassHelperDao(new LocalClassHelperDao()); + DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); + Configurations.setHelper(new LocalConfigurationHelper()); + StateHubManager.setStorage(new MemoryStore()); + StateHubManager.setLock(new MemoryLock()); } @After public void stop() { - if (module != null) { - module.stop(); - } + DaoContext.setEntityDao(null); + DaoContext.setClassHelperDao(null); + DaoContext.setXmlEntityDao(null); + Configurations.setHelper(null); + StateHubManager.setStorage(null); + StateHubManager.setLock(null); } } diff --git a/src/test/java/com/fanruan/api/report/analy/AnalyKitTest.java b/src/test/java/com/fanruan/api/report/analy/AnalyKitTest.java index 79d3eaf..26e161b 100644 --- a/src/test/java/com/fanruan/api/report/analy/AnalyKitTest.java +++ b/src/test/java/com/fanruan/api/report/analy/AnalyKitTest.java @@ -1,6 +1,6 @@ package com.fanruan.api.report.analy; -import com.fanruan.api.Prepare; +import com.fanruan.api.ModulePrepare; import com.fanruan.api.report.analy.data.TreeNode; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; @@ -13,7 +13,7 @@ import org.junit.Test; import java.util.HashMap; import java.util.Map; -public class AnalyKitTest extends Prepare { +public class AnalyKitTest extends ModulePrepare { @Test public void testTree() { WorkBook tpl = new WorkBook();