public class ConfigurationHandler extends Object implements org.forgerock.opendj.config.server.spi.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 and Description |
---|
ConfigurationHandler(ServerContext serverContext)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addEntry(org.forgerock.opendj.ldap.Entry entry)
Add a configuration entry.
|
static ConfigurationHandler |
bootstrapConfiguration(ServerContext serverContext)
Bootstraps the server configuration.
|
void |
deleteEntry(org.forgerock.opendj.ldap.Dn dn)
Delete a configuration entry.
|
void |
deregisterAddListener(org.forgerock.opendj.ldap.Dn dn,
org.forgerock.opendj.config.server.spi.ConfigAddListener listener) |
boolean |
deregisterChangeListener(org.forgerock.opendj.ldap.Dn dn,
org.forgerock.opendj.config.server.spi.ConfigChangeListener listener) |
void |
deregisterDeleteListener(org.forgerock.opendj.ldap.Dn dn,
org.forgerock.opendj.config.server.spi.ConfigDeleteListener listener) |
void |
finalize()
Finalizes the configuration handler.
|
List<org.forgerock.opendj.config.server.spi.ConfigAddListener> |
getAddListeners(org.forgerock.opendj.ldap.Dn dn) |
Map<String,String> |
getAlerts()
Retrieves information about the set of alerts that this generator
may produce.
|
List<org.forgerock.opendj.config.server.spi.ConfigChangeListener> |
getChangeListeners(org.forgerock.opendj.ldap.Dn dn) |
Set<org.forgerock.opendj.ldap.Dn> |
getChildren(org.forgerock.opendj.ldap.Dn dn) |
String |
getClassName()
Retrieves the fully-qualified name of the Java class for this
alert generator implementation.
|
org.forgerock.opendj.ldap.Dn |
getComponentEntryDN()
Retrieves the DN of the configuration entry with which this alert
generator is associated.
|
File |
getConfigurationFile()
Returns the configuration file containing all configuration entries.
|
List<org.forgerock.opendj.config.server.spi.ConfigDeleteListener> |
getDeleteListeners(org.forgerock.opendj.ldap.Dn dn) |
org.forgerock.opendj.ldap.Entry |
getEntry(org.forgerock.opendj.ldap.Dn dn) |
org.forgerock.opendj.ldap.Entry |
getRootEntry()
Returns the configuration root entry.
|
boolean |
hasEntry(org.forgerock.opendj.ldap.Dn dn) |
long |
numSubordinates(org.forgerock.opendj.ldap.Dn entryDN,
boolean subtree)
Retrieves the number of subordinates for the requested entry.
|
void |
registerAddListener(org.forgerock.opendj.ldap.Dn dn,
org.forgerock.opendj.config.server.spi.ConfigAddListener listener) |
void |
registerChangeListener(org.forgerock.opendj.ldap.Dn dn,
org.forgerock.opendj.config.server.spi.ConfigChangeListener listener) |
void |
registerDeleteListener(org.forgerock.opendj.ldap.Dn dn,
org.forgerock.opendj.config.server.spi.ConfigDeleteListener listener) |
void |
reinitializeWithFullSchema(org.forgerock.opendj.ldap.schema.Schema schema)
Re-initializes the configuration handler with a fully initialized schema.
|
void |
replaceEntry(org.forgerock.opendj.ldap.Entry oldEntry,
org.forgerock.opendj.ldap.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 |
writeSuccessfulStartupConfig()
Generates a configuration file with the ".startok" suffix, representing a configuration
file that has a successful start.
|
public ConfigurationHandler(ServerContext serverContext)
serverContext
- The server context.public static ConfigurationHandler bootstrapConfiguration(ServerContext serverContext) throws InitializationException
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.
serverContext
- The server context.InitializationException
- If an error occurs during bootstrapping.public void reinitializeWithFullSchema(org.forgerock.opendj.ldap.schema.Schema schema) throws InitializationException
Previously registered listeners are preserved.
schema
- The server schema, fully initialized.InitializationException
- If an error occurs.public void finalize()
public Map<String,String> getAlerts()
AlertGenerator
getAlerts
in interface AlertGenerator
public Set<org.forgerock.opendj.ldap.Dn> getChildren(org.forgerock.opendj.ldap.Dn dn) throws org.forgerock.opendj.config.server.ConfigException
getChildren
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
org.forgerock.opendj.config.server.ConfigException
public String getClassName()
AlertGenerator
getClassName
in interface AlertGenerator
public org.forgerock.opendj.ldap.Dn getComponentEntryDN()
AlertGenerator
getComponentEntryDN
in interface AlertGenerator
public File getConfigurationFile()
public org.forgerock.opendj.ldap.Entry getEntry(org.forgerock.opendj.ldap.Dn dn) throws org.forgerock.opendj.config.server.ConfigException
getEntry
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
org.forgerock.opendj.config.server.ConfigException
public org.forgerock.opendj.ldap.Entry getRootEntry()
public List<org.forgerock.opendj.config.server.spi.ConfigAddListener> getAddListeners(org.forgerock.opendj.ldap.Dn dn)
getAddListeners
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
public List<org.forgerock.opendj.config.server.spi.ConfigChangeListener> getChangeListeners(org.forgerock.opendj.ldap.Dn dn)
getChangeListeners
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
public List<org.forgerock.opendj.config.server.spi.ConfigDeleteListener> getDeleteListeners(org.forgerock.opendj.ldap.Dn dn)
getDeleteListeners
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
public boolean hasEntry(org.forgerock.opendj.ldap.Dn dn) throws org.forgerock.opendj.config.server.ConfigException
hasEntry
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
org.forgerock.opendj.config.server.ConfigException
public void search(SearchOperation searchOperation)
searchOperation
- Defines the search to performpublic long numSubordinates(org.forgerock.opendj.ldap.Dn entryDN, boolean subtree) throws org.forgerock.opendj.config.server.ConfigException
entryDN
- The distinguished name of the entry.subtree
- true
to include all entries from the requested entry to the lowest level in
the tree or false
to only include the entries immediately below the requested
entry.ConfigException
- If a problem occurs while trying to retrieve the entry.org.forgerock.opendj.config.server.ConfigException
public void addEntry(org.forgerock.opendj.ldap.Entry entry) throws DirectoryException
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.
entry
- The configuration entry to add.DirectoryException
- If an error occurs.public void deleteEntry(org.forgerock.opendj.ldap.Dn dn) throws DirectoryException
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.
dn
- DN of entry to delete.DirectoryException
- If a problem occurs.public void replaceEntry(org.forgerock.opendj.ldap.Entry oldEntry, org.forgerock.opendj.ldap.Entry newEntry) throws DirectoryException
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.
oldEntry
- The original entry that is being replaced.newEntry
- The new entry to use in place of the existing entry with the same DN.DirectoryException
- If a problem occurs while trying to replace the entry.public void registerAddListener(org.forgerock.opendj.ldap.Dn dn, org.forgerock.opendj.config.server.spi.ConfigAddListener listener)
registerAddListener
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
public void registerDeleteListener(org.forgerock.opendj.ldap.Dn dn, org.forgerock.opendj.config.server.spi.ConfigDeleteListener listener)
registerDeleteListener
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
public void registerChangeListener(org.forgerock.opendj.ldap.Dn dn, org.forgerock.opendj.config.server.spi.ConfigChangeListener listener)
registerChangeListener
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
public void deregisterAddListener(org.forgerock.opendj.ldap.Dn dn, org.forgerock.opendj.config.server.spi.ConfigAddListener listener)
deregisterAddListener
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
public void deregisterDeleteListener(org.forgerock.opendj.ldap.Dn dn, org.forgerock.opendj.config.server.spi.ConfigDeleteListener listener)
deregisterDeleteListener
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
public boolean deregisterChangeListener(org.forgerock.opendj.ldap.Dn dn, org.forgerock.opendj.config.server.spi.ConfigChangeListener listener)
deregisterChangeListener
in interface org.forgerock.opendj.config.server.spi.ConfigurationRepository
public void writeLDIF(LDIFExportConfig exportConfig) throws DirectoryException
exportConfig
- The configuration to use for the export.DirectoryException
- If a problem occurs while writing the LDIF.public void writeSuccessfulStartupConfig()
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.
Copyright © 2010-2017 ForgeRock AS. All Rights Reserved.