Package org.opends.server.api
Class ConnectionHandler<T extends ConnectionHandlerCfg>
java.lang.Object
org.opends.server.api.ConnectionHandler<T>
- Type Parameters:
T
- The type of connection handler configuration handled by this connection handler implementation.
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
HTTPConnectionHandler
,JmxConnectionHandler
,LDAPConnectionHandler
,LDIFConnectionHandler
public abstract class ConnectionHandler<T extends ConnectionHandlerCfg>
extends Object
implements Closeable
This class defines the set of methods and structures that must be implemented by a Directory Server connection
handler.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAdditionalMeters
(MeterRegistryHolder registry) Computes additional meters that is specific to the connection handler implementation.protected void
Adds the object class names that should be included in the monitor entry related to this connection handler to the provided attribute.abstract void
bind()
Operates in a loop, accepting new connections and ensuring that requests on those connections are handled properly.final void
close()
Closes this connection handler so that it will no longer accept new client connections, disconnecting any existing connections, and releasing any other resources associated with the connection handler.protected void
doClose()
Closes this connection handler so that it will no longer accept new client connections.protected abstract void
doInitializeConnectionHandler
(ServerContext serverContext, T configuration) Initializes this connection handler provider based on the information in the provided connection handler configuration.abstract Collection<ClientConnection>
Retrieves the set of active client connections that have been established through this connection handler.abstract Dn
Retrieves the DN of the configuration entry with which this alert generator is associated.abstract String
Retrieves a name that may be used to refer to this connection handler.Returns the type of this connection handler.Retrieves an unmodifiable set of enabled SSL cipher suites configured for this connection handler, if applicable.Retrieves the set of enabled SSL protocols configured for this connection handler.abstract Collection<com.forgerock.opendj.util.HostPort>
Retrieves information about the listener(s) that will be used to accept client connections.protected int
getNumRequestHandlers
(Integer numRequestHandlers, String friendlyName) Determine the number of request handlers.abstract String
Retrieves the name of the protocol used to communicate with clients.protected ServerContext
Returns the server context.final void
initializeConnectionHandler
(ServerContext serverContext, T configuration) Initializes this connection handler provider based on the information in the provided connection handler configuration.boolean
Indicates if the connection is on the Administration Connector which may mean it is excluded from certain checks.boolean
isConfigurationAcceptable
(ServerContext serverContext, T configuration, List<LocalizableMessage> unacceptableReasons) Indicates whether the provided configuration is acceptable for this connection handler.toString()
Retrieves a string representation of this connection handler.abstract void
toString
(StringBuilder buffer) Appends a string representation of this connection handler to the provided buffer.
-
Constructor Details
-
ConnectionHandler
public ConnectionHandler()
-
-
Method Details
-
getConnectionHandlerName
Retrieves a name that may be used to refer to this connection handler. Every connection handler instance (even handlers of the same type) must have a unique name.- Returns:
- A unique name that may be used to refer to this connection handler.
-
getConnectionHandlerType
Returns the type of this connection handler. By default this returnsgetProtocol()
. It should be returning the insecure protocol version.- Returns:
- The type of this connection handler.
-
getEnabledSSLCipherSuites
Retrieves an unmodifiable set of enabled SSL cipher suites configured for this connection handler, if applicable. Implementations must return an empty set if use of SSL/TLS is not possible.- Returns:
- The set of enabled SSL cipher suites configured for this connection handler.
-
getEnabledSSLProtocols
Retrieves the set of enabled SSL protocols configured for this connection handler. Implementations must return an empty set if use of SSL/TLS is not possible.- Returns:
- The set of enabled SSL protocols configured for this connection handler.
-
getComponentEntryDN
Retrieves the DN of the configuration entry with which this alert generator is associated.- Returns:
- The DN of the configuration entry with which this alert generator is associated.
-
getProtocol
Retrieves the name of the protocol used to communicate with clients. It should take into account any special naming that may be needed to express any security mechanisms or other constraints in place (e.g., "LDAPS" for LDAP over SSL).- Returns:
- The name of the protocol used to communicate with clients.
-
getListeners
Retrieves information about the listener(s) that will be used to accept client connections.- Returns:
- Information about the listener(s) that will be used to accept client connections, or an empty list if this connection handler does not accept connections from network clients.
-
getClientConnections
Retrieves the set of active client connections that have been established through this connection handler.- Returns:
- The set of active client connections that have been established through this connection handler.
-
getServerContext
Returns the server context.- Returns:
- the server context
-
initializeConnectionHandler
public final void initializeConnectionHandler(ServerContext serverContext, T configuration) throws InitializationException Initializes this connection handler provider based on the information in the provided connection handler configuration.- Parameters:
serverContext
- The server context.configuration
- The connection handler configuration that contains the information to use to initialize this connection handler.- Throws:
InitializationException
- If a problem occurs during initialization that is not related to the server configuration.
-
doInitializeConnectionHandler
protected abstract void doInitializeConnectionHandler(ServerContext serverContext, T configuration) throws InitializationException Initializes this connection handler provider based on the information in the provided connection handler configuration.- Parameters:
serverContext
- The server context.configuration
- The connection handler configuration that contains the information to use to initialize this connection handler.- Throws:
InitializationException
- If a problem occurs during initialization that is not related to the server configuration.
-
isAdministrative
public boolean isAdministrative()Indicates if the connection is on the Administration Connector which may mean it is excluded from certain checks.- Returns:
true
if the connection is on the Administration Connector.
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(ServerContext serverContext, T configuration, List<LocalizableMessage> unacceptableReasons) Indicates whether the provided configuration is acceptable for this connection handler. It should be possible to call this method on an uninitialized connection handler instance in order to determine whether the connection handler would be able to use the provided configuration.- Parameters:
serverContext
- The server contextconfiguration
- The connection handler configuration for which to make the determination.unacceptableReasons
- A list that may be used to hold the reasons that the provided configuration is not acceptable.- Returns:
true
if the provided configuration is acceptable for this connection handler, orfalse
if not.
-
bind
Operates in a loop, accepting new connections and ensuring that requests on those connections are handled properly.- Throws:
IOException
- If theConnectionHandler
cannot be bound.
-
close
public final void close()Closes this connection handler so that it will no longer accept new client connections, disconnecting any existing connections, and releasing any other resources associated with the connection handler.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
doClose
protected void doClose()Closes this connection handler so that it will no longer accept new client connections. Implementations should disconnect any existing connections and release any other resources associated with the connection handler. -
getNumRequestHandlers
Determine the number of request handlers.- Parameters:
numRequestHandlers
- the number of request handlers from the configuration.friendlyName
- the friendly name of this connection handler- Returns:
- the number of request handlers from the configuration determined from the configuration or from the number of available processors on the current machine
-
toString
Retrieves a string representation of this connection handler. -
toString
Appends a string representation of this connection handler to the provided buffer.- Parameters:
buffer
- The buffer to which the information should be appended.
-
addAdditionalMeters
Computes additional meters that is specific to the connection handler implementation. The default implementation is to do nothing.- Parameters:
registry
- where additional meters should be added.
-
addAdditionalMonitorObjectClassNames
Adds the object class names that should be included in the monitor entry related to this connection handler to the provided attribute.- Parameters:
ocAttr
- The object class attribute on which the object class names are added.
-