Class DirectoryEnvironmentConfig
- java.lang.Object
-
- org.opends.server.types.DirectoryEnvironmentConfig
-
@PublicAPI(stability=VOLATILE, mayInstantiate=true, mayInvoke=true) public final class DirectoryEnvironmentConfig extends Object
This class provides a set of properties that may control various aspects of the server environment. Note that these properties may only be altered before the Directory Server is started. Any attempt to change an environment configuration property while the server is running will be rejected.
-
-
Constructor Summary
Constructors Constructor Description DirectoryEnvironmentConfig()
Creates a new directory environment configuration initialized from the system properties defined in the JVM.DirectoryEnvironmentConfig(boolean checkIfServerIsRunning)
Creates a new directory environment configuration initialized from the system properties defined in the JVM.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
disableAdminDataSynchronization()
Indicates whether the Directory Server startup process should skip the synchronization between admin data and the configuration.boolean
disableConnectionHandlers()
Indicates whether the Directory Server startup process should skip the connection handler creation and initialization phases.boolean
disableSynchronization()
Indicates whether the Directory Server startup process should skip the synchronization provider creation and initialization phases.boolean
forceDaemonThreads()
Indicates whether all threads created by the Directory Server should be created as daemon threads.Path
getConfigFile()
Retrieves the configuration file that should be used to initialize the Directory Server config handler.Path
getInstanceRoot()
Retrieves the directory that should be considered the instance root.String
getInstanceRootAsString()
Retrieves the path of the directory that should be considered the instance root.Path
getLockDirectory()
Retrieves the directory that should be used to hold the server lock files.int
getMaxConfigArchiveSize()
Retrieves the maximum number of archived configurations that the Directory Server should maintain.PropertyResolver
getPropertyResolver()
Returns thePropertyResolver
to be used by Directory Server when resolving configuration expressions to values.Path
getSchemaDirectory()
Retrieves the directory that contains the server schema configuration files.static Path
getSchemaDirectory(Path instanceDir)
Retrieves the directory that contains the server schema configuration files.File
getServerRoot()
Retrieves the directory that should be considered the server root.String
getServerRootAsString()
Retrieves the path of the directory that should be considered the server root.Path
getVarDirectory()
Retrieves the directory in which mutable files should be placed.boolean
maintainConfigArchive()
Indicates whether the Directory Server should maintain an archive of previous configurations.boolean
registerShutdownHook()
Indicates whether the Directory Server should register a virtual-machine shutdown hook.File
setConfigFile(File configFile)
Specifies the configuration file that should be used to initialize the Directory Server config handler.PropertyResolver
setConfigResolver(PropertyResolver resolver)
Specifies thePropertyResolver
to resolve configuration expressions.boolean
setDisableConnectionHandlers(boolean disableConnectionHandlers)
Specifies whether the Directory Server startup process should skip the connection handler creation and initialization phases.boolean
setForceDaemonThreads(boolean forceDaemonThreads)
Specifies whether all threads created by the Directory Server should be created as daemon threads.File
setInstanceRoot(File instanceRoot)
Specifies the directory that should be considered the instance root.boolean
setMaintainConfigArchive(boolean maintainConfigArchive)
Specifies whether the Directory Server should maintain an archive of previous configurations.String
setProperty(String name, String value)
Specifies a property with the given name and value.boolean
setRegisterShutdownHook(boolean registerShutdownHook)
Specifies whether a virtual-machine shutdown hook should be registered.File
setSchemaDirectory(File schemaDirectory)
Specifies the directory that should contain the server schema configuration files.File
setServerRoot(File serverRoot)
Specifies the directory that should be considered the server root.boolean
useLastKnownGoodConfiguration()
Indicates whether the Directory Server should attempt to start with the "last known good" configuration rather than the current active configuration file.
-
-
-
Constructor Detail
-
DirectoryEnvironmentConfig
public DirectoryEnvironmentConfig()
Creates a new directory environment configuration initialized from the system properties defined in the JVM.
-
DirectoryEnvironmentConfig
public DirectoryEnvironmentConfig(boolean checkIfServerIsRunning)
Creates a new directory environment configuration initialized from the system properties defined in the JVM.- Parameters:
checkIfServerIsRunning
- Iftrue
, prevent any change when server is running.
-
-
Method Detail
-
setProperty
public String setProperty(String name, String value) throws InitializationException
Specifies a property with the given name and value. If a property is already defined with the given name, then its value will be replaced with the provided value, or the property will be removed if the given value isnull
.- Parameters:
name
- The name of the property to set.value
- The value of the property to set, ornull
if the property is to be removed.- Returns:
- The previous value held for the property, or
null
if it was not previously set. - Throws:
InitializationException
- If the Directory Server is already running.
-
getServerRoot
public File getServerRoot()
Retrieves the directory that should be considered the server root.The determination will first be based on the properties defined in this object. If no value is found there, then the JVM system properties will be checked, followed by an environment variable. If there is still no value, then the location of the config file, if available, is used to determine the root.
- Returns:
- The directory that should be considered the server root, or
null
if it can't be determined.
-
getServerRootAsString
public String getServerRootAsString()
Retrieves the path of the directory that should be considered the server root.This method uses the same rules than
getServerRoot
method, but never returnsnull
. If no directory can be found it returns as a last resort the value of "user.dir" system property.- Returns:
- the path of the directory that should be considered the server root.
-
getInstanceRoot
public Path getInstanceRoot()
Retrieves the directory that should be considered the instance root.- Returns:
- The directory that should be considered the instance root or
null
if it can't be determined.
-
getInstanceRootAsString
public String getInstanceRootAsString()
Retrieves the path of the directory that should be considered the instance root.This method uses the same rules than
getInstanceRoot
method, but never returnsnull
. If no directory can be found it returns as a last resort the value of "user.dir" system property.- Returns:
- the path of the directory that should be considered the instance root.
-
setServerRoot
public File setServerRoot(File serverRoot) throws InitializationException
Specifies the directory that should be considered the server root. Any relative path used in the server should be considered relative to the server root.- Parameters:
serverRoot
- The directory that should be considered the server root.- Returns:
- The previous server root, or
null
if there was none. - Throws:
InitializationException
- If the Directory Server is already running or there is a problem with the provided server root.
-
setInstanceRoot
public File setInstanceRoot(File instanceRoot) throws InitializationException
Specifies the directory that should be considered the instance root. Any relative path used in the server should be considered relative to the instance root.- Parameters:
instanceRoot
- The directory that should be considered the instanceRoot root.- Returns:
- The previous server root, or
null
if there was none. - Throws:
InitializationException
- If the Directory Server is already running or there is a problem with the provided server root.
-
setConfigResolver
public PropertyResolver setConfigResolver(PropertyResolver resolver)
Specifies thePropertyResolver
to resolve configuration expressions.- Parameters:
resolver
- the property resolver- Returns:
- the previous property resolver
-
getConfigFile
public Path getConfigFile()
Retrieves the configuration file that should be used to initialize the Directory Server config handler. If no default configuration file is specified, then the server will attempt to use "config/config.ldif" below the server root if it exists.- Returns:
- The configuration file that should be used to initialize the Directory Server config handler, or
null
if no configuration file is defined.
-
getPropertyResolver
public PropertyResolver getPropertyResolver() throws InitializationException
Returns thePropertyResolver
to be used by Directory Server when resolving configuration expressions to values. If no resolvers have been defined, the default property resolver for the stack is used.- Returns:
- the list of
PropertyResolver
- Throws:
InitializationException
- If the resolver can't be created
-
setConfigFile
public File setConfigFile(File configFile) throws InitializationException
Specifies the configuration file that should be used to initialize the Directory Server config handler.- Parameters:
configFile
- The configuration file that should be used to initialize the Directory Server config handler.- Returns:
- The previously-defined configuration file, or
null
if none was defined. - Throws:
InitializationException
- If the Directory Server is already running or there is a problem with the provided configuration file.
-
useLastKnownGoodConfiguration
public boolean useLastKnownGoodConfiguration()
Indicates whether the Directory Server should attempt to start with the "last known good" configuration rather than the current active configuration file. Note that if there is no "last known good" configuration file available, then the server should try to start using the current, active configuration file. If no explicit value is defined, then a default result offalse
will be returned.- Returns:
true
if the Directory Server should attempt to start using the "last known good" configuration, orfalse
if it should try to start using the active configuration.
-
maintainConfigArchive
public boolean maintainConfigArchive()
Indicates whether the Directory Server should maintain an archive of previous configurations. If no explicit value is defined, then a default result oftrue
will be returned.- Returns:
true
if the Directory Server should maintain an archive of previous configurations, orfalse
if not.
-
setMaintainConfigArchive
public boolean setMaintainConfigArchive(boolean maintainConfigArchive) throws InitializationException
Specifies whether the Directory Server should maintain an archive of previous configurations.- Parameters:
maintainConfigArchive
- Indicates whether the Directory Server should maintain an archive of previous configurations.- Returns:
- The previous setting for this configuration option. If no previous value was specified, then
true
will be returned. - Throws:
InitializationException
- If the Directory Server is already running.
-
getMaxConfigArchiveSize
public int getMaxConfigArchiveSize()
Retrieves the maximum number of archived configurations that the Directory Server should maintain. If no value is defined, then a value of zero will be returned.- Returns:
- The maximum number of archived configurations that the Directory Server should maintain, or zero if there should not be any limit.
-
getSchemaDirectory
public Path getSchemaDirectory()
Retrieves the directory that contains the server schema configuration files.- Returns:
- The directory that contains the server schema configuration files, or
null
if none is defined.
-
getSchemaDirectory
public static Path getSchemaDirectory(Path instanceDir)
Retrieves the directory that contains the server schema configuration files. If a default directory of "db/schema" or "config/schema" exists below the instance directory, then that will be returned.This code is copied to LdifManagementContextFactory#getSchemaDirectory().
- Parameters:
instanceDir
- The instance directory inside which the schema directory is searched- Returns:
- The directory that contains the server schema configuration files, or
null
if none is defined.
-
setSchemaDirectory
public File setSchemaDirectory(File schemaDirectory) throws InitializationException
Specifies the directory that should contain the server schema configuration files. It must exist and must be a directory.- Parameters:
schemaDirectory
- The directory that should contain the server schema configuration files.- Returns:
- The previously-defined schema configuration directory, or
null
if none was defined. - Throws:
InitializationException
- If the Directory Server is already running or there is a problem with the provided schema directory.
-
getLockDirectory
public Path getLockDirectory()
Retrieves the directory that should be used to hold the server lock files. If no value is defined, then the server will attempt to use a default directory of "locks" below the server root.- Returns:
- The directory that should be used to hold the server lock files, or
null
if it cannot be determined.
-
getVarDirectory
public Path getVarDirectory()
Retrieves the directory in which mutable files should be placed.- Returns:
- The directory in which variable files should be placed, or
null
if it cannot be determined
-
disableConnectionHandlers
public boolean disableConnectionHandlers()
Indicates whether the Directory Server startup process should skip the connection handler creation and initialization phases.- Returns:
true
if the Directory Server should not start its connection handlers, orfalse
if the connection handlers should be enabled.
-
disableSynchronization
public boolean disableSynchronization()
Indicates whether the Directory Server startup process should skip the synchronization provider creation and initialization phases.- Returns:
true
if the Directory Server should not start its synchronization provider, orfalse
if the synchronization provider should be enabled.
-
disableAdminDataSynchronization
public boolean disableAdminDataSynchronization()
Indicates whether the Directory Server startup process should skip the synchronization between admin data and the configuration.- Returns:
true
if the Directory Server should start synchronization between admin data and the configuration.
-
setDisableConnectionHandlers
public boolean setDisableConnectionHandlers(boolean disableConnectionHandlers) throws InitializationException
Specifies whether the Directory Server startup process should skip the connection handler creation and initialization phases.- Parameters:
disableConnectionHandlers
- Indicates whether the Directory Server should skip the connection handler creation and initialization phases.- Returns:
- The previous setting for this configuration option. If no previous value was specified, then
false
will be returned. - Throws:
InitializationException
- If the Directory Server is already running.
-
forceDaemonThreads
public boolean forceDaemonThreads()
Indicates whether all threads created by the Directory Server should be created as daemon threads.- Returns:
true
if all threads created by the Directory Server should be created as daemon threads, orfalse
if not.
-
setForceDaemonThreads
public boolean setForceDaemonThreads(boolean forceDaemonThreads) throws InitializationException
Specifies whether all threads created by the Directory Server should be created as daemon threads.- Parameters:
forceDaemonThreads
- Indicates whether all threads created by the Directory Server should be created as daemon threads.- Returns:
- The previous setting for this configuration option. If no previous value was specified, then
false
will be returned. - Throws:
InitializationException
- If the Directory Server is already running.
-
registerShutdownHook
public boolean registerShutdownHook()
Indicates whether the Directory Server should register a virtual-machine shutdown hook.- Returns:
true
if the Directory Server should register a shutdown hook orfalse
if not.
-
setRegisterShutdownHook
public boolean setRegisterShutdownHook(boolean registerShutdownHook) throws InitializationException
Specifies whether a virtual-machine shutdown hook should be registered.- Parameters:
registerShutdownHook
- Indicates whether the Directory Server should register a virtual-machine shutdown hook.- Returns:
- The previous setting for this configuration option. If no previous value was specified, then
false
will be returned. - Throws:
InitializationException
- If the Directory Server is already running.
-
-