com.unboundid.ldap.listener
Class LDAPListenerConfig

java.lang.Object
  extended by com.unboundid.ldap.listener.LDAPListenerConfig

@Mutable
@ThreadSafety(level=NOT_THREADSAFE)
public final class LDAPListenerConfig
extends java.lang.Object

This class provides a mechanism for defining the configuration to use for an LDAPListener instance. Note that while instances of this class are not inherently threadsafe, a private copy of the configuration will be created whenever a new LDAPListener is created so that this configuration may continue to be altered for new instances without impacting any existing listeners.


Constructor Summary
LDAPListenerConfig(int listenPort, LDAPListenerRequestHandler requestHandler)
          Creates a new listener configuration.
 
Method Summary
 LDAPListenerConfig duplicate()
          Creates a copy of this configuration that may be altered without impacting this configuration, and which will not be altered by changes to this configuration.
 LDAPListenerExceptionHandler getExceptionHandler()
          Retrieves the exception handler that should be notified of any exceptions caught while attempting to accept or interact with a client connection.
 int getLingerTimeoutSeconds()
          Retrieves the timeout in seconds that should be used if the SO_LINGER socket option is enabled.
 java.net.InetAddress getListenAddress()
          Retrieves the address on which to listen for client connections, if defined.
 int getListenPort()
          Retrieves the port number on which to listen for client connections.
 int getMaxConnections()
          Retrieves the maximum number of concurrent connections that the listener will allow.
 int getReceiveBufferSize()
          Retrieves the receive buffer size that should be used for sockets accepted by the listener.
 LDAPListenerRequestHandler getRequestHandler()
          Retrieves the LDAP listener request handler that should be used to process requests read from clients.
 int getSendBufferSize()
          Retrieves the send buffer size that should be used for sockets accepted by the listener.
 javax.net.ServerSocketFactory getServerSocketFactory()
          Retrieves the factory that will be used to create the server socket that will listen for client connections.
 void setExceptionHandler(LDAPListenerExceptionHandler exceptionHandler)
          Specifies the exception handler that should be notified of any exceptions caught while attempting to accept or interact with a client connection.
 void setLingerTimeoutSeconds(int lingerTimeout)
          Specifies the timeout in seconds that should be used if the SO_LINGER socket option is enabled.
 void setListenAddress(java.net.InetAddress listenAddress)
          Specifies the address on which to listen for client connections.
 void setListenPort(int listenPort)
          Specifies the port number on which to listen for client connections.
 void setMaxConnections(int maxConnections)
          Specifies the maximum number of concurrent connections that the listener will allow.
 void setReceiveBufferSize(int receiveBufferSize)
          Specifies the receive buffer size that should be used for sockets accepted by the listener.
 void setRequestHandler(LDAPListenerRequestHandler requestHandler)
          Specifies the LDAP listener request handler that should be used to process requests read from clients.
 void setSendBufferSize(int sendBufferSize)
          Specifies the send buffer size that should be used for sockets accepted by the listener.
 void setServerSocketFactory(javax.net.ServerSocketFactory serverSocketFactory)
          Specifies the factory that will be used to create the server socket that will listen for client connections.
 void setUseKeepAlive(boolean useKeepAlive)
          Specifies whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.
 void setUseLinger(boolean useLinger)
          Specifies whether to use the SO_LINGER socket option for sockets accepted by the listener.
 void setUseReuseAddress(boolean useReuseAddress)
          Specifies whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.
 void setUseTCPNoDelay(boolean useTCPNoDelay)
          Specifies whether to use the TCP_NODELAY socket option for sockets accepted by the listener.
 java.lang.String toString()
          Retrieves a string representation of this LDAP listener config.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this LDAP listener config to the provided buffer.
 boolean useKeepAlive()
          Indicates whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.
 boolean useLinger()
          Indicates whether to use the SO_LINGER socket option for sockets accepted by the listener.
 boolean useReuseAddress()
          Indicates whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.
 boolean useTCPNoDelay()
          Indicates whether to use the TCP_NODELAY socket option for sockets accepted by the listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LDAPListenerConfig

