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 intentryCountNumber of entries received.private LdapEntryHandler[]onEntryFunctions to handle response entries.private SearchReferenceHandler[]onReferenceFunctions to handle response references.private SearchResultHandler[]onSearchResultFunctions to handle complete response.private SearchResponseresultSynthetic result that is built as entries and references are received.private static Predicate<Message>SEARCH_RESPONSE_TIMEOUT_CONDITIONPredicate that requires any message except unsolicited.private static booleanSORT_RESULTSWhether 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 SearchResponseawait()Waits for a result or reports a timeout exception.voidentry(LdapEntry r)InvokesonEntry.protected voidevaluateThrowCondition(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.DefaultSearchOperationHandleonComplete(CompleteHandler function)Sets the function to execute when the operation completes.DefaultSearchOperationHandleonControl(ResponseControlHandler... function)Sets the functions to execute when a control is received.DefaultSearchOperationHandleonEntry(LdapEntryHandler... function)Sets the functions to execute when a search result entry is received.DefaultSearchOperationHandleonException(ExceptionHandler function)Sets the function to execute when an exception occurs.DefaultSearchOperationHandleonIntermediate(IntermediateResponseHandler... function)Sets the functions to execute when an intermediate response is received.DefaultSearchOperationHandleonReference(SearchReferenceHandler... function)Sets the functions to execute when a search result reference is received.DefaultSearchOperationHandleonReferral(ReferralHandler... function)Sets the functions to execute when a referral is received.DefaultSearchOperationHandleonReferralResult(ReferralResultHandler<SearchResponse> function)Sets the functions to execute when a response is complete and contains a referral result code.DefaultSearchOperationHandleonResult(ResultHandler... function)Sets the functions to execute when a result is received.DefaultSearchOperationHandleonSearchResult(SearchResultHandler... function)Sets the functions to execute when a search result is complete.DefaultSearchOperationHandleonUnsolicitedNotification(UnsolicitedNotificationHandler... function)Sets the functions to execute when an unsolicited notification is received.voidreference(SearchResultReference r)InvokesonReference.voidresult(SearchResponse r)InvokesDefaultOperationHandle.onResultand sets the result.DefaultSearchOperationHandlesend()Sends this request to the server.DefaultSearchOperationHandlethrowIf(ResultPredicate function)Sets the function to determine whether an exception should be raised by a particular result.StringtoString()-
Methods inherited from class org.ldaptive.transport.DefaultOperationHandle
abandon, abandon, cancel, consumedMessage, consumedMessage, control, exception, finalizeResult, getAbandonedTime, getMessageID, getOnComplete, getOnControl, getOnException, getOnIntermediate, getOnReferral, getOnReferralResult, getOnResult, getOnUnsolicitedNotification, getReceivedTime, getRequest, getSentTime, getThrowCondition, hasConsumedMessage, initializeMessageFunctional, initializeMessageFunctional, intermediate, messageID, notifyExceptionHandlers, processHandlerException, 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, getAbandonedTime, 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:DefaultOperationHandleReturns a predicate to determine whether the responseTimeout semaphore should be released.- Overrides:
getResponseTimeoutConditionin classDefaultOperationHandle<SearchRequest,SearchResponse>- Returns:
- response timeout condition
-
send
public DefaultSearchOperationHandle send()
Description copied from interface:OperationHandleSends this request to the server.- Specified by:
sendin interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
sendin interfaceSearchOperationHandle- Overrides:
sendin classDefaultOperationHandle<SearchRequest,SearchResponse>- Returns:
- this handle
-
await
public SearchResponse await() throws LdapException
Description copied from interface:OperationHandleWaits for a result or reports a timeout exception.- Specified by:
awaitin interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
awaitin interfaceSearchOperationHandle- Overrides:
awaitin 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:DefaultOperationHandleInvokesDefaultOperationHandle.throwCondition, if it exists, for the supplied result.- Overrides:
evaluateThrowConditionin classDefaultOperationHandle<SearchRequest,SearchResponse>- Parameters:
r- to evaluate
-
onResult
public DefaultSearchOperationHandle onResult(ResultHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when a result is received.- Specified by:
onResultin interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
onResultin interfaceSearchOperationHandle- Overrides:
onResultin classDefaultOperationHandle<SearchRequest,SearchResponse>- Parameters:
function- to execute on a result- Returns:
- this handle
-
onControl
public DefaultSearchOperationHandle onControl(ResponseControlHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when a control is received.- Specified by:
onControlin interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
onControlin interfaceSearchOperationHandle- Overrides:
onControlin classDefaultOperationHandle<SearchRequest,SearchResponse>- Parameters:
function- to execute on a control- Returns:
- this handle
-
onReferral
public DefaultSearchOperationHandle onReferral(ReferralHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when a referral is received.- Specified by:
onReferralin interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
onReferralin interfaceSearchOperationHandle- Overrides:
onReferralin classDefaultOperationHandle<SearchRequest,SearchResponse>- Parameters:
function- to execute on a referral- Returns:
- this handle
-
onIntermediate
public DefaultSearchOperationHandle onIntermediate(IntermediateResponseHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when an intermediate response is received.- Specified by:
onIntermediatein interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
onIntermediatein interfaceSearchOperationHandle- Overrides:
onIntermediatein classDefaultOperationHandle<SearchRequest,SearchResponse>- Parameters:
function- to execute on an intermediate response- Returns:
- this handle
-
onUnsolicitedNotification
public DefaultSearchOperationHandle onUnsolicitedNotification(UnsolicitedNotificationHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when an unsolicited notification is received.- Specified by:
onUnsolicitedNotificationin interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
onUnsolicitedNotificationin interfaceSearchOperationHandle- Overrides:
onUnsolicitedNotificationin 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:OperationHandleSets the functions to execute when a response is complete and contains a referral result code.- Specified by:
onReferralResultin interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
onReferralResultin interfaceSearchOperationHandle- Overrides:
onReferralResultin classDefaultOperationHandle<SearchRequest,SearchResponse>- Parameters:
function- to execute on a referral response- Returns:
- this handle
-
onException
public DefaultSearchOperationHandle onException(ExceptionHandler function)
Description copied from interface:OperationHandleSets the function to execute when an exception occurs.- Specified by:
onExceptionin interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
onExceptionin interfaceSearchOperationHandle- Overrides:
onExceptionin classDefaultOperationHandle<SearchRequest,SearchResponse>- Parameters:
function- to execute when an exception occurs- Returns:
- this handle
-
throwIf
public DefaultSearchOperationHandle throwIf(ResultPredicate function)
Description copied from interface:OperationHandleSets the function to determine whether an exception should be raised by a particular result.- Specified by:
throwIfin interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
throwIfin interfaceSearchOperationHandle- Overrides:
throwIfin 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:OperationHandleSets the function to execute when the operation completes.- Specified by:
onCompletein interfaceOperationHandle<SearchRequest,SearchResponse>- Specified by:
onCompletein interfaceSearchOperationHandle- Overrides:
onCompletein classDefaultOperationHandle<SearchRequest,SearchResponse>- Parameters:
function- to execute on completion- Returns:
- this handle
-
onEntry
public DefaultSearchOperationHandle onEntry(LdapEntryHandler... function)
Description copied from interface:SearchOperationHandleSets the functions to execute when a search result entry is received.- Specified by:
onEntryin interfaceSearchOperationHandle- Parameters:
function- to execute on a search result entry- Returns:
- this handle
-
onReference
public DefaultSearchOperationHandle onReference(SearchReferenceHandler... function)
Description copied from interface:SearchOperationHandleSets the functions to execute when a search result reference is received.- Specified by:
onReferencein interfaceSearchOperationHandle- Parameters:
function- to execute on a search result reference- Returns:
- this handle
-
onSearchResult
public DefaultSearchOperationHandle onSearchResult(SearchResultHandler... function)
Description copied from interface:SearchOperationHandleSets the functions to execute when a search result is complete.- Specified by:
onSearchResultin 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:DefaultOperationHandleInvokesDefaultOperationHandle.onResultand sets the result. Handle is considered done when this is invoked.- Overrides:
resultin classDefaultOperationHandle<SearchRequest,SearchResponse>- Parameters:
r- result
-
toString
public String toString()
- Overrides:
toStringin classDefaultOperationHandle<SearchRequest,SearchResponse>
-
-