com.unboundid.ldap.listener
Class LDAPListener

java.lang.Object
  extended by java.lang.Thread
      extended by com.unboundid.ldap.listener.LDAPListener
All Implemented Interfaces:
java.lang.Runnable

@ThreadSafety(level=NOT_THREADSAFE)
public final class LDAPListener
extends java.lang.Thread

This class provides a mechanism that may be used to accept connections from LDAP clients and ensure that any requests received on those connections will be processed appropriately.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
LDAPListener(LDAPListenerConfig config)
          Creates a new LDAPListener object with the provided configuration.
 
Method Summary
 java.net.InetAddress getListenAddress()
          Retrieves the address on which this listener is accepting client connections.
 int getListenPort()
          Retrieves the port on which this listener is accepting client connections.
 void run()
          Operates in a loop, waiting for client connections to arrive and ensuring that they are handled properly.
 void shutDown(boolean closeExisting)
          Indicates that this listener should stop accepting connections.
 void startListening()
          Creates the server socket for this listener and starts listening for client connections.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LDAPListener

public LDAPListener(LDAPListenerConfig config)
Creates a new LDAPListener object with the provided configuration. The Thread.start() method must be called after creating the object to actually start listening for requests.

Parameters:
config - The configuration to use for this listener.
Method Detail

startListening

public void startListening()
                    throws java.io.IOException
Creates the server socket for this listener and starts listening for client connections. This method will return after the listener has stated.

Throws:
java.io.IOException - If a problem occurs while creating the server socket.

run

@InternalUseOnly
public void run()
Operates in a loop, waiting for client connections to arrive and ensuring that they are handled properly. This method is for internal use only and must not be called by third-party code.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

shutDown

public void shutDown(boolean closeExisting)
Indicates that this listener should stop accepting connections. It may optionally also terminate any existing connections that are already established.

Parameters:
closeExisting - Indicates whether to close existing connections that may already be established.

getListenAddress

public java.net.InetAddress getListenAddress()
Retrieves the address on which this listener is accepting client connections. Note that if no explicit listen address was configured, then the address returned may not be usable by clients. In the event that the InetAddress.isAnyLocalAddress method returns true, then clients should generally use localhost to attempt to establish connections.

Returns:
The address on which this listener is accepting client connections, or null if it is not currently listening for client connections.

getListenPort

public int getListenPort()
Retrieves the port on which this listener is accepting client connections.

Returns:
The port on which this listener is accepting client connections, or -1 if it is not currently listening for client connections.