public LDAPListenerConfig(int listenPort,
                          LDAPListenerRequestHandler requestHandler)
Creates a new listener configuration.

Parameters:
listenPort - The port on which to listen for client connections. It must be an integer between 1 and 65535, or 0 to indicate that a free port should be chosen by the JVM.
requestHandler - The request handler that will be used to process requests read from clients. It must not be null.
Method Detail

getListenPort

public int getListenPort()
Retrieves the port number on which to listen for client connections. A value of zero indicates that the listener should allow the JVM to choose a free port.

Returns:
The port number on which to listen for client connections.

setListenPort

public void setListenPort(int listenPort)
Specifies the port number on which to listen for client connections. The provided value must be between 1 and 65535, or it may be 0 to indicate that the JVM should select a free port on the system.

Parameters:
listenPort - The port number on which to listen for client connections.

getRequestHandler

public LDAPListenerRequestHandler getRequestHandler()
Retrieves the LDAP listener request handler that should be used to process requests read from clients.

Returns:
The LDAP listener request handler that should be used to process requests read from clients.

setRequestHandler

public void setRequestHandler(LDAPListenerRequestHandler requestHandler)
Specifies the LDAP listener request handler that should be used to process requests read from clients.

Parameters:
requestHandler - The LDAP listener request handler that should be used to process requests read from clients. It must not be null.

useKeepAlive

public boolean useKeepAlive()
Indicates whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.

Returns:
true if the SO_KEEPALIVE socket option should be used for sockets accepted by the listener, or false if not.

setUseKeepAlive

public void setUseKeepAlive(boolean useKeepAlive)
Specifies whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.

Parameters:
useKeepAlive - Indicates whether to use the SO_KEEPALIVE socket option for sockets accepted by the listener.

useLinger

public boolean useLinger()
Indicates whether to use the SO_LINGER socket option for sockets accepted by the listener.

Returns:
true if the SO_LINGER socket option should be used for sockets accepted by the listener, or false if not.

setUseLinger

public void setUseLinger(boolean useLinger)
Specifies whether to use the SO_LINGER socket option for sockets accepted by the listener.

Parameters:
useLinger - Indicates whether to use the SO_LINGER socket option for sockets accepted by the listener.

useReuseAddress

public boolean useReuseAddress()
Indicates whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.

Returns:
true if the SO_REUSEADDR socket option should be used for sockets accepted by the listener, or false if not.

setUseReuseAddress

public void setUseReuseAddress(boolean useReuseAddress)
Specifies whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.

Parameters:
useReuseAddress - Indicates whether to use the SO_REUSEADDR socket option for sockets accepted by the listener.

useTCPNoDelay

public boolean useTCPNoDelay()
Indicates whether to use the TCP_NODELAY socket option for sockets accepted by the listener.

Returns:
true if the TCP_NODELAY socket option should be used for sockets accepted by the listener, or false if not.

setUseTCPNoDelay

public void setUseTCPNoDelay(boolean useTCPNoDelay)
Specifies whether to use the TCP_NODELAY socket option for sockets accepted by the listener.

Parameters:
useTCPNoDelay - Indicates whether to use the TCP_NODELAY socket option for sockets accepted by the listener.

getListenAddress

public java.net.InetAddress getListenAddress()
Retrieves the address on which to listen for client connections, if defined.

Returns:
The address on which to listen for client connections, or null if it should listen on all available addresses on all interfaces.

setListenAddress

public void setListenAddress(java.net.InetAddress listenAddress)
Specifies the address on which to listen for client connections.

Parameters:
listenAddress - The address on which to listen for client connections. It may be null to indicate that it should listen on all available addresses on all interfaces.

getLingerTimeoutSeconds

public int getLingerTimeoutSeconds()
Retrieves the timeout in seconds that should be used if the SO_LINGER socket option is enabled.

