LDAPRequestHandler.java revision 99faa045b6241c1d2843cce1b7a9d9c97055beae
829N/A * The contents of this file are subject to the terms of the 829N/A * Common Development and Distribution License, Version 1.0 only 829N/A * (the "License"). You may not use this file except in compliance 2362N/A * You can obtain a copy of the license at 829N/A * See the License for the specific language governing permissions 829N/A * and limitations under the License. 829N/A * When distributing Covered Code, include this CDDL HEADER in each 829N/A * file and include the License file at 829N/A * add the following below this CDDL HEADER, with the fields enclosed 829N/A * by brackets "[]" replaced with your own identifying information: 829N/A * Portions Copyright [yyyy] [name of copyright owner] 829N/A * Portions Copyright 2006-2007 Sun Microsystems, Inc. 829N/A * This class defines an LDAP request handler, which is associated with an LDAP 829N/A * connection handler and is responsible for reading and decoding any requests 829N/A * that LDAP clients may send to the server. Multiple request handlers may be 829N/A * used in conjunction with a single connection handler for better performance 829N/A * The buffer size in bytes to use when reading data from a client. 829N/A // Indicates whether the Directory Server is in the process of shutting down. // The queue that will be used to hold the set of pending connections that // need to be registered with the selector. // The connection handler with which this request handler is associated. // The selector that will be used to monitor the client connections. // The name to use for this request handler. * Creates a new LDAP request handler that will be associated with the * provided connection handler. * @param connectionHandler The LDAP connection handler with which this * request handler is associated. * @param requestHandlerID The integer value that may be used to distingush * this request handler from others associated with * the same connection handler. * @throws InitializationException If a problem occurs while initializing // Check to see if we get an error while trying to perform a select. If // we do, then it's likely CR 6322825 and the server won't be able to // handle LDAP requests in its current state. * Operates in a loop, waiting for client requests to arrive and ensuring that * they are processed properly. // Operate in a loop until the server shuts down. Each time through the // loop, check for new requests, then check for new connections. // FIXME -- Should we do something else with this? // Some other error occurred while we were trying to read data // FIXME -- Should we log this? // We got some other kind of error. If nothing else, cancel the // key, but if the client connection is available then // disconnect it as well. // This could happen if a connection was closed between the time // that select returned and the time that we try to access the // associated channel. If that was the case, we don't need to do // This should not happen, and it would have caused our reader // thread to die. Log a severe error. // Check to see if we have any pending connections that need to be // registered with the selector. * Registers the provided client connection with this request handler so that * any requests received from that client will be processed. * @param clientConnection The client connection to be registered with this * @return <CODE>true</CODE> if the client connection was properly registered * with this request handler, or <CODE>false</CODE> if not. // FIXME -- Need to check if the maximum client limit has been reached. // If the server is in the process of shutting down, then we don't want to // Try to add the new connection to the queue. If it succeeds, then wake // up the selector so it will be picked up right away. Otherwise, // disconnect the client. * Deregisters the provided client connection from this request handler so it * will no longer look for requests from that client. * @param clientConnection The client connection to deregister from this * Deregisters all clients associated with this request handler. * Retrieves the set of all client connections that are currently registered * with this request handler. * @return The set of all client connections that are currently registered * with this request handler. * Retrieves the human-readable name for this shutdown listener. * @return The human-readable name for this shutdown listener. * Causes this request handler to register itself as a shutdown listener with * the Directory Server. This must be called if the connection handler is * shut down without closing all associated connections, otherwise the thread * would not be stopped by the server. * Indicates that the Directory Server has received a request to stop running * and that this shutdown listener should take any action necessary to prepare * @param reason The human-readable reason for the shutdown.