public final class LDAPListener extends Object implements Closeable
ServerConnection
created using the provided ServerConnectionFactory
.
When processing requests, ServerConnection
implementations are passed
an integer as the first parameter. This integer represents the
requestID
associated with the client request and corresponds to the
requestID
passed as a parameter to abandon and cancel extended
requests. The request ID may also be useful for logging purposes.
An LDAPListener
does not require ServerConnection
implementations to return a result when processing requests. More
specifically, an LDAPListener
does not maintain any internal state
information associated with each request which must be released. This is
useful when implementing LDAP abandon operations which may prevent results
being sent for abandoned operations.
The following code illustrates how to create a simple LDAP server:
class MyClientConnection implements ServerConnection<Integer> { private final LDAPClientContext clientContext; private MyClientConnection(LDAPClientContext clientContext) { this.clientContext = clientContext; } public void add(Integer requestID, AddRequest request, ResultHandler<Result> handler, IntermediateResponseHandler intermediateResponseHandler) throws UnsupportedOperationException { // ... } // ... } class MyServer implements ServerConnectionFactory<LDAPClientContext, RequestContext> { public ServerConnection<RequestContext> accept(LDAPClientContext context) { System.out.println("Connection from: " + context.getPeerAddress()); return new MyClientConnection(context); } } public static void main(String[] args) throws Exception { LDAPListener listener = new LDAPListener(1389, new MyServer()); // ... listener.close(); }
Modifier and Type | Field and Description |
---|---|
static Option<Integer> |
CONNECT_MAX_BACKLOG
Specifies the maximum queue length for incoming connections requests.
|
static Option<DecodeOptions> |
LDAP_DECODE_OPTIONS
Sets the decoding options which will be used to control how requests and responses are decoded.
|
static Option<Integer> |
REQUEST_MAX_SIZE_IN_BYTES
Specifies the maximum request size in bytes for incoming LDAP requests.
|
static Option<Boolean> |
SO_KEEPALIVE
Specifies the value of the
SO_KEEPALIVE socket option for new connections. |
static Option<Integer> |
SO_LINGER_IN_SECONDS
Specifies the value of the
SO_LINGER socket option for new connections. |
static Option<Boolean> |
SO_REUSE_ADDRESS
Specifies the value of the
SO_REUSEADDR socket option for new connections. |
static Option<Boolean> |
TCP_NO_DELAY
Specifies the value of the
TCP_NODELAY socket option for new connections. |
static Option<String> |
TRANSPORT_PROVIDER
Specifies the name of the provider to use for transport.
|
static Option<ClassLoader> |
TRANSPORT_PROVIDER_CLASS_LOADER
Specifies the class loader which will be used to load the
TransportProvider . |
Constructor and Description |
---|
LDAPListener(InetSocketAddress address,
ServerConnectionFactory<LDAPClientContext,Integer> factory)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(InetSocketAddress address,
ServerConnectionFactory<LDAPClientContext,Integer> factory,
Options options)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(int port,
ServerConnectionFactory<LDAPClientContext,Integer> factory)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(int port,
ServerConnectionFactory<LDAPClientContext,Integer> factory,
Options options)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(String host,
int port,
ServerConnectionFactory<LDAPClientContext,Integer> factory)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
LDAPListener(String host,
int port,
ServerConnectionFactory<LDAPClientContext,Integer> factory,
Options options)
Creates a new LDAP listener implementation which will listen for LDAP
client connections at the provided address.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this LDAP connection listener.
|
InetAddress |
getAddress()
Returns the
InetAddress that this LDAP listener is listening on. |
String |
getHostName()
Returns the host name that this LDAP listener is listening on.
|
int |
getPort()
Returns the port that this LDAP listener is listening on.
|
String |
getProviderName()
Returns the name of the transport provider, which provides the implementation
of this factory.
|
InetSocketAddress |
getSocketAddress()
Returns the address that this LDAP listener is listening on.
|
String |
toString() |
public static final Option<Integer> CONNECT_MAX_BACKLOG
public static final Option<Integer> REQUEST_MAX_SIZE_IN_BYTES
public static final Option<ClassLoader> TRANSPORT_PROVIDER_CLASS_LOADER
TransportProvider
.
By default the default class loader will be used.
The transport provider is loaded using java.util.ServiceLoader
,
the JDK service-provider loading facility. The provider must be
accessible from the same class loader that was initially queried to
locate the configuration file; note that this is not necessarily the
class loader from which the file was actually loaded. This method allows
to provide a class loader to be used for loading the provider.
public static final Option<String> TRANSPORT_PROVIDER
Transport providers implement TransportProvider
interface.
The name should correspond to the name of an existing provider, as
returned by TransportProvider#getName()
method.
public static final Option<Boolean> TCP_NO_DELAY
TCP_NODELAY
socket option for new connections.
The default setting is true
and may be configured using the
org.forgerock.opendj.io.tcpNoDelay
property.
public static final Option<Boolean> SO_REUSE_ADDRESS
SO_REUSEADDR
socket option for new connections.
The default setting is true
and may be configured using the
org.forgerock.opendj.io.reuseAddress
property.
public static final Option<Integer> SO_LINGER_IN_SECONDS
SO_LINGER
socket option for new connections.
The default setting is -1
(disabled) and may be configured using
the org.forgerock.opendj.io.linger
property.
public static final Option<Boolean> SO_KEEPALIVE
SO_KEEPALIVE
socket option for new connections.
The default setting is true
and may be configured using the
org.forgerock.opendj.io.keepAlive
property.
public static final Option<DecodeOptions> LDAP_DECODE_OPTIONS
public LDAPListener(int port, ServerConnectionFactory<LDAPClientContext,Integer> factory) throws IOException
port
- The port to listen on.factory
- The server connection factory which will be used to create
server connections.IOException
- If an error occurred while trying to listen on the provided
address.NullPointerException
- If {code factory} was null
.public LDAPListener(int port, ServerConnectionFactory<LDAPClientContext,Integer> factory, Options options) throws IOException
port
- The port to listen on.factory
- The server connection factory which will be used to create
server connections.options
- The LDAP listener options.IOException
- If an error occurred while trying to listen on the provided
address.NullPointerException
- If {code factory} or options
was null
.public LDAPListener(InetSocketAddress address, ServerConnectionFactory<LDAPClientContext,Integer> factory) throws IOException
address
- The address to listen on.factory
- The server connection factory which will be used to create
server connections.IOException
- If an error occurred while trying to listen on the provided
address.NullPointerException
- If address
or {code factory} was null
.public LDAPListener(InetSocketAddress address, ServerConnectionFactory<LDAPClientContext,Integer> factory, Options options) throws IOException
address
- The address to listen on.factory
- The server connection factory which will be used to create
server connections.options
- The LDAP listener options.IOException
- If an error occurred while trying to listen on the provided
address.NullPointerException
- If address
, {code factory}, or options
was
null
.public LDAPListener(String host, int port, ServerConnectionFactory<LDAPClientContext,Integer> factory) throws IOException
host
- The address to listen on.port
- The port to listen on.factory
- The server connection factory which will be used to create
server connections.IOException
- If an error occurred while trying to listen on the provided
address.NullPointerException
- If host
or {code factory} was null
.public LDAPListener(String host, int port, ServerConnectionFactory<LDAPClientContext,Integer> factory, Options options) throws IOException
host
- The address to listen on.port
- The port to listen on.factory
- The server connection factory which will be used to create
server connections.options
- The LDAP listener options.IOException
- If an error occurred while trying to listen on the provided
address.NullPointerException
- If host
, {code factory}, or options
was
null
.public void close()
close
in interface Closeable
close
in interface AutoCloseable
public InetAddress getAddress()
InetAddress
that this LDAP listener is listening on.InetAddress
that this LDAP listener is listening on.public String getHostName()
public int getPort()
public InetSocketAddress getSocketAddress()
public String getProviderName()
Copyright 2010-2017 ForgeRock AS.