Class Environment

java.lang.Object
org.nuxeo.common.Environment

public class Environment extends Object
Author:
Bogdan Stefanescu
  • Field Details

  • Constructor Details

    • Environment

      public Environment(File home)
      Call to that constructor should be followed by a call to init(). Depending on the available System properties, you may want to also call loadProperties(Properties) or setServerHome(File) methods before init(); here is the recommended order:
       Environment env = new Environment(home);
       Environment.setDefault(env);
       env.loadProperties(properties);
       env.setServerHome(home);
       env.init();
       
      Parameters:
      home - Root path used for most defaults. It is recommended to make it match the server home rather than the runtime home.
      See Also:
    • Environment

      public Environment(File home, Properties properties)
      Call to that constructor should be followed by a call to init(). Depending on the available System properties, you may want to also call setServerHome(File) method before init(); here is the recommended order:
       Environment env = new Environment(home, properties);
       Environment.setDefault(env);
       env.setServerHome(home);
       env.init();
       
      Parameters:
      home - Root path used for most defaults. It is recommended to make it match the server home rather than the runtime home.
      properties - Source properties for initialization. It is used as an Hashtable: ie only the custom values are read, the properties default values are ignored if any.
      See Also:
  • Method Details

    • setDefault

      public static void setDefault(Environment env)
    • getDefault

      public static Environment getDefault()
    • getDefault

      public static Environment getDefault(Properties systemProperties)
      Since:
      11.5
    • getHome

      public File getHome()
    • isApplicationServer

      public boolean isApplicationServer()
    • setIsApplicationServer

      public void setIsApplicationServer(boolean isAppServer)
    • getHostApplicationName

      public String getHostApplicationName()
    • getHostApplicationVersion

      public String getHostApplicationVersion()
    • setHostApplicationName

      public void setHostApplicationName(String name)
    • setHostApplicationVersion

      public void setHostApplicationVersion(String version)
    • getTemp

      public File getTemp()
    • setTemp

      public void setTemp(String temp)
      Resolve the path against serverHome if not absolute.
      Since:
      8.1
    • setTemp

      public void setTemp(File temp)
    • getConfig

      public File getConfig()
    • setConfig

      public void setConfig(String config)
      Resolve the path against runtimeHome if not absolute.
      Since:
      8.1
    • setConfig

      public void setConfig(File config)
    • getLog

      public File getLog()
    • setLog

      public void setLog(String log)
      Resolve the path against serverHome if not absolute.
      Since:
      8.1
    • setLog

      public void setLog(File log)
    • getData

      public File getData()
    • setData

      public void setData(String data)
      Resolve the path against runtimeHome if not absolute.
      Since:
      8.1
    • setData

      public void setData(File data)
    • getWeb

      public File getWeb()
    • setWeb

      public void setWeb(String web)
      Resolve the path against runtimeHome if not absolute.
      Since:
      8.1
    • setWeb

      public void setWeb(File web)
    • getRuntimeHome

      public File getRuntimeHome()
      Since:
      5.4.2
    • setRuntimeHome

      public void setRuntimeHome(File runtimeHome)
      Since:
      5.4.2
    • getCommandLineArguments

      public String[] getCommandLineArguments()
    • setCommandLineArguments

      public void setCommandLineArguments(String[] args)
    • getProperty

      public String getProperty(String key)
    • getProperty

      public String getProperty(String key, String defaultValue)
    • setProperty

      public void setProperty(String key, String value)
      If setting a path property, consider using setPath(String, String)
    • getProperties

      public Properties getProperties()
    • loadProperties

      public void loadProperties(Properties props)
    • isJBoss

      public boolean isJBoss()
    • isJetty

      public boolean isJetty()
    • isTomcat

      public boolean isTomcat()
    • init

      public void 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.
      Since:
      5.4.1
    • getServerHome

      public File getServerHome()
      This method always returns the server home (or getHome() if NUXEO_HOME_DIR is not set).
      Returns:
      Server home
      Since:
      5.4.2
    • setServerHome

      public void setServerHome(File serverHome)
      Since:
      5.4.2
    • setConfigurationProvider

      public void setConfigurationProvider(Iterable<URL> configProvider)
    • getConfigurationProvider

      public Iterable<URL> getConfigurationProvider()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setPath

      public void setPath(String key, File value, File baseDir)
      Add a file path as a property
      Parameters:
      key - Property key
      value - Property value: an absolute or relative file
      baseDir - The directory against which the file will be resolved if not absolute
      Since:
      8.1
      See Also:
    • setPath

      public void setPath(String key, String value, File baseDir)
      Add a file path as a property
      Parameters:
      key - Property key
      value - Property value: an absolute or relative file path
      baseDir - The directory against which the file will be resolved if not absolute
      Since:
      8.1
      See Also:
    • setPath

      public void setPath(String key, File value)
      Add a file path as a property
      Parameters:
      key - Property key
      value - Property value: an absolute or relative file; if relative, it will be resolved against home
      Since:
      8.1
      See Also:
    • setPath

      public void setPath(String key, String value)
      Add a file path as a property
      Parameters:
      key - Property key
      value - Property value: an absolute or relative file path; if relative, it will be resolved against home
      Since:
      8.1
      See Also:
    • getPath

      public File getPath(String key)
      Returns:
      the file which path is associated with the given key. The file is guaranteed to be absolute if it has been set with setPath(String, File)
      Since:
      8.1
    • getPath

      public File getPath(String key, String defaultValue)
      Parameters:
      key - the property key
      defaultValue - the default path, absolute or relative to server home
      Returns:
      the file which path is associated with the given key. The file is guaranteed to be absolute if it has been set with setPath(String, File)
      Since:
      8.1
    • getDistributionVersion

      public String getDistributionVersion()
      Returns:
      the version of the Nuxeo distribution
      Since:
      11.5
    • getDistributionDate

      public String getDistributionDate()
      Returns:
      the build date of the Nuxeo distribution
      Since:
      11.5
    • getDistributionInfo

      protected void getDistributionInfo()