Package org.nuxeo.common
Class Environment
- java.lang.Object
-
- org.nuxeo.common.Environment
-
public class Environment extends Object
- Author:
- Bogdan Stefanescu
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Environment(File home)
Call to that constructor should be followed by a call toinit()
.Environment(File home, Properties properties)
Call to that constructor should be followed by a call toinit()
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String[]
getCommandLineArguments()
File
getConfig()
Iterable<URL>
getConfigurationProvider()
File
getData()
static Environment
getDefault()
static Environment
getDefault(Properties systemProperties)
String
getDistributionDate()
protected void
getDistributionInfo()
String
getDistributionVersion()
File
getHome()
String
getHostApplicationName()
String
getHostApplicationVersion()
File
getLog()
File
getPath(String key)
File
getPath(String key, String defaultValue)
Properties
getProperties()
String
getProperty(String key)
String
getProperty(String key, String defaultValue)
File
getRuntimeHome()
File
getServerHome()
This method always returns the server home (orgetHome()
ifNUXEO_HOME_DIR
is not set).File
getTemp()
File
getWeb()
void
init()
Initialization with System properties to avoid issues due to home set with runtime home instead of server home.boolean
isApplicationServer()
boolean
isJBoss()
boolean
isJetty()
boolean
isTomcat()
void
loadProperties(Properties props)
void
setCommandLineArguments(String[] args)
void
setConfig(File config)
void
setConfig(String config)
Resolve the path againstruntimeHome
if not absolute.void
setConfigurationProvider(Iterable<URL> configProvider)
void
setData(File data)
void
setData(String data)
Resolve the path againstruntimeHome
if not absolute.static void
setDefault(Environment env)
void
setHostApplicationName(String name)
void
setHostApplicationVersion(String version)
void
setIsApplicationServer(boolean isAppServer)
void
setLog(File log)
void
setLog(String log)
Resolve the path againstserverHome
if not absolute.void
setPath(String key, File value)
Add a file path as a propertyvoid
setPath(String key, File value, File baseDir)
Add a file path as a propertyvoid
setPath(String key, String value)
Add a file path as a propertyvoid
setPath(String key, String value, File baseDir)
Add a file path as a propertyvoid
setProperty(String key, String value)
If setting a path property, consider usingsetPath(String, String)
void
setRuntimeHome(File runtimeHome)
void
setServerHome(File serverHome)
void
setTemp(File temp)
void
setTemp(String temp)
Resolve the path againstserverHome
if not absolute.void
setWeb(File web)
void
setWeb(String web)
Resolve the path againstruntimeHome
if not absolute.String
toString()
-
-
-
Field Detail
-
JBOSS_HOST
public static final String JBOSS_HOST
Constants that identifies possible hosts for the framework.- See Also:
- Constant Field Values
-
NXSERVER_HOST
public static final String NXSERVER_HOST
- See Also:
- Constant Field Values
-
TOMCAT_HOST
public static final String TOMCAT_HOST
- See Also:
- Constant Field Values
-
NUXEO_HOME_DIR
public static final String NUXEO_HOME_DIR
- See Also:
- Constant Field Values
-
NUXEO_HOME
public static final String NUXEO_HOME
- Since:
- 5.6
- See Also:
- Constant Field Values
-
NUXEO_RUNTIME_HOME
public static final String NUXEO_RUNTIME_HOME
- Since:
- 5.4.2
- See Also:
- Constant Field Values
-
NUXEO_DATA_DIR
public static final String NUXEO_DATA_DIR
- See Also:
- Constant Field Values
-
DEFAULT_DATA_DIR
public static final String DEFAULT_DATA_DIR
- Since:
- 5.9.4
- See Also:
- Constant Field Values
-
NUXEO_LOG_DIR
public static final String NUXEO_LOG_DIR
- See Also:
- Constant Field Values
-
DEFAULT_LOG_DIR
public static final String DEFAULT_LOG_DIR
- Since:
- 5.9.4
- See Also:
- Constant Field Values
-
NUXEO_PID_DIR
public static final String NUXEO_PID_DIR
- See Also:
- Constant Field Values
-
NUXEO_TMP_DIR
public static final String NUXEO_TMP_DIR
- See Also:
- Constant Field Values
-
DEFAULT_TMP_DIR
public static final String DEFAULT_TMP_DIR
- Since:
- 5.9.4
- See Also:
- Constant Field Values
-
NUXEO_CONFIG_DIR
public static final String NUXEO_CONFIG_DIR
- See Also:
- Constant Field Values
-
DEFAULT_CONFIG_DIR
public static final String DEFAULT_CONFIG_DIR
- Since:
- 5.9.4
- See Also:
- Constant Field Values
-
NUXEO_WEB_DIR
public static final String NUXEO_WEB_DIR
- See Also:
- Constant Field Values
-
DEFAULT_WEB_DIR
public static final String DEFAULT_WEB_DIR
- Since:
- 5.9.4
- See Also:
- Constant Field Values
-
NUXEO_MP_DIR
public static final String NUXEO_MP_DIR
- Since:
- 5.9.4
- See Also:
- Constant Field Values
-
DEFAULT_MP_DIR
public static final String DEFAULT_MP_DIR
- Since:
- 5.9.4
- See Also:
- Constant Field Values
-
NUXEO_CONTEXT_PATH
public static final String NUXEO_CONTEXT_PATH
- Since:
- 5.6
- See Also:
- Constant Field Values
-
BUNDLES_DIR
public static final String BUNDLES_DIR
The application layout (optional): directory containing nuxeo runtime osgi bundles.- See Also:
- Constant Field Values
-
BUNDLES
public static final String BUNDLES
- See Also:
- Constant Field Values
-
home
protected final File home
-
data
protected File data
-
log
protected File log
-
config
protected File config
-
web
protected File web
-
temp
protected File temp
-
properties
protected final Properties properties
-
args
protected String[] args
-
isAppServer
protected boolean isAppServer
-
hostAppName
protected String hostAppName
-
hostAppVersion
protected String hostAppVersion
-
distributionVersion
protected String distributionVersion
-
distributionDate
protected String distributionDate
-
SERVER_STATUS_KEY
public static final String SERVER_STATUS_KEY
- See Also:
- Constant Field Values
-
DISTRIBUTION_NAME
public static final String DISTRIBUTION_NAME
- See Also:
- Constant Field Values
-
DISTRIBUTION_VERSION
public static final String DISTRIBUTION_VERSION
- See Also:
- Constant Field Values
-
DISTRIBUTION_SERVER
public static final String DISTRIBUTION_SERVER
- Since:
- 7.10
- See Also:
- Constant Field Values
-
DISTRIBUTION_DATE
public static final String DISTRIBUTION_DATE
- Since:
- 7.10
- See Also:
- Constant Field Values
-
DISTRIBUTION_PACKAGE
public static final String DISTRIBUTION_PACKAGE
- Since:
- 7.10
- See Also:
- Constant Field Values
-
DISTRIBUTION_HOTFIX
public static final String DISTRIBUTION_HOTFIX
- Since:
- 11.5
- See Also:
- Constant Field Values
-
DISTRIBUTION_PROPERTY_FILE
public static final String DISTRIBUTION_PROPERTY_FILE
- Since:
- 11.5
- See Also:
- Constant Field Values
-
PRODUCT_NAME
public static final String PRODUCT_NAME
- Since:
- 7.10
- See Also:
- Constant Field Values
-
PRODUCT_VERSION
public static final String PRODUCT_VERSION
- Since:
- 7.10
- See Also:
- Constant Field Values
-
NUXEO_HTTP_PROXY_HOST
public static final String NUXEO_HTTP_PROXY_HOST
- Since:
- 6.0
- See Also:
- Constant Field Values
-
NUXEO_HTTP_PROXY_PORT
public static final String NUXEO_HTTP_PROXY_PORT
- Since:
- 6.0
- See Also:
- Constant Field Values
-
NUXEO_HTTP_PROXY_LOGIN
public static final String NUXEO_HTTP_PROXY_LOGIN
- Since:
- 6.0
- See Also:
- Constant Field Values
-
NUXEO_HTTP_PROXY_PASSWORD
public static final String NUXEO_HTTP_PROXY_PASSWORD
- Since:
- 6.0
- See Also:
- Constant Field Values
-
CRYPT_ALGO
public static final String CRYPT_ALGO
- Since:
- 7.4
- See Also:
- Constant Field Values
-
CRYPT_KEY
public static final String CRYPT_KEY
- Since:
- 7.4
- See Also:
- Constant Field Values
-
CRYPT_KEYALIAS
public static final String CRYPT_KEYALIAS
- Since:
- 7.4
- See Also:
- Constant Field Values
-
CRYPT_KEYSTORE_PATH
public static final String CRYPT_KEYSTORE_PATH
- Since:
- 7.4
- See Also:
- Constant Field Values
-
CRYPT_KEYSTORE_PASS
public static final String CRYPT_KEYSTORE_PASS
- Since:
- 7.4
- See Also:
- Constant Field Values
-
JAVA_DEFAULT_KEYSTORE
public static final String JAVA_DEFAULT_KEYSTORE
- Since:
- 7.4
- See Also:
- Constant Field Values
-
JAVA_DEFAULT_KEYSTORE_PASS
public static final String JAVA_DEFAULT_KEYSTORE_PASS
- Since:
- 7.4
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Environment
public Environment(File home)
Call to that constructor should be followed by a call toinit()
. Depending on the available System properties, you may want to also callloadProperties(Properties)
orsetServerHome(File)
methods beforeinit()
; 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:
init()
-
Environment
public Environment(File home, Properties properties)
Call to that constructor should be followed by a call toinit()
. Depending on the available System properties, you may want to also callsetServerHome(File)
method beforeinit()
; 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 anHashtable
: ie only the custom values are read, the properties default values are ignored if any.- See Also:
init()
-
-
Method Detail
-
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 againstserverHome
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 againstruntimeHome
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 againstserverHome
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 againstruntimeHome
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 againstruntimeHome
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)
-
setProperty
public void setProperty(String key, String value)
If setting a path property, consider usingsetPath(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. IfNUXEO_HOME
System property is not set, or if you want to set a custom server home, then you should callsetServerHome(File)
before.- Since:
- 5.4.1
-
getServerHome
public File getServerHome()
This method always returns the server home (orgetHome()
ifNUXEO_HOME_DIR
is not set).- Returns:
- Server home
- Since:
- 5.4.2
-
setServerHome
public void setServerHome(File serverHome)
- Since:
- 5.4.2
-
setPath
public void setPath(String key, File value, File baseDir)
Add a file path as a property- Parameters:
key
- Property keyvalue
- Property value: an absolute or relative filebaseDir
- The directory against which the file will be resolved if not absolute- Since:
- 8.1
- See Also:
setProperty(String, String)
,setPath(String, String, File)
,setPath(String, File)
-
setPath
public void setPath(String key, String value, File baseDir)
Add a file path as a property- Parameters:
key
- Property keyvalue
- Property value: an absolute or relative file pathbaseDir
- The directory against which the file will be resolved if not absolute- Since:
- 8.1
- See Also:
setProperty(String, String)
,setPath(String, File, File)
,setPath(String, File)
-
setPath
public void setPath(String key, File value)
Add a file path as a property- Parameters:
key
- Property keyvalue
- Property value: an absolute or relative file; if relative, it will be resolved againsthome
- Since:
- 8.1
- See Also:
setProperty(String, String)
,setPath(String, File, File)
-
setPath
public void setPath(String key, String value)
Add a file path as a property- Parameters:
key
- Property keyvalue
- Property value: an absolute or relative file path; if relative, it will be resolved againsthome
- Since:
- 8.1
- See Also:
setProperty(String, String)
,setPath(String, String, File)
-
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 keydefaultValue
- 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()
-
-