ExtendedOperationConfigManager.java revision f983fc4bc7a4dc0e9d175e77cfaf8a2127aaeb2d
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* This class defines a utility that will be used to manage the set of extended
* operation handlers defined in the Directory Server. It will initialize the
* handlers when the server starts, and then will manage any additions,
* removals, or modifications of any extended operation handlers while the
* server is running.
*/
public class ExtendedOperationConfigManager implements
{
/**
* A mapping between the DNs of the config entries and the associated extended
* operation handlers.
*/
private final ServerContext serverContext;
/**
* Creates a new instance of this extended operation config manager.
*
* @param serverContext
* The server context.
*/
{
this.serverContext = serverContext;
}
/**
* Initializes all extended operation handlers currently defined in the
* Directory Server configuration. This should only be called at Directory
* Server startup.
*
* @throws ConfigException If a configuration problem causes the extended
* operation handler initialization process to fail.
*
* @throws InitializationException If a problem occurs while initializing
* the extended operation handler that is
* not related to the server configuration.
*/
public void initializeExtendedOperationHandlers()
{
// Create an internal server management context and retrieve
// the root configuration which has the extended operation handler relation.
// Register add and delete listeners.
// Initialize existing handlers.
{
// Get the handler's configuration.
// This will decode and validate its properties.
// Register as a change listener for this handler so that we can be
// notified when it is disabled or enabled.
config.addChangeListener(this);
// Ignore this handler if it is disabled.
{
// Load the handler's implementation class and initialize it.
// Put this handler in the hash map so that we will be able to find
// it if it is deleted or disabled.
}
}
}
/**
* {@inheritDoc}
*/
{
// See if the entry is registered as an extended operation handler.
// If so, deregister it and finalize the handler.
{
}
return ccr;
}
/**
* {@inheritDoc}
*/
public boolean isConfigurationChangeAcceptable(
{
return !configuration.isEnabled()
}
/**
* {@inheritDoc}
*/
{
// Attempt to get the existing handler. This will only
// succeed if it was enabled.
// See whether the handler should be enabled.
if (configuration.isEnabled()) {
// The handler needs to be enabled.
try {
// Put this handler in the hash so that we will
// be able to find it if it is altered.
} catch (ConfigException e) {
logger.traceException(e);
} catch (Exception e) {
logger.traceException(e);
}
}
} else {
if (configuration.isEnabled()) {
// The handler is currently active, so we don't
// need to do anything. Changes to the class name cannot be
// applied dynamically, so if the class name did change then
// indicate that administrative action is required for that
// change to take effect.
ccr.setAdminActionRequired(true);
}
} else {
// We need to disable the connection handler.
}
}
return ccr;
}
/**
* {@inheritDoc}
*/
public boolean isConfigurationAddAcceptable(
{
}
/**
* {@inheritDoc}
*/
{
// Register as a change listener for this connection handler entry
// so that we will be notified of any changes that may be made to
// it.
configuration.addChangeListener(this);
// Ignore this connection handler if it is disabled.
if (configuration.isEnabled())
{
// The connection handler needs to be enabled.
try {
// Put this connection handler in the hash so that we will be
// able to find it if it is altered.
}
catch (ConfigException e)
{
logger.traceException(e);
}
catch (Exception e)
{
logger.traceException(e);
}
}
return ccr;
}
/**
* {@inheritDoc}
*/
public boolean isConfigurationDeleteAcceptable(
{
// A delete should always be acceptable, so just return true.
return true;
}
// Load and initialize the handler named in the config.
private ExtendedOperationHandler getHandler(
{
try
{
return extendedOperationHandler;
}
catch (Exception e)
{
logger.traceException(e);
}
}
// Determines whether or not the new configuration's implementation
// class is acceptable.
{
try {
}
catch (Exception e)
{
logger.traceException(e);
return false;
}
}
}