netscape.ldap
Class LDAPSearchListener
java.lang.Object
|
+--netscape.ldap.LDAPMessageQueue
|
+--netscape.ldap.LDAPSearchListener
- public class LDAPSearchListener
- extends netscape.ldap.LDAPMessageQueue
Manages search results, references and responses returned on one or
more search requests
Method Summary |
int[] |
getIDs()
Returns message IDs for all outstanding requests |
LDAPMessage |
getResponse()
Blocks until a search result, reference or response is available,
or until all operations associated with the object have completed
or been canceled. |
boolean |
isResponseReceived()
Reports true if a response has been received from the server. |
void |
merge(LDAPSearchListener listener2)
Merge two search listeners
Move/append the content from another search listener to this one. |
Methods inherited from class netscape.ldap.LDAPMessageQueue |
getMessageCount,
getRequestCount,
toString |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
getResponse
public LDAPMessage getResponse()
throws LDAPException
- Blocks until a search result, reference or response is available,
or until all operations associated with the object have completed
or been canceled.
- Returns:
- a search result, search reference, search response message,
or null if there are no more outstanding requests.
- Throws:
- LDAPException - Network error exception
- LDAPInterruptedException - The invoking thread was interrupted
- See Also:
LDAPResponse
,
LDAPSearchResult
,
LDAPSearchResultReference
merge
public void merge(LDAPSearchListener listener2)
- Merge two search listeners
Move/append the content from another search 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.getIDs(), 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.getIDs().
The proper way to handle this scenario is to create a separate listener
for each new request, and after l.getIDs() 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.
getIDs
public int[] getIDs()
- Returns message IDs for all outstanding requests
- Returns:
- message ID array.