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.Logger
logger
Logger 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 void
abandon()
Abandons this operation.void
abandon(LdapException cause)
Abandons this operation.S
await()
Waits for a result or reports a timeout exception.ExtendedOperationHandle
cancel()
Cancels this operation.protected void
consumedMessage()
Indicates that a protocol message was consumed by a supplied consumer.void
control(ResponseControl c)
InvokesonControl
.void
exception(LdapException e)
InvokesonException
followed bycomplete()
.java.lang.Integer
getMessageID()
Returns the message ID assigned to this handle.CompleteHandler
getOnComplete()
ResponseControlHandler[]
getOnControl()
ExceptionHandler
getOnException()
IntermediateResponseHandler[]
getOnIntermediate()
ReferralHandler[]
getOnReferral()
ResultHandler[]
getOnResult()
UnsolicitedNotificationHandler[]
getOnUnsolicitedNotification()
java.time.Instant
getReceivedTime()
Returns the time this operation received a result or encountered an exception.Request
getRequest()
Returns the request.java.time.Instant
getSentTime()
Returns the time this operation sent a request.ResultPredicate
getThrowCondition()
boolean
hasConsumedMessage()
Returns whether this handle has consumed any messages.protected void
initializeMessageFunctional(java.lang.Object... functions)
Iterates over the supplied functions, set the connection and request if the type isMessageFunctional
.void
intermediate(IntermediateResponse r)
InvokesonIntermediate
.void
messageID(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.void
referral(java.lang.String... url)
InvokesonReferral
.void
result(S r)
InvokesonResult
and sets the result.DefaultOperationHandle<Q,S>
send()
Sends this request to the server.void
sent()
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.String
toString()
void
unsolicitedNotification(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:OperationHandle
Sends this request to the server.
-
await
public S await() throws LdapException
Description copied from interface:OperationHandle
Waits for a result or reports a timeout exception.- Specified by:
await
in 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:OperationHandle
Sets the functions to execute when a result is received.
-
onControl
public DefaultOperationHandle<Q,S> onControl(ResponseControlHandler... function)
Description copied from interface:OperationHandle
Sets the functions to execute when a control is received.
-
onReferral
public DefaultOperationHandle<Q,S> onReferral(ReferralHandler... function)
Description copied from interface:OperationHandle
Sets the functions to execute when a referral is received.- Specified by:
onReferral
in 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:OperationHandle
Sets the functions to execute when an intermediate response is received.- Specified by:
onIntermediate
in 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:OperationHandle
Sets the functions to execute when an unsolicited notification is received.- Specified by:
onUnsolicitedNotification
in 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:OperationHandle
Sets the function to execute when an exception occurs.- Specified by:
onException
in 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:OperationHandle
Sets the function to execute when the operation completes.- Specified by:
onComplete
in 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:OperationHandle
Sets 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:OperationHandle
Abandons 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:OperationHandle
Cancels 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:OperationHandle
Returns the time this operation sent a request.- Specified by:
getSentTime
in interfaceOperationHandle<Q extends Request,S extends Result>
- Returns:
- sent time
-
getReceivedTime
public java.time.Instant getReceivedTime()
Description copied from interface:OperationHandle
Returns the time this operation received a result or encountered an exception.- Specified by:
getReceivedTime
in 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)
InvokesonResult
and 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)
InvokesonException
followed 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:
toString
in classjava.lang.Object
-
-