Browse Source

去除moduleshell

master
zack 5 years ago
parent
commit
7f682b45fb
  1. 42
      src/main/java/com/fanruan/api/env/EnvKit.java
  2. 33
      src/main/java/com/fanruan/api/env/shell/ModuleShell.java
  3. 52
      src/test/java/com/fanruan/api/ModulePrepare.java
  4. 31
      src/test/java/com/fanruan/api/Prepare.java
  5. 4
      src/test/java/com/fanruan/api/report/analy/AnalyKitTest.java

42
src/main/java/com/fanruan/api/env/EnvKit.java vendored

@ -1,22 +1,6 @@
package com.fanruan.api.env; 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.stable.project.ProjectConstants;
import com.fr.store.StateServerActivator;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.resource.WorkResource; 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);
}
/** /**
* 退出当前工作目录 * 退出当前工作目录
*/ */

33
src/main/java/com/fanruan/api/env/shell/ModuleShell.java vendored

@ -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();
}
}
}

52
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();
}
}
}

31
src/test/java/com/fanruan/api/Prepare.java

@ -1,7 +1,15 @@
package com.fanruan.api; package com.fanruan.api;
import com.fanruan.api.env.EnvKit; import com.fr.config.dao.DaoContext;
import com.fanruan.api.env.shell.ModuleShell; 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.After;
import org.junit.Before; import org.junit.Before;
@ -11,19 +19,26 @@ import org.junit.Before;
* Created by richie on 2019-08-09 * Created by richie on 2019-08-09
*/ */
public class Prepare { public class Prepare {
private ModuleShell module;
@Before @Before
public void start() { public void start() {
module = EnvKit.createLocalStartModule(""); FineRuntime.start();
module.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 @After
public void stop() { public void stop() {
if (module != null) { DaoContext.setEntityDao(null);
module.stop(); DaoContext.setClassHelperDao(null);
} DaoContext.setXmlEntityDao(null);
Configurations.setHelper(null);
StateHubManager.setStorage(null);
StateHubManager.setLock(null);
} }
} }

4
src/test/java/com/fanruan/api/report/analy/AnalyKitTest.java

@ -1,6 +1,6 @@
package com.fanruan.api.report.analy; 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.fanruan.api.report.analy.data.TreeNode;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
@ -13,7 +13,7 @@ import org.junit.Test;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class AnalyKitTest extends Prepare { public class AnalyKitTest extends ModulePrepare {
@Test @Test
public void testTree() { public void testTree() {
WorkBook tpl = new WorkBook(); WorkBook tpl = new WorkBook();

Loading…
Cancel
Save