org.nuxeo.common.Environment.init()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中org.nuxeo.common.Environment.init()方法的一些代码示例,展示了Environment.init()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.init()方法的具体详情如下:
包路径:org.nuxeo.common.Environment
类名称:Environment
方法名:init

Environment.init介绍

[英]Initialization with System properties to avoid issues due to home set with runtime home instead of server home. If #NUXEO_HOME System property is not set, or if you want to set a custom server home, then you should call #setServerHome(File) before.
[中]使用系统属性初始化,以避免由于使用运行时主目录而不是服务器主目录设置主目录而导致的问题。如果未设置#NUXEO#U HOME系统属性,或者如果要设置自定义服务器HOME,则应先调用#setServerHome(文件)。

代码示例

代码示例来源:origin: org.nuxeo.common/nuxeo-common

private static synchronized void tryInitEnvironment() {
  String homeDir = System.getProperty(NUXEO_HOME);
  if (homeDir != null) {
    File home = new File(homeDir);
    if (home.isDirectory()) {
      DEFAULT = new Environment(home);
      DEFAULT.init();
    }
  }
}

代码示例来源:origin: org.nuxeo.runtime/nuxeo-launcher-commons

/**
 * @since 5.6
 * @return an {@link Environment} initialized with a few basics
 */
public Environment getEnv() {
  /*
   * It could be useful to initialize DEFAULT env in {@link #setBasicConfiguration()}... For now, the generated
   * {@link Environment} is not static.
   */
  if (env == null) {
    env = new Environment(getRuntimeHome());
    File distribFile = new File(new File(nuxeoHome, TEMPLATES), "common/config/distribution.properties");
    if (distribFile.exists()) {
      try {
        env.loadProperties(loadTrimmedProperties(distribFile));
      } catch (IOException e) {
        log.error(e);
      }
    }
    env.loadProperties(userConfig);
    env.setServerHome(getNuxeoHome());
    env.init();
    env.setData(userConfig.getProperty(Environment.NUXEO_DATA_DIR, "data"));
    env.setLog(userConfig.getProperty(Environment.NUXEO_LOG_DIR, "logs"));
    env.setTemp(userConfig.getProperty(Environment.NUXEO_TMP_DIR, "tmp"));
    env.setPath(PARAM_MP_DIR, getDistributionMPDir(), env.getServerHome());
    env.setPath(Environment.NUXEO_MP_DIR, getPackagesDir(), env.getServerHome());
  }
  return env;
}

相关文章