Class DirectoryEnvironmentConfig

java.lang.Object
org.opends.server.types.DirectoryEnvironmentConfig

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
    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

    Modifier and Type
    Method
    Description
    boolean
    Indicates whether the Directory Server startup process should skip the synchronization between admin data and the configuration.
    boolean
    Indicates whether the Directory Server startup process should skip the connection handler creation and initialization phases.
    boolean
    Indicates whether the Directory Server startup process should skip the synchronization provider creation and initialization phases.
    boolean
    Indicates whether all threads created by the Directory Server should be created as daemon threads.
    Retrieves the configuration file that should be used to initialize the Directory Server config handler.
    Retrieves a Path object corresponding to the specified path.
    Retrieves a Path object corresponding to the specified path.
    Retrieves the directory that should be considered the instance root.
    Retrieves the path of the directory that should be considered the instance root.
    Retrieves the directory that should be used to hold the server lock files.
    int
    Retrieves the maximum number of archived configurations that the Directory Server should maintain.
    Returns the PropertyResolver to be used by Directory Server when resolving configuration expressions to values.
    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.
    Retrieves the directory that should be considered the server root.
    Retrieves the path of the directory that should be considered the server root.
    Retrieves the directory in which mutable files should be placed.
    boolean
    Indicates whether the Directory Server should maintain an archive of previous configurations.
    boolean
    Indicates whether the Directory Server should register a virtual-machine shutdown hook.
    void
    setConfigFile(Path configFile)
    Specifies the configuration file that should be used to initialize the Directory Server config handler.
    void
    Specifies the PropertyResolver to resolve configuration expressions.
    void
    setDisableConnectionHandlers(boolean disableConnectionHandlers)
    Specifies whether the Directory Server startup process should skip the connection handler creation and initialization phases.
    void
    setForceDaemonThreads(boolean forceDaemonThreads)
    Specifies whether all threads created by the Directory Server should be created as daemon threads.
    void
    setInstanceRoot(Path instanceRoot)
    Specifies the directory that should be considered the instance root.
    void
    setMaintainConfigArchive(boolean maintainConfigArchive)
    Specifies whether the Directory Server should maintain an archive of previous configurations.
    void
    setProperty(String name, String value)
    Specifies a property with the given name and value.
    void
    setRegisterShutdownHook(boolean registerShutdownHook)
    Specifies whether a virtual-machine shutdown hook should be registered.
    void
    setSchemaDirectory(Path schemaDirectory)
    Specifies the directory that should contain the server schema configuration files.
    void
    setServerRoot(Path serverRoot)
    Specifies the directory that should be considered the server root.
    boolean
    Indicates whether the Directory Server should attempt to start with the "last known good" configuration rather than the current active configuration file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • 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 - If true, prevent any change when server is running.
  • Method Details

    • setProperty

      public void 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 is null.
      Parameters:
      name - The name of the property to set.
      value - The value of the property to set, or null if the property is to be removed.
      Throws:
      InitializationException - If the Directory Server is already running.
    • getServerRoot

      public Path 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.
    • getServerRootOrUserDir

      public Path getServerRootOrUserDir()
      Retrieves the path of the directory that should be considered the server root.

      This method uses the same rules than getServerRoot method, but never returns null. 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.
    • getInstanceRootOrUserDir

      public Path getInstanceRootOrUserDir()
      Retrieves the path of the directory that should be considered the instance root.

      This method uses the same rules than getInstanceRoot method, but never returns null. 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 void setServerRoot(Path 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.
      Throws:
      InitializationException - If the Directory Server is already running or there is a problem with the provided server root.
    • setInstanceRoot

      public void setInstanceRoot(Path 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.
      Throws:
      InitializationException - If the Directory Server is already running or there is a problem with the provided server root.
    • setConfigResolver

      public void setConfigResolver(PropertyResolver resolver)
      Specifies the PropertyResolver to resolve configuration expressions.
      Parameters:
      resolver - the 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 the PropertyResolver 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 void setConfigFile(Path 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.
      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 of false will be returned.
      Returns:
      true if the Directory Server should attempt to start using the "last known good" configuration, or false 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 of true will be returned.
      Returns:
      true if the Directory Server should maintain an archive of previous configurations, or false if not.
    • setMaintainConfigArchive

      public void 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.
      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 void setSchemaDirectory(Path 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.
      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, or false 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, or false 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 void 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.
      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, or false if not.
    • setForceDaemonThreads

      public void 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.
      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 or false if not.
    • setRegisterShutdownHook

      public void 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.
      Throws:
      InitializationException - If the Directory Server is already running.
    • getFileForPath

      public Path getFileForPath(String path)
      Retrieves a Path object corresponding to the specified path. If the given path is an absolute path, then it will be used. If the path is relative, then it will be interpreted as if it were relative to the Directory Server root.
      Parameters:
      path - The path object to be retrieved as an absolute Path
      Returns:
      A Path object that corresponds to the specified path.
    • getFileForPath

      public Path getFileForPath(Path path)
      Retrieves a Path object corresponding to the specified path. If the given path is an absolute path, then it will be used. If the path is relative, then it will be interpreted as if it were relative to the Directory Server root.
      Parameters:
      path - The path object to be retrieved as an absolute Path
      Returns:
      A Path object that corresponds to the specified path.