Package org.ldaptive.transport
Class DefaultOperationHandle<Q extends Request,S extends Result>
- java.lang.Object
-
- org.ldaptive.transport.DefaultOperationHandle<Q,S>
-
- Type Parameters:
Q- type of requestS- type of result
- All Implemented Interfaces:
OperationHandle<Q,S>
- Direct Known Subclasses:
DefaultCompareOperationHandle,DefaultExtendedOperationHandle,DefaultSearchOperationHandle,NettyConnection.BindOperationHandle
public class DefaultOperationHandle<Q extends Request,S extends Result> extends java.lang.Object implements OperationHandle<Q,S>
Handle that notifies on the components of an LDAP operation request.- Author:
- Middleware Services
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.LoggerloggerLogger for this class.
-
Constructor Summary
Constructors Constructor Description DefaultOperationHandle(Q req, TransportConnection conn, java.time.Duration timeout)Creates a new operation handle.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabandon()Abandons this operation.voidabandon(LdapException cause)Abandons this operation.Sawait()Waits for a result or reports a timeout exception.ExtendedOperationHandlecancel()Cancels this operation.protected voidconsumedMessage()Indicates that a protocol message was consumed by a supplied consumer.voidcontrol(ResponseControl c)InvokesonControl.voidexception(LdapException e)InvokesonExceptionfollowed bycomplete().java.lang.IntegergetMessageID()Returns the message ID assigned to this handle.CompleteHandlergetOnComplete()ResponseControlHandler[]getOnControl()ExceptionHandlergetOnException()IntermediateResponseHandler[]getOnIntermediate()ReferralHandler[]getOnReferral()ResultHandler[]getOnResult()UnsolicitedNotificationHandler[]getOnUnsolicitedNotification()java.time.InstantgetReceivedTime()Returns the time this operation received a result or encountered an exception.RequestgetRequest()Returns the request.java.time.InstantgetSentTime()Returns the time this operation sent a request.ResultPredicategetThrowCondition()booleanhasConsumedMessage()Returns whether this handle has consumed any messages.protected voidinitializeMessageFunctional(java.lang.Object... functions)Iterates over the supplied functions, set the connection and request if the type isMessageFunctional.voidintermediate(IntermediateResponse r)InvokesonIntermediate.voidmessageID(int id)Sets the message ID.DefaultOperationHandle<Q,S>onComplete(CompleteHandler function)Sets the function to execute when the operation completes.DefaultOperationHandle<Q,S>onControl(ResponseControlHandler... function)Sets the functions to execute when a control is received.DefaultOperationHandle<Q,S>onException(ExceptionHandler function)Sets the function to execute when an exception occurs.DefaultOperationHandle<Q,S>onIntermediate(IntermediateResponseHandler... function)Sets the functions to execute when an intermediate response is received.DefaultOperationHandle<Q,S>onReferral(ReferralHandler... function)Sets the functions to execute when a referral is received.DefaultOperationHandle<Q,S>onResult(ResultHandler... function)Sets the functions to execute when a result is received.DefaultOperationHandle<Q,S>onUnsolicitedNotification(UnsolicitedNotificationHandler... function)Sets the functions to execute when an unsolicited notification is received.voidreferral(java.lang.String... url)InvokesonReferral.voidresult(S r)InvokesonResultand sets the result.DefaultOperationHandle<Q,S>send()Sends this request to the server.voidsent()Sets the sent time to now.DefaultOperationHandle<Q,S>throwIf(ResultPredicate function)Sets the function to determine whether an exception should be raised by a particular result.java.lang.StringtoString()voidunsolicitedNotification(UnsolicitedNotification u)InvokesonUnsolicitedNotification.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ldaptive.OperationHandle
execute
-
-
-
-
Constructor Detail
-
DefaultOperationHandle
public DefaultOperationHandle(Q req, TransportConnection conn, java.time.Duration timeout)
Creates a new operation handle.- Parameters:
req- request to expect a response forconn- the request will be executed ontimeout- duration to wait for a response
-
-
Method Detail
-
send
public DefaultOperationHandle<Q,S> send()
Description copied from interface:OperationHandleSends this request to the server.
-
await
public S await() throws LdapException
Description copied from interface:OperationHandleWaits for a result or reports a timeout exception.- Specified by:
awaitin interfaceOperationHandle<Q extends Request,S extends Result>- Returns:
- result of the operation or empty if the operation is abandoned
- Throws:
LdapException- if an error occurs executing the request
-
onResult
public DefaultOperationHandle<Q,S> onResult(ResultHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when a result is received.
-
onControl
public DefaultOperationHandle<Q,S> onControl(ResponseControlHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when a control is received.
-
onReferral
public DefaultOperationHandle<Q,S> onReferral(ReferralHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when a referral is received.- Specified by:
onReferralin interfaceOperationHandle<Q extends Request,S extends Result>- Parameters:
function- to execute on a referral- Returns:
- this handle
-
onIntermediate
public DefaultOperationHandle<Q,S> onIntermediate(IntermediateResponseHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when an intermediate response is received.- Specified by:
onIntermediatein interfaceOperationHandle<Q extends Request,S extends Result>- Parameters:
function- to execute on an intermediate response- Returns:
- this handle
-
onUnsolicitedNotification
public DefaultOperationHandle<Q,S> onUnsolicitedNotification(UnsolicitedNotificationHandler... function)
Description copied from interface:OperationHandleSets the functions to execute when an unsolicited notification is received.- Specified by:
onUnsolicitedNotificationin interfaceOperationHandle<Q extends Request,S extends Result>- Parameters:
function- to execute on an unsolicited notification- Returns:
- this handle
-
onException
public DefaultOperationHandle<Q,S> onException(ExceptionHandler function)
Description copied from interface:OperationHandleSets the function to execute when an exception occurs.- Specified by:
onExceptionin interfaceOperationHandle<Q extends Request,S extends Result>- Parameters:
function- to execute when an exception occurs- Returns:
- this handle
-
onComplete
public DefaultOperationHandle<Q,S> onComplete(CompleteHandler function)
Description copied from interface:OperationHandleSets the function to execute when the operation completes.- Specified by:
onCompletein interfaceOperationHandle<Q extends Request,S extends Result>- Parameters:
function- to execute on completion- Returns:
- this handle
-
throwIf
public DefaultOperationHandle<Q,S> throwIf(ResultPredicate function)
Description copied from interface:OperationHandleSets the function to determine whether an exception should be raised by a particular result.
-
initializeMessageFunctional
protected void initializeMessageFunctional(java.lang.Object... functions)
Iterates over the supplied functions, set the connection and request if the type isMessageFunctional.- Parameters:
functions- to initialize
-
abandon
public void abandon()
Description copied from interface:OperationHandleAbandons this operation.
-
abandon
public void abandon(LdapException cause)
Abandons this operation. Any threads waiting on the result will receive an empty result. SeeConnection.operation(AbandonRequest).- Parameters:
cause- the reason this request was abandoned
-
cancel
public ExtendedOperationHandle cancel()
Description copied from interface:OperationHandleCancels this operation. SeeCancelRequest.
-
getMessageID
public java.lang.Integer getMessageID()
Returns the message ID assigned to this handle.- Returns:
- message ID
-
getSentTime
public java.time.Instant getSentTime()
Description copied from interface:OperationHandleReturns the time this operation sent a request.- Specified by:
getSentTimein interfaceOperationHandle<Q extends Request,S extends Result>- Returns:
- sent time
-
getReceivedTime
public java.time.Instant getReceivedTime()
Description copied from interface:OperationHandleReturns the time this operation received a result or encountered an exception.- Specified by:
getReceivedTimein interfaceOperationHandle<Q extends Request,S extends Result>- Returns:
- received time
-
getOnResult
public ResultHandler[] getOnResult()
-
getOnControl
public ResponseControlHandler[] getOnControl()
-
getOnReferral
public ReferralHandler[] getOnReferral()
-
getOnIntermediate
public IntermediateResponseHandler[] getOnIntermediate()
-
getOnException
public ExceptionHandler getOnException()
-
getOnComplete
public CompleteHandler getOnComplete()
-
getThrowCondition
public ResultPredicate getThrowCondition()
-
getOnUnsolicitedNotification
public UnsolicitedNotificationHandler[] getOnUnsolicitedNotification()
-
hasConsumedMessage
public boolean hasConsumedMessage()
Returns whether this handle has consumed any messages.- Returns:
- whether this handle has consumed any messages
-
getRequest
public Request getRequest()
Returns the request.- Returns:
- request
-
messageID
public void messageID(int id)
Sets the message ID.- Parameters:
id- message ID
-
sent
public void sent()
Sets the sent time to now.
-
result
public void result(S r)
InvokesonResultand sets the result. Handle is considered done when this is invoked.- Parameters:
r- result
-
control
public void control(ResponseControl c)
InvokesonControl.- Parameters:
c- response control
-
referral
public void referral(java.lang.String... url)
InvokesonReferral.- Parameters:
url- referral url
-
intermediate
public void intermediate(IntermediateResponse r)
InvokesonIntermediate.- Parameters:
r- intermediate response
-
unsolicitedNotification
public void unsolicitedNotification(UnsolicitedNotification u)
InvokesonUnsolicitedNotification.- Parameters:
u- unsolicited notification
-
exception
public void exception(LdapException e)
InvokesonExceptionfollowed bycomplete().- Parameters:
e- exception
-
consumedMessage
protected void consumedMessage()
Indicates that a protocol message was consumed by a supplied consumer.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-