@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class AsyncRequestID extends java.lang.Object implements java.io.Serializable, java.util.concurrent.Future<LDAPResult>
java.util.concurrent.Future
interface, so it may be used in that
manner.
Modification mod = new Modification(ModificationType.REPLACE, "description", "This is the new description."); ModifyRequest modifyRequest = new ModifyRequest("dc=example,dc=com", mod); AsyncRequestID asyncRequestID = connection.asyncModify(modifyRequest, myAsyncResultListener); // Assume that we've waited a reasonable amount of time but the modify // hasn't completed yet so we'll try to abandon it. connection.abandon(asyncRequestID);
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
Attempts to cancel the associated asynchronous operation operation.
|
boolean |
equals(java.lang.Object o)
Indicates whether the provided object is equal to this async request ID.
|
LDAPResult |
get()
Attempts to get the result for the associated operation, waiting if
necessary for it to complete.
|
LDAPResult |
get(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Attempts to get the result for the associated operation, waiting if
necessary for up to the specified length of time for the operation to
complete.
|
int |
getMessageID()
Retrieves the message ID for the associated request.
|
int |
hashCode()
Retrieves a hash code for this async request ID.
|
boolean |
isCancelled()
Indicates whether an attempt has been made to cancel the associated
operation before it completed.
|
boolean |
isDone()
Indicates whether the associated operation has completed, regardless of
whether it completed normally, completed with an error, or was canceled
before starting.
|
java.lang.String |
toString()
Retrieves a string representation of this async request ID.
|
public int getMessageID()
public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface java.util.concurrent.Future<LDAPResult>
mayInterruptIfRunning
- Indicates whether to interrupt the thread
running the associated task. This will be
ignored.true
if an abandon request was sent to cancel the
associated operation, or false
if it was not possible to
send an abandon request because the operation has already
completed, because an abandon request has already been sent, or
because an error occurred while trying to send the cancel request.public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<LDAPResult>
true
if an attempt was made to cancel the operation, or
false
if no cancel attempt was made, or if the operation
completed before it could be canceled.public boolean isDone()
isDone
in interface java.util.concurrent.Future<LDAPResult>
true
if the associated operation has completed, or if an
attempt has been made to cancel it, or false
if the
operation has not yet completed and no cancel attempt has been
made.@NotNull public LDAPResult get() throws java.lang.InterruptedException
java.util.concurrent.Future
API in that it
will not wait forever. Rather, it will wait for no more than the length of
time specified as the maximum response time defined in the connection
options for the connection used to send the asynchronous request. This is
necessary because the operation may have been abandoned or otherwise
interrupted, or the associated connection may have become invalidated, in
a way that the LDAP SDK cannot detect.get
in interface java.util.concurrent.Future<LDAPResult>
java.lang.InterruptedException
- If the thread calling this method was
interrupted before a result was received.@NotNull public LDAPResult get(long timeout, @NotNull java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
get
in interface java.util.concurrent.Future<LDAPResult>
timeout
- The maximum length of time to wait for the response.timeUnit
- The time unit for the provided timeout
value.java.lang.InterruptedException
- If the thread calling this method was
interrupted before a result was received.java.util.concurrent.TimeoutException
- If a timeout was encountered before the result
could be obtained.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(@Nullable java.lang.Object o)
equals
in class java.lang.Object
o
- The object for which to make the determination.true
if the provided object is equal to this async request
ID, or false
if not.