Browse Source

去除moduleshell

remotes/1611766341912730171/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. 33
      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;
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);
}
/**
* 退出当前工作目录
*/

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

33
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);
}
}

4
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();

Loading…
Cancel
Save