Package org.ldaptive.transport
Class DefaultSearchOperationHandle
- java.lang.Object
-
- org.ldaptive.transport.DefaultOperationHandle<SearchRequest,SearchResponse>
-
- org.ldaptive.transport.DefaultSearchOperationHandle
-
- All Implemented Interfaces:
OperationHandle<SearchRequest,SearchResponse>
,SearchOperationHandle
public final class DefaultSearchOperationHandle extends DefaultOperationHandle<SearchRequest,SearchResponse> implements SearchOperationHandle
Handle that notifies on the components of a search request.
-
-
Field Summary
Fields Modifier and Type Field Description private int
entryCount
Number of entries received.private LdapEntryHandler[]
onEntry
Functions to handle response entries.private SearchReferenceHandler[]
onReference
Functions to handle response references.private SearchResultHandler[]
onSearchResult
Functions to handle complete response.private SearchResponse
result
Synthetic result that is built as entries and references are received.private static Predicate<Message>
SEARCH_RESPONSE_TIMEOUT_CONDITION
Predicate that requires any message except unsolicited.private static boolean
SORT_RESULTS
Whether to automatically sort search results.-
Fields inherited from class org.ldaptive.transport.DefaultOperationHandle
logger
-
-
Constructor Summary
Constructors Constructor Description DefaultSearchOperationHandle(SearchRequest req, TransportConnection conn, Duration timeout)
Creates a new search operation handle.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SearchResponse
await()
Waits for a result or reports a timeout exception.void
entry(LdapEntry r)
InvokesonEntry
.protected void
evaluateThrowCondition(Result r)
InvokesDefaultOperationHandle.throwCondition
, if it exists, for the supplied result.LdapEntryHandler[]
getOnEntry()
SearchReferenceHandler[]
getOnReference()
SearchResultHandler[]
getOnSearchResult()
protected Predicate<Message>
getResponseTimeoutCondition()
Returns a predicate to determine whether the responseTimeout semaphore should be released.DefaultSearchOperationHandle
onComplete(CompleteHandler function)
Sets the function to execute when the operation completes.DefaultSearchOperationHandle
onControl(ResponseControlHandler... function)
Sets the functions to execute when a control is received.DefaultSearchOperationHandle
onEntry(LdapEntryHandler... function)
Sets the functions to execute when a search result entry is received.DefaultSearchOperationHandle
onException(ExceptionHandler function)
Sets the function to execute when an exception occurs.DefaultSearchOperationHandle
onIntermediate(IntermediateResponseHandler... function)
Sets the functions to execute when an intermediate response is received.DefaultSearchOperationHandle
onReference(SearchReferenceHandler... function)
Sets the functions to execute when a search result reference is received.DefaultSearchOperationHandle
onReferral(ReferralHandler... function)
Sets the functions to execute when a referral is received.DefaultSearchOperationHandle
onReferralResult(ReferralResultHandler<SearchResponse> function)
Sets the functions to execute when a response is complete and contains a referral result code.DefaultSearchOperationHandle
onResult(ResultHandler... function)
Sets the functions to execute when a result is received.DefaultSearchOperationHandle
onSearchResult(SearchResultHandler... function)
Sets the functions to execute when a search result is complete.DefaultSearchOperationHandle
onUnsolicitedNotification(UnsolicitedNotificationHandler... function)
Sets the functions to execute when an unsolicited notification is received.void
reference(SearchResultReference r)
InvokesonReference
.void
result(SearchResponse r)
InvokesDefaultOperationHandle.onResult
and sets the result.DefaultSearchOperationHandle
send()
Sends this request to the server.DefaultSearchOperationHandle
throwIf(ResultPredicate function)
Sets the function to determine whether an exception should be raised by a particular result.String
toString()
-
Methods inherited from class org.ldaptive.transport.DefaultOperationHandle
abandon, abandon, cancel, consumedMessage, consumedMessage, control, exception, finalizeResult, getMessageID, getOnComplete, getOnControl, getOnException, getOnIntermediate, getOnReferral, getOnReferralResult, getOnResult, getOnUnsolicitedNotification, getReceivedTime, getRequest, getSentTime, getThrowCondition, hasConsumedMessage, initializeMessageFunctional, initializeMessageFunctional, intermediate, messageID, processReferralResult, processResult, referral, sent, unsolicitedNotification
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ldaptive.OperationHandle
abandon, cancel, getReceivedTime, getSentTime
-
Methods inherited from interface org.ldaptive.SearchOperationHandle
execute
-
-
-
-
Field Detail
-
SEARCH_RESPONSE_TIMEOUT_CONDITION
private static final Predicate<Message> SEARCH_RESPONSE_TIMEOUT_CONDITION
Predicate that requires any message except unsolicited.
-
SORT_RESULTS
private static final boolean SORT_RESULTS
Whether to automatically sort search results.
-
result
private final SearchResponse result
Synthetic result that is built as entries and references are received.
-
entryCount
private int entryCount
Number of entries received.
-
onEntry
private LdapEntryHandler[] onEntry
Functions to handle response entries.
-
onReference
private SearchReferenceHandler[] onReference
Functions to handle response references.
-
onSearchResult
private SearchResultHandler[] onSearchResult
Functions to handle complete response.
-
-
Constructor Detail
-
DefaultSearchOperationHandle
public DefaultSearchOperationHandle(SearchRequest req, TransportConnection conn, Duration timeout)
Creates a new search operation handle.- Parameters:
req
- search request to expect a response forconn
- the request will be executed ontimeout
- duration to wait for a response
-
-
Method Detail
-
getResponseTimeoutCondition
protected Predicate<Message> getResponseTimeoutCondition()
Description copied from class:DefaultOperationHandle
Returns a predicate to determine whether the responseTimeout semaphore should be released.- Overrides:
getResponseTimeoutCondition
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Returns:
- response timeout condition
-
send
public DefaultSearchOperationHandle send()
Description copied from interface:OperationHandle
Sends this request to the server.- Specified by:
send
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
send
in interfaceSearchOperationHandle
- Overrides:
send
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Returns:
- this handle
-
await
public SearchResponse await() throws LdapException
Description copied from interface:OperationHandle
Waits for a result or reports a timeout exception.- Specified by:
await
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
await
in interfaceSearchOperationHandle
- Overrides:
await
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Returns:
- result of the operation or empty if the operation is abandoned
- Throws:
LdapException
- if an error occurs executing the request
-
evaluateThrowCondition
protected void evaluateThrowCondition(Result r)
Description copied from class:DefaultOperationHandle
InvokesDefaultOperationHandle.throwCondition
, if it exists, for the supplied result.- Overrides:
evaluateThrowCondition
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
r
- to evaluate
-
onResult
public DefaultSearchOperationHandle onResult(ResultHandler... function)
Description copied from interface:OperationHandle
Sets the functions to execute when a result is received.- Specified by:
onResult
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
onResult
in interfaceSearchOperationHandle
- Overrides:
onResult
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
function
- to execute on a result- Returns:
- this handle
-
onControl
public DefaultSearchOperationHandle onControl(ResponseControlHandler... function)
Description copied from interface:OperationHandle
Sets the functions to execute when a control is received.- Specified by:
onControl
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
onControl
in interfaceSearchOperationHandle
- Overrides:
onControl
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
function
- to execute on a control- Returns:
- this handle
-
onReferral
public DefaultSearchOperationHandle onReferral(ReferralHandler... function)
Description copied from interface:OperationHandle
Sets the functions to execute when a referral is received.- Specified by:
onReferral
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
onReferral
in interfaceSearchOperationHandle
- Overrides:
onReferral
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
function
- to execute on a referral- Returns:
- this handle
-
onIntermediate
public DefaultSearchOperationHandle onIntermediate(IntermediateResponseHandler... function)
Description copied from interface:OperationHandle
Sets the functions to execute when an intermediate response is received.- Specified by:
onIntermediate
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
onIntermediate
in interfaceSearchOperationHandle
- Overrides:
onIntermediate
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
function
- to execute on an intermediate response- Returns:
- this handle
-
onUnsolicitedNotification
public DefaultSearchOperationHandle onUnsolicitedNotification(UnsolicitedNotificationHandler... function)
Description copied from interface:OperationHandle
Sets the functions to execute when an unsolicited notification is received.- Specified by:
onUnsolicitedNotification
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
onUnsolicitedNotification
in interfaceSearchOperationHandle
- Overrides:
onUnsolicitedNotification
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
function
- to execute on an unsolicited notification- Returns:
- this handle
-
onReferralResult
public DefaultSearchOperationHandle onReferralResult(ReferralResultHandler<SearchResponse> function)
Description copied from interface:OperationHandle
Sets the functions to execute when a response is complete and contains a referral result code.- Specified by:
onReferralResult
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
onReferralResult
in interfaceSearchOperationHandle
- Overrides:
onReferralResult
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
function
- to execute on a referral response- Returns:
- this handle
-
onException
public DefaultSearchOperationHandle onException(ExceptionHandler function)
Description copied from interface:OperationHandle
Sets the function to execute when an exception occurs.- Specified by:
onException
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
onException
in interfaceSearchOperationHandle
- Overrides:
onException
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
function
- to execute when an exception occurs- Returns:
- this handle
-
throwIf
public DefaultSearchOperationHandle throwIf(ResultPredicate function)
Description copied from interface:OperationHandle
Sets the function to determine whether an exception should be raised by a particular result.- Specified by:
throwIf
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
throwIf
in interfaceSearchOperationHandle
- Overrides:
throwIf
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
function
- to determine whether to throw an exception- Returns:
- this handle
-
onComplete
public DefaultSearchOperationHandle onComplete(CompleteHandler function)
Description copied from interface:OperationHandle
Sets the function to execute when the operation completes.- Specified by:
onComplete
in interfaceOperationHandle<SearchRequest,SearchResponse>
- Specified by:
onComplete
in interfaceSearchOperationHandle
- Overrides:
onComplete
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
function
- to execute on completion- Returns:
- this handle
-
onEntry
public DefaultSearchOperationHandle onEntry(LdapEntryHandler... function)
Description copied from interface:SearchOperationHandle
Sets the functions to execute when a search result entry is received.- Specified by:
onEntry
in interfaceSearchOperationHandle
- Parameters:
function
- to execute on a search result entry- Returns:
- this handle
-
onReference
public DefaultSearchOperationHandle onReference(SearchReferenceHandler... function)
Description copied from interface:SearchOperationHandle
Sets the functions to execute when a search result reference is received.- Specified by:
onReference
in interfaceSearchOperationHandle
- Parameters:
function
- to execute on a search result reference- Returns:
- this handle
-
onSearchResult
public DefaultSearchOperationHandle onSearchResult(SearchResultHandler... function)
Description copied from interface:SearchOperationHandle
Sets the functions to execute when a search result is complete.- Specified by:
onSearchResult
in interfaceSearchOperationHandle
- Parameters:
function
- to execute on a search result- Returns:
- this handle
-
getOnEntry
public LdapEntryHandler[] getOnEntry()
-
getOnReference
public SearchReferenceHandler[] getOnReference()
-
getOnSearchResult
public SearchResultHandler[] getOnSearchResult()
-
reference
public void reference(SearchResultReference r)
InvokesonReference
.- Parameters:
r
- search result reference
-
result
public void result(SearchResponse r)
Description copied from class:DefaultOperationHandle
InvokesDefaultOperationHandle.onResult
and sets the result. Handle is considered done when this is invoked.- Overrides:
result
in classDefaultOperationHandle<SearchRequest,SearchResponse>
- Parameters:
r
- result
-
toString
public String toString()
- Overrides:
toString
in classDefaultOperationHandle<SearchRequest,SearchResponse>
-
-