netscape.ldap
Class LDAPResponseListener

java.lang.Object
  extended by netscape.ldap.LDAPMessageQueue
      extended by netscape.ldap.LDAPResponseListener
All Implemented Interfaces:
java.io.Serializable

public class LDAPResponseListener
extends LDAPMessageQueue

Represents the message queue associated with a particular LDAP operation or operations.

See Also:
Serialized Form

Field Summary
(package private) static long serialVersionUID
           
 
Constructor Summary
LDAPResponseListener(boolean asynchOp)
          Constructor
 
Method Summary
 int[] getMessageIDs()
          Returns message IDs for all outstanding requests
 LDAPResponse getResponse()
          Blocks until a response is available, or until all operations associated with the object have completed or been canceled, and returns the response.
 boolean isResponseReceived()
          Reports true if a response has been received from the server.
 void merge(LDAPResponseListener listener2)
          Merge two response listeners.
 
Methods inherited from class netscape.ldap.LDAPMessageQueue
addMessage, addRequest, completeRequest, getAllMessages, getConnection, getConnThread, getMessageCount, getMessageID, getRequestCount, isAsynchOp, isMessageReceived, merge, nextMessage, removeAllRequests, removeRequest, reset, setException, toString, waitFirstMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

LDAPResponseListener

LDAPResponseListener(boolean asynchOp)
Constructor

Parameters:
asynchOp - a boolean flag that is true if the object is used for asynchronous LDAP operations
See Also:
LDAPAsynchronousConnection
Method Detail

getResponse

public LDAPResponse getResponse()
                         throws LDAPException
Blocks until a response is available, or until all operations associated with the object have completed or been canceled, and returns the response.

Returns:
a response for an LDAP operation or null if there are no more outstanding requests.
Throws:
LDAPException - Network error exception
LDAPInterruptedException - The invoking thread was interrupted

merge

public void merge(LDAPResponseListener listener2)
Merge two response listeners. Move/append the content from another response listener to this one.

To be used for synchronization of asynchronous LDAP operations where requests are sent by one thread but processed by another one.

A client may be implemented in such a way that one thread makes LDAP requests and calls l.getMessageIDs(), while another thread is responsible for processing of responses (call l.getResponse()). Both threads are using the same listener objects. In such a case, a race condition may occur, where a LDAP response message is retrieved and the request terminated (request ID removed) before the first thread has a chance to execute l.getMessageIDs(). The proper way to handle this scenario is to create a separate listener for each new request, and after l.getMessageIDs() has been invoked, merge the new request with the existing one.

Parameters:
listener2 - the listener with which to merge

isResponseReceived

public boolean isResponseReceived()
Reports true if a response has been received from the server.

Returns:
a flag indicating whether the response message queue is empty.

getMessageIDs

public int[] getMessageIDs()
Returns message IDs for all outstanding requests

Overrides:
getMessageIDs in class LDAPMessageQueue
Returns:
message ID array.