ConnectionHandlerConfigManager.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-2009 Sun Microsystems, Inc.
* Portions Copyright 2012-2015 ForgeRock AS.
*/
/**
* This class defines a utility that will be used to manage the
* configuration for the set of connection handlers defined in the
* Directory Server. It will perform the necessary initialization of
* those connection handlers when the server is first started, and
* then will manage any changes to them while the server is running.
*/
public class ConnectionHandlerConfigManager implements
/**
* The mapping between configuration entry DNs and their corresponding
* connection handler implementations.
*/
private final ServerContext serverContext;
/**
* Creates a new instance of this connection handler config manager.
*
* @param serverContext
* The server context.
*/
this.serverContext = serverContext;
}
/**
* {@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 {
// Attempt to start the connection handler.
// Put this connection handler in the hash so that we will be
// able to find it if it is altered.
// Register the connection handler with the Directory Server.
} catch (ConfigException e) {
logger.traceException(e);
} catch (Exception e) {
logger.traceException(e);
}
}
return ccr;
}
/**
* {@inheritDoc}
*/
// Attempt to get the existing connection handler. This will only
// succeed if it was enabled.
// See whether the connection handler should be enabled.
if (connectionHandler == null) {
if (configuration.isEnabled()) {
// The connection handler needs to be enabled.
try {
// Attempt to start the connection handler.
// Put this connection handler in the hash so that we will
// be able to find it if it is altered.
// Register the connection handler with the Directory
// Server.
} catch (ConfigException e) {
logger.traceException(e);
} catch (Exception e) {
logger.traceException(e);
}
}
} else {
if (configuration.isEnabled()) {
// The connection 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}
*/
// See if the entry is registered as a connection handler. If so,
// deregister and stop it. We'll try to leave any established
// connections alone if possible.
if (connectionHandler != null) {
}
return ccr;
}
/**
* Initializes the configuration associated with the Directory
* Server connection handlers. This should only be called at
* Directory Server startup.
*
* @throws ConfigException
* If a critical configuration problem prevents the
* connection handler initialization from succeeding.
* @throws InitializationException
* If a problem occurs while initializing the connection
* handlers that is not related to the server
* configuration.
*/
public void initializeConnectionHandlerConfig()
throws ConfigException, InitializationException {
// Clear the set of connection handlers in case of in-core restart.
// Initialize the admin connector.
// Get the root configuration which acts as the parent of all
// connection handlers.
.getInstance();
// Register as an add and delete listener so that we can
// be notified if new connection handlers are added or existing
// connection handlers are removed.
// Initialize existing connection handles.
// 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.
config.addChangeListener(this);
// Ignore this connection handler if it is disabled.
// Note that we don't want to start the connection handler
// because we're still in the startup process. Therefore, we
// will not do so and allow the server to start it at the very
// end of the initialization process.
// Put this connection handler in the hash so that we will be
// able to find it if it is altered.
// Register the connection handler with the Directory Server.
}
}
}
private void initializeAdministrationConnectorConfig()
throws ConfigException, InitializationException {
// Put this connection handler in the hash so that we will be
// able to find it if it is altered.
// Register the connection handler with the Directory Server.
}
/**
* {@inheritDoc}
*/
public boolean isConfigurationAddAcceptable(
return !configuration.isEnabled()
}
/**
* {@inheritDoc}
*/
public boolean isConfigurationChangeAcceptable(
return !configuration.isEnabled()
}
/**
* {@inheritDoc}
*/
public boolean isConfigurationDeleteAcceptable(
// A delete should always be acceptable, so just return true.
return true;
}
// Load and initialize the connection handler named in the config.
T config) throws ConfigException
{
try {
@SuppressWarnings("rawtypes")
return connectionHandler;
} catch (Exception e) {
logger.traceException(e);
throw new ConfigException(message, e);
}
}
// Determines whether or not the new configuration's implementation
// class is acceptable.
private boolean isJavaClassAcceptable(
try {
if (connectionHandler == null) {
@SuppressWarnings("rawtypes")
}
} catch (Exception e) {
logger.traceException(e);
return false;
}
}
}