netscape.ldap
Class LDAPConnThread

java.lang.Object
  extended bynetscape.ldap.LDAPConnThread
All Implemented Interfaces:
java.lang.Runnable

class LDAPConnThread
extends java.lang.Object
implements java.lang.Runnable

Multiple LDAPConnection clones can share a single physical connection, which is maintained by a thread. +----------------+ | LDAPConnection | --------+ +----------------+ | | +----------------+ | +----------------+ | LDAPConnection | --------+------- | LDAPConnThread | +----------------+ | +----------------+ | +----------------+ | | LDAPConnection | --------+ +----------------+ All LDAPConnections send requests and get responses from LDAPConnThread (a thread).


Field Summary
(package private) static java.text.SimpleDateFormat m_timeFormat
           
 
Constructor Summary
LDAPConnThread(LDAPConnSetupMgr connMgr, LDAPCache cache, java.lang.Object traceOutput)
          Constructs a connection thread that maintains connection to the LDAP server.
 
Method Summary
(package private)  void abandon(int id, LDAPControl[] ctrls)
          Stop dispatching responses for a particular message ID and send the abandon request.
(package private)  LDAPMessageQueue changeListener(int id, LDAPMessageQueue toNotify)
          Change listener for a message ID.
(package private)  void connect(LDAPConnection ldc)
           
(package private)  void deregister(LDAPConnection conn)
          De-Register with this connection thread.
(package private)  int getClientCount()
           
(package private)  java.io.InputStream getInputStream()
           
(package private)  java.io.OutputStream getOutputStream()
           
(package private)  int getRequestCount()
           
(package private)  boolean isBound()
           
(package private)  boolean isConnected()
           
(package private)  void layerSocket(LDAPTLSSocketFactory factory)
          Layer a SSL socket over the current non-SSL one
(package private)  void logTraceMessage(java.lang.StringBuffer msg)
           
 void register(LDAPConnection conn)
          Register with this connection thread.
(package private)  void resultRetrieved()
          This is called when a search result has been retrieved from the incoming queue.
 void run()
          Reads from the LDAP server input stream for incoming LDAP messages.
(package private)  void sendRequest(LDAPConnection conn, JDAPProtocolOp request, LDAPMessageQueue toNotify, LDAPConstraints cons)
          Sends LDAP request via this connection thread.
(package private)  void setBound(boolean bound)
           
(package private)  void setCache(LDAPCache cache)
          Set the cache to use for searches.
(package private)  void setInputStream(java.io.InputStream is)
           
(package private)  void setOutputStream(java.io.OutputStream os)
           
(package private)  void setTraceOutput(java.lang.Object traceOutput)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_timeFormat

static java.text.SimpleDateFormat m_timeFormat
Constructor Detail

LDAPConnThread

public LDAPConnThread(LDAPConnSetupMgr connMgr,
                      LDAPCache cache,
                      java.lang.Object traceOutput)
Constructs a connection thread that maintains connection to the LDAP server.

Parameters:
connMgr - the connection setup manager
cache - cache object or null
traceOutput - trace object or null
Method Detail

connect

void connect(LDAPConnection ldc)
       throws LDAPException
Throws:
LDAPException

toString

public java.lang.String toString()

layerSocket

void layerSocket(LDAPTLSSocketFactory factory)
           throws java.lang.Exception
Layer a SSL socket over the current non-SSL one

Throws:
java.lang.Exception

setBound

void setBound(boolean bound)

isBound

boolean isBound()

getInputStream

java.io.InputStream getInputStream()

setInputStream

void setInputStream(java.io.InputStream is)

getOutputStream

java.io.OutputStream getOutputStream()

setOutputStream

void setOutputStream(java.io.OutputStream os)

getRequestCount

int getRequestCount()

setTraceOutput

void setTraceOutput(java.lang.Object traceOutput)

logTraceMessage

void logTraceMessage(java.lang.StringBuffer msg)

setCache

void setCache(LDAPCache cache)
Set the cache to use for searches.

Parameters:
cache - The cache to use for searches; null for no cache

sendRequest

void sendRequest(LDAPConnection conn,
                 JDAPProtocolOp request,
                 LDAPMessageQueue toNotify,
                 LDAPConstraints cons)
           throws LDAPException
Sends LDAP request via this connection thread.

Parameters:
request - request to send
toNotify - response listener to invoke when the response is ready
Throws:
LDAPException

register

public void register(LDAPConnection conn)
Register with this connection thread.

Parameters:
conn - LDAP connection

getClientCount

int getClientCount()

isConnected

boolean isConnected()

deregister

void deregister(LDAPConnection conn)
De-Register with this connection thread. If all the connection is deregistered. Then, this thread should be killed.

Parameters:
conn - LDAP connection

resultRetrieved

void resultRetrieved()
This is called when a search result has been retrieved from the incoming queue. We use the notification to unblock the listener thread, if it is waiting for the backlog to lighten.


run

public void run()
Reads from the LDAP server input stream for incoming LDAP messages.

Specified by:
run in interface java.lang.Runnable

abandon

void abandon(int id,
             LDAPControl[] ctrls)
Stop dispatching responses for a particular message ID and send the abandon request.

Parameters:
id - Message ID for which to discard responses.

changeListener

LDAPMessageQueue changeListener(int id,
                                LDAPMessageQueue toNotify)
Change listener for a message ID. Required when LDAPMessageQueue.merge() is invoked.

Parameters:
id - Message ID for which to chanage the listener.
Returns:
Previous listener.