forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.9 KiB
93 lines
2.9 KiB
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; |
|
import com.fr.workspace.simple.SimpleWork; |
|
import org.jetbrains.annotations.NotNull; |
|
|
|
/** |
|
* @author richie |
|
* @version 10.0 |
|
* Created by richie on 2019-08-09 |
|
*/ |
|
public class EnvKit { |
|
|
|
/** |
|
* 获取当前的工作目录 |
|
* @return 工作目录 |
|
*/ |
|
public static Workspace getCurrent() { |
|
return WorkContext.getCurrent(); |
|
} |
|
|
|
/** |
|
* 获取当前工作目录的资源读写对象 |
|
* @return 资源读写对象 |
|
*/ |
|
public static WorkResource getWorkResource() { |
|
return WorkContext.getWorkResource(); |
|
} |
|
|
|
/** |
|
* 设置一个目录为工作目录 |
|
* @param path 工作目录位置 |
|
*/ |
|
public static void setCurrent(@NotNull String path) { |
|
if (path.endsWith(ProjectConstants.WEBINF_NAME)) { |
|
SimpleWork.checkIn(path); |
|
} else { |
|
throw new IllegalArgumentException("Cannot set " + path + " as work directory."); |
|
} |
|
} |
|
|
|
/** |
|
* 创建本地服务器启动模块 |
|
* |
|
* @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); |
|
} |
|
|
|
/** |
|
* 退出当前工作目录 |
|
*/ |
|
public static void checkout() { |
|
SimpleWork.checkOut(); |
|
} |
|
}
|
|
|