Returns:
The timeout in seconds that should be used if the SO_LINGER socket option is enabled.

setLingerTimeoutSeconds

public void setLingerTimeoutSeconds(int lingerTimeout)
Specifies the timeout in seconds that should be used if the SO_LINGER socket option is enabled.

Parameters:
lingerTimeout - The timeout in seconds that should be used if the SO_LINGER socket option is enabled. The value must be between 0 and 65535, inclusive.

getMaxConnections

public int getMaxConnections()
Retrieves the maximum number of concurrent connections that the listener will allow. If a client tries to establish a new connection while the listener already has the maximum number of concurrent connections, then the new connection will be rejected.

Returns:
The maximum number of concurrent connections that the listener will allow, or zero if no limit should be enforced.

setMaxConnections

public void setMaxConnections(int maxConnections)
Specifies the maximum number of concurrent connections that the listener will allow. If a client tries to establish a new connection while the listener already has the maximum number of concurrent connections, then the new connection will be rejected.

Parameters:
maxConnections - The maximum number of concurrent connections that the listener will allow. A value that is less than or equal to zero indicates no limit.

getReceiveBufferSize

public int getReceiveBufferSize()
Retrieves the receive buffer size that should be used for sockets accepted by the listener.

Returns:
The receive buffer size that should be used for sockets accepted by the listener, or 0 if the default receive buffer size should be used.

setReceiveBufferSize

public void setReceiveBufferSize(int receiveBufferSize)
Specifies the receive buffer size that should be used for sockets accepted by the listener. A value less than or equal to zero indicates that the default receive buffer size should be used.

Parameters:
receiveBufferSize - The receive buffer size that should be used for sockets accepted by the listener.

getSendBufferSize

public int getSendBufferSize()
Retrieves the send buffer size that should be used for sockets accepted by the listener.

Returns:
The send buffer size that should be used for sockets accepted by the listener, or 0 if the default send buffer size should be used.

setSendBufferSize

public void setSendBufferSize(int sendBufferSize)
Specifies the send buffer size that should be used for sockets accepted by the listener. A value less than or equal to zero indicates that the default send buffer size should be used.

Parameters:
sendBufferSize - The send buffer size that should be used for sockets accepted by the listener.

getExceptionHandler

public LDAPListenerExceptionHandler getExceptionHandler()
Retrieves the exception handler that should be notified of any exceptions caught while attempting to accept or interact with a client connection.

Returns:
The exception handler that should be notified of any exceptions caught while attempting to accept or interact with a client connection, or null if none is defined.

setExceptionHandler

public void setExceptionHandler(LDAPListenerExceptionHandler exceptionHandler)
Specifies the exception handler that should be notified of any exceptions caught while attempting to accept or interact with a client connection.

Parameters:
exceptionHandler - The exception handler that should be notified of any exceptions encountered during processing. It may be null if no exception handler should be used.

getServerSocketFactory

public javax.net.ServerSocketFactory getServerSocketFactory()
Retrieves the factory that will be used to create the server socket that will listen for client connections.

Returns:
The factory that will be used to create the server socket that will listen for client connections.

setServerSocketFactory

public void setServerSocketFactory(javax.net.ServerSocketFactory serverSocketFactory)
Specifies the factory that will be used to create the server socket that will listen for client connections.

Parameters:
serverSocketFactory - The factory that will be used to create the server socket that will listen for client connections. It may be null to use the JVM-default server socket factory.

duplicate

public LDAPListenerConfig duplicate()
Creates a copy of this configuration that may be altered without impacting this configuration, and which will not be altered by changes to this configuration.

Returns:
A copy of this configuration that may be altered without impacting this configuration, and which will not be altered by changes to this configuration.

toString

public java.lang.String toString()
Retrieves a string representation of this LDAP listener config.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of this LDAP listener config.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP listener config to the provided buffer.

Parameters:
buffer - The buffer to which the information should be appended.