Class ConfigurationHandler
- All Implemented Interfaces:
ConfigurationRepository
,AlertGenerator
Configuration is represented by configuration entries, persisted on the file system. Configuration entries are
initially read from configuration file ("config/config.ldif" by default), then stored in a MemoryBackend
during server uptime.
The handler allows to register and unregister some listeners on any configuration entry (add, change or delete listener). Configuration entries can be added, replaced or deleted to the handler. Any change of a configuration entry will trigger the listeners registered for this entry, and will also trigger an update of configuration file.
The handler also maintains an up-to-date archive of configuration files.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a configuration entry.static ConfigurationHandler
bootstrapConfiguration
(ServerContext serverContext) Bootstraps the server configuration.void
deleteEntry
(Dn dn) Delete a configuration entry.void
deregisterAddListener
(Dn dn, ConfigAddListener listener) Deregisters the provided add listener so that it will no longer be notified if any new entries are added immediately below the entry corresponding to the provided DN.void
deregisterChangeListener
(Dn dn, ConfigChangeListener listener) Attempts to deregister the provided change listener with the provided DN.void
deregisterDeleteListener
(Dn dn, ConfigDeleteListener listener) Deregisters the provided delete listener so that it will no longer be notified if any entries are deleted immediately below the entry corresponding to the provided DN.void
finalize()
Finalizes the configuration handler.getAddListeners
(Dn dn) Retrieves the add listeners that have been registered with the provided DN.Retrieves information about the set of alerts that this generator may produce.getChangeListeners
(Dn dn) Retrieves the change listeners that have been registered with the provided DN.getChildren
(Dn dn) Returns the set of DNs of children of the entry corresponding to the provided DN.Retrieves the DN of the configuration entry with which this alert generator is associated.Returns the configuration file containing all configuration entries.getDeleteListeners
(Dn dn) Retrieves the delete listeners that have been registered with the provided DN.Returns the configuration entry for the provided DN.Returns the configuration root entry.boolean
Checks if the provided DN corresponds to a configuration entry.long
numSubordinates
(Dn entryDN, boolean subtree) Retrieves the number of subordinates for the requested entry.void
registerAddListener
(Dn dn, ConfigAddListener listener) Registers the provided add listener so that it will be notified if any new entries are added immediately below the entry corresponding to the provided DN.void
registerChangeListener
(Dn dn, ConfigChangeListener listener) Registers the provided change listener so that it will be notified of any changes to the entry corrresponding to provided DN.void
registerDeleteListener
(Dn dn, ConfigDeleteListener listener) Registers the provided delete listener so that it will be notified if any entries are deleted immediately below the entry corresponding to the provided DN.void
reinitializeWithFullSchema
(Schema schema) Re-initializes the configuration handler with a fully initialized schema.void
replaceEntry
(Entry oldEntry, Entry newEntry) Replaces the old configuration entry with the new configuration entry provided.void
search
(SearchOperation searchOperation) Search the configuration entries.void
writeLDIF
(LDIFExportConfig exportConfig) Writes the current configuration to LDIF with the provided export configuration.void
Generates a configuration file with the ".startok" suffix, representing a configuration file that has a successful start.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opends.server.api.AlertGenerator
getClassName
-
Constructor Details
-
ConfigurationHandler
Creates a new instance.- Parameters:
serverContext
- The server context.
-
-
Method Details
-
bootstrapConfiguration
public static ConfigurationHandler bootstrapConfiguration(ServerContext serverContext) throws InitializationException Bootstraps the server configuration.The returned ConfigurationHandler is initialized with a partial schema and must be later re-initialized with the full schema by calling
reinitializeWithFullSchema(Schema)
method once the schema has been fully loaded.- Parameters:
serverContext
- The server context.- Returns:
- the configuration handler
- Throws:
InitializationException
- If an error occurs during bootstrapping.
-
reinitializeWithFullSchema
Re-initializes the configuration handler with a fully initialized schema.Previously registered listeners are preserved.
- Parameters:
schema
- The server schema, fully initialized.- Throws:
InitializationException
- If an error occurs.
-
finalize
public void finalize()Finalizes the configuration handler. -
getAlerts
Description copied from interface:AlertGenerator
Retrieves information about the set of alerts that this generator may produce. The map returned should be between the notification type for a particular notification and the human-readable description for that notification. This alert generator must not generate any alerts with types that are not contained in this list.- Specified by:
getAlerts
in interfaceAlertGenerator
- Returns:
- Information about the set of alerts that this generator may produce.
-
getChildren
Description copied from interface:ConfigurationRepository
Returns the set of DNs of children of the entry corresponding to the provided DN. .- Specified by:
getChildren
in interfaceConfigurationRepository
- Parameters:
dn
- DN of a configuration entry.- Returns:
- the set of DN of children of the corresponding entry
- Throws:
ConfigException
- If a problem occurs during retrieval.
-
getComponentEntryDN
Description copied from interface:AlertGenerator
Retrieves the DN of the configuration entry with which this alert generator is associated.- Specified by:
getComponentEntryDN
in interfaceAlertGenerator
- Returns:
- The DN of the configuration entry with which this alert generator is associated.
-
getConfigurationFile
Returns the configuration file containing all configuration entries.- Returns:
- the configuration file
-
getEntry
Description copied from interface:ConfigurationRepository
Returns the configuration entry for the provided DN.- Specified by:
getEntry
in interfaceConfigurationRepository
- Parameters:
dn
- DN of the configuration entry- Returns:
- the config entry
-
getRootEntry
Returns the configuration root entry.- Returns:
- the root entry
-
getAddListeners
Description copied from interface:ConfigurationRepository
Retrieves the add listeners that have been registered with the provided DN.- Specified by:
getAddListeners
in interfaceConfigurationRepository
- Parameters:
dn
- The DN of the configuration entry.- Returns:
- The list of add listeners.
-
getChangeListeners
Description copied from interface:ConfigurationRepository
Retrieves the change listeners that have been registered with the provided DN.- Specified by:
getChangeListeners
in interfaceConfigurationRepository
- Parameters:
dn
- The DN of the configuration entry.- Returns:
- The list of change listeners.
-
getDeleteListeners
Description copied from interface:ConfigurationRepository
Retrieves the delete listeners that have been registered with the provided DN.- Specified by:
getDeleteListeners
in interfaceConfigurationRepository
- Parameters:
dn
- The DN of the configuration entry.- Returns:
- The list of delete listeners.
-
hasEntry
Description copied from interface:ConfigurationRepository
Checks if the provided DN corresponds to a configuration entry.- Specified by:
hasEntry
in interfaceConfigurationRepository
- Parameters:
dn
- DN of the configuration entry- Returns:
true
if and only if there is a configuration entry with this DN
-
search
Search the configuration entries.- Parameters:
searchOperation
- Defines the search to perform
-
numSubordinates
Retrieves the number of subordinates for the requested entry.- Parameters:
entryDN
- The distinguished name of the entry.subtree
-true
to include all entries from the requested entry to the lowest level in the tree orfalse
to only include the entries immediately below the requested entry.- Returns:
- The number of subordinate entries
- Throws:
ConfigException
- If a problem occurs while trying to retrieve the entry.
-
addEntry
Add a configuration entry.The add is performed only if all Add listeners on the parent entry accept the changes. Once the change is accepted, entry is effectively added and all Add listeners are called again to apply the change resulting from this new entry.
- Parameters:
entry
- The configuration entry to add.- Throws:
LdapException
- If an error occurs.
-
deleteEntry
Delete a configuration entry.The delete is performed only if all Delete listeners on the parent entry accept the changes. Once the change is accepted, entry is effectively deleted and all Delete listeners are called again to apply the change resulting from this deletion.
- Parameters:
dn
- DN of entry to delete.- Throws:
LdapException
- If a problem occurs.
-
replaceEntry
Replaces the old configuration entry with the new configuration entry provided.The replacement is performed only if all Change listeners on the entry accept the changes. Once the change is accepted, entry is effectively replaced and all Change listeners are called again to apply the change resulting from the replacement.
- Parameters:
oldEntry
- The original entry that is being replaced.newEntry
- The new entry to use in place of the existing entry with the same DN.- Throws:
LdapException
- If a problem occurs while trying to replace the entry.
-
registerAddListener
Description copied from interface:ConfigurationRepository
Registers the provided add listener so that it will be notified if any new entries are added immediately below the entry corresponding to the provided DN.- Specified by:
registerAddListener
in interfaceConfigurationRepository
- Parameters:
dn
- The DN of the configuration entry.listener
- The add listener that should be registered.
-
registerDeleteListener
Description copied from interface:ConfigurationRepository
Registers the provided delete listener so that it will be notified if any entries are deleted immediately below the entry corresponding to the provided DN.- Specified by:
registerDeleteListener
in interfaceConfigurationRepository
- Parameters:
dn
- The DN of the configuration entry.listener
- The delete listener that should be registered.
-
registerChangeListener
Description copied from interface:ConfigurationRepository
Registers the provided change listener so that it will be notified of any changes to the entry corrresponding to provided DN. No check will be made to determine whether the provided listener is already registered.- Specified by:
registerChangeListener
in interfaceConfigurationRepository
- Parameters:
dn
- The DN of the configuration entry.listener
- The change listener that should be registered.
-
deregisterAddListener
Description copied from interface:ConfigurationRepository
Deregisters the provided add listener so that it will no longer be notified if any new entries are added immediately below the entry corresponding to the provided DN.- Specified by:
deregisterAddListener
in interfaceConfigurationRepository
- Parameters:
dn
- The DN of the configuration entry.listener
- The add listener that should be deregistered.
-
deregisterDeleteListener
Description copied from interface:ConfigurationRepository
Deregisters the provided delete listener so that it will no longer be notified if any entries are deleted immediately below the entry corresponding to the provided DN.- Specified by:
deregisterDeleteListener
in interfaceConfigurationRepository
- Parameters:
dn
- The DN of the configuration entry.listener
- The delete listener that should be deregistered.
-
deregisterChangeListener
Description copied from interface:ConfigurationRepository
Attempts to deregister the provided change listener with the provided DN.- Specified by:
deregisterChangeListener
in interfaceConfigurationRepository
- Parameters:
dn
- The DN of the configuration entry.listener
- The change listener to deregister with this DN.
-
writeLDIF
Writes the current configuration to LDIF with the provided export configuration.- Parameters:
exportConfig
- The configuration to use for the export.- Throws:
LdapException
- If a problem occurs while writing the LDIF.
-
writeSuccessfulStartupConfig
public void writeSuccessfulStartupConfig()Generates a configuration file with the ".startok" suffix, representing a configuration file that has a successful start.This method must not be called if configuration can't be correctly initialized.
The actual generation is skipped if last known good configuration is used.
-