Package org.forgerock.opendj.ldap.spi
Class ResultLdapPromiseImpl<R extends Request,S extends Result>
- java.lang.Object
-
- org.forgerock.opendj.ldap.spi.LdapPromiseImpl<S>
-
- org.forgerock.opendj.ldap.spi.ResultLdapPromiseImpl<R,S>
-
- Type Parameters:
R- The type of the associatedRequest.S- The type of result returned by this promise.
- All Implemented Interfaces:
Future<S>,IntermediateResponseHandler,LdapPromise<S>,LdapResultHandler<S>,org.forgerock.util.promise.ExceptionHandler<LdapException>,org.forgerock.util.promise.Promise<S,LdapException>,org.forgerock.util.promise.ResultHandler<S>
- Direct Known Subclasses:
BindResultLdapPromiseImpl,ExtendedResultLdapPromiseImpl,SearchResultLdapPromiseImpl
public abstract class ResultLdapPromiseImpl<R extends Request,S extends Result> extends LdapPromiseImpl<S> implements LdapPromise<S>, IntermediateResponseHandler
This class provides an implementation of theLdapPromise.- See Also:
Promise,Promises,LdapPromise
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadaptErrorResult(Result result)Sets the result associated to this promise as an error result.booleancancel(boolean mayInterruptIfRunning)booleancheckForTimeout()Returnstrueif this request should be canceled once the timeout period expires.Rget()Rget(long timeout, TimeUnit unit)RgetOrThrow()RgetOrThrow(long timeout, TimeUnit unit)RgetOrThrowUninterruptibly()RgetOrThrowUninterruptibly(long timeout, TimeUnit unit)RgetRequest()Returns the attached request.intgetRequestID()Returns the request ID of the request if appropriate.longgetTimestamp()Returns the creation time of this promise.PgetWrappedPromise()booleanhandleIntermediateResponse(IntermediateResponse response)Invoked each time an intermediate response is returned from the Directory Server.booleanisBindOrStartTLS()Returnstrueif this promise represents the result of a bind or StartTLS request.booleanisCancelled()booleanisDone()voidsetResultOrError(S result)Sets the result associated to this promise.<VOUT,EOUT extends Exception>
org.forgerock.util.promise.Promise<VOUT,EOUT>then(org.forgerock.util.Function<? super R,VOUT,EOUT> onResult, org.forgerock.util.Function<? super LdapException,VOUT,EOUT> onException)<VOUT,EOUT extends Exception>
org.forgerock.util.promise.Promise<VOUT,EOUT>then(org.forgerock.util.Function<? super R,VOUT,EOUT> onResult, org.forgerock.util.Function<? super LdapException,VOUT,EOUT> onException, org.forgerock.util.Function<? super RuntimeException,VOUT,EOUT> onRuntimeException)<VOUT> LdapPromise<VOUT>then(org.forgerock.util.Function<? super R,VOUT,LdapException> onResult)LdapPromise<R>thenAlways(Runnable onResultOrException)<VOUT,EOUT extends Exception>
org.forgerock.util.promise.Promise<VOUT,EOUT>thenAsync(org.forgerock.util.AsyncFunction<? super R,VOUT,EOUT> onResult, org.forgerock.util.AsyncFunction<? super LdapException,VOUT,EOUT> onException)<VOUT,EOUT extends Exception>
org.forgerock.util.promise.Promise<VOUT,EOUT>thenAsync(org.forgerock.util.AsyncFunction<? super R,VOUT,EOUT> onResult, org.forgerock.util.AsyncFunction<? super LdapException,VOUT,EOUT> onException, org.forgerock.util.AsyncFunction<? super RuntimeException,VOUT,EOUT> onRuntimeException)<VOUT> LdapPromise<VOUT>thenAsync(org.forgerock.util.AsyncFunction<? super R,VOUT,LdapException> onResult)<EOUT extends Exception>
org.forgerock.util.promise.Promise<R,EOUT>thenCatch(org.forgerock.util.Function<? super LdapException,R,EOUT> onException)<EOUT extends Exception>
org.forgerock.util.promise.Promise<R,EOUT>thenCatchAsync(org.forgerock.util.AsyncFunction<? super LdapException,R,EOUT> onException)org.forgerock.util.promise.Promise<R,LdapException>thenCatchRuntimeException(org.forgerock.util.Function<? super RuntimeException,R,LdapException> onRuntimeException)org.forgerock.util.promise.Promise<R,LdapException>thenCatchRuntimeExceptionAsync(org.forgerock.util.AsyncFunction<? super RuntimeException,R,LdapException> onRuntimeException)LdapPromise<R>thenFinally(Runnable onResultOrException)LdapPromise<R>thenOnException(org.forgerock.util.promise.ExceptionHandler<? super LdapException> onException)LdapPromise<R>thenOnResult(org.forgerock.util.promise.ResultHandler<? super R> onResult)LdapPromise<R>thenOnResultOrException(Runnable onResultOrException)LdapPromise<R>thenOnResultOrException(org.forgerock.util.promise.ResultHandler<? super R> onResult, org.forgerock.util.promise.ExceptionHandler<? super LdapException> onException)LdapPromise<R>thenOnRuntimeException(org.forgerock.util.promise.RuntimeExceptionHandler onRuntimeException)StringtoString()Returns a string representation of this promise's state.-
Methods inherited from class org.forgerock.opendj.ldap.spi.LdapPromiseImpl
handleException, handleResult, newLdapPromiseImpl, newLdapPromiseImpl
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.forgerock.opendj.ldap.LdapPromise
getRequestID, then, thenAlways, thenAsync, thenFinally, thenOnException, thenOnResult, thenOnResultOrException, thenOnResultOrException
-
Methods inherited from interface org.forgerock.util.promise.Promise
cancel, get, get, getOrThrow, getOrThrow, getOrThrowUninterruptibly, getOrThrowUninterruptibly, isCancelled, isDone, then, then, thenAsync, thenAsync, thenCatch, thenCatchAsync, thenCatchRuntimeException, thenCatchRuntimeExceptionAsync, thenOnRuntimeException
-
-
-
-
Method Detail
-
handleIntermediateResponse
public final boolean handleIntermediateResponse(IntermediateResponse response)
Description copied from interface:IntermediateResponseHandlerInvoked each time an intermediate response is returned from the Directory Server.- Specified by:
handleIntermediateResponsein interfaceIntermediateResponseHandler- Parameters:
response- The intermediate response.- Returns:
trueif this handler should continue to be notified of any remaining intermediate responses, orfalseif the remaining responses should be skipped for some reason (e.g. a client side size limit has been reached).
-
isBindOrStartTLS
public boolean isBindOrStartTLS()
Returnstrueif this promise represents the result of a bind or StartTLS request. The default implementation is to returnfalse.- Returns:
trueif this promise represents the result of a bind or StartTLS request.
-
toString
public String toString()
Returns a string representation of this promise's state.
-
adaptErrorResult
public final void adaptErrorResult(Result result)
Sets the result associated to this promise as an error result.- Parameters:
result- result of an operation
-
getTimestamp
public final long getTimestamp()
Returns the creation time of this promise.- Returns:
- the timestamp indicating creation time of this promise
-
setResultOrError
public final void setResultOrError(S result)
Sets the result associated to this promise.- Parameters:
result- the result of operation
-
getRequest
public R getRequest()
Returns the attached request.- Returns:
- The request.
-
checkForTimeout
public boolean checkForTimeout()
Returnstrueif this request should be canceled once the timeout period expires. The default implementation is to returntruewhich will be appropriate for nearly all requests, the one obvious exception being persistent searches.- Returns:
trueif this request should be canceled once the timeout period expires.
-
getRequestID
public int getRequestID()
Description copied from interface:LdapPromiseReturns the request ID of the request if appropriate.- Specified by:
getRequestIDin interfaceLdapPromise<R>- Returns:
- The request ID, or
-1if there is no request ID.
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancelin interfaceFuture<R>- Specified by:
cancelin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
get
public R get() throws ExecutionException, InterruptedException- Specified by:
getin interfaceFuture<R>- Specified by:
getin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>- Throws:
ExecutionExceptionInterruptedException
-
get
public R get(long timeout, TimeUnit unit) throws ExecutionException, TimeoutException, InterruptedException- Specified by:
getin interfaceFuture<R>- Specified by:
getin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>- Throws:
ExecutionExceptionTimeoutExceptionInterruptedException
-
getOrThrow
public R getOrThrow() throws InterruptedException, LdapException- Specified by:
getOrThrowin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>- Throws:
InterruptedExceptionLdapException
-
getOrThrow
public R getOrThrow(long timeout, TimeUnit unit) throws InterruptedException, LdapException, TimeoutException- Specified by:
getOrThrowin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>- Throws:
InterruptedExceptionLdapExceptionTimeoutException
-
getOrThrowUninterruptibly
public R getOrThrowUninterruptibly() throws LdapException- Specified by:
getOrThrowUninterruptiblyin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>- Throws:
LdapException
-
getOrThrowUninterruptibly
public R getOrThrowUninterruptibly(long timeout, TimeUnit unit) throws LdapException, TimeoutException- Specified by:
getOrThrowUninterruptiblyin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>- Throws:
LdapExceptionTimeoutException
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture<R>- Specified by:
isCancelledin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfaceFuture<R>- Specified by:
isDonein interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenOnException
public LdapPromise<R> thenOnException(org.forgerock.util.promise.ExceptionHandler<? super LdapException> onException)
- Specified by:
thenOnExceptionin interfaceLdapPromise<R>- Specified by:
thenOnExceptionin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenOnRuntimeException
public LdapPromise<R> thenOnRuntimeException(org.forgerock.util.promise.RuntimeExceptionHandler onRuntimeException)
- Specified by:
thenOnRuntimeExceptionin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenOnResult
public LdapPromise<R> thenOnResult(org.forgerock.util.promise.ResultHandler<? super R> onResult)
- Specified by:
thenOnResultin interfaceLdapPromise<R>- Specified by:
thenOnResultin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenOnResultOrException
public LdapPromise<R> thenOnResultOrException(Runnable onResultOrException)
- Specified by:
thenOnResultOrExceptionin interfaceLdapPromise<R>- Specified by:
thenOnResultOrExceptionin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
then
public <VOUT> LdapPromise<VOUT> then(org.forgerock.util.Function<? super R,VOUT,LdapException> onResult)
- Specified by:
thenin interfaceLdapPromise<R>- Specified by:
thenin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
then
public <VOUT,EOUT extends Exception> org.forgerock.util.promise.Promise<VOUT,EOUT> then(org.forgerock.util.Function<? super R,VOUT,EOUT> onResult, org.forgerock.util.Function<? super LdapException,VOUT,EOUT> onException)
- Specified by:
thenin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
then
public <VOUT,EOUT extends Exception> org.forgerock.util.promise.Promise<VOUT,EOUT> then(org.forgerock.util.Function<? super R,VOUT,EOUT> onResult, org.forgerock.util.Function<? super LdapException,VOUT,EOUT> onException, org.forgerock.util.Function<? super RuntimeException,VOUT,EOUT> onRuntimeException)
- Specified by:
thenin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenOnResultOrException
public LdapPromise<R> thenOnResultOrException(org.forgerock.util.promise.ResultHandler<? super R> onResult, org.forgerock.util.promise.ExceptionHandler<? super LdapException> onException)
- Specified by:
thenOnResultOrExceptionin interfaceLdapPromise<R>- Specified by:
thenOnResultOrExceptionin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenAlways
public LdapPromise<R> thenAlways(Runnable onResultOrException)
- Specified by:
thenAlwaysin interfaceLdapPromise<R>- Specified by:
thenAlwaysin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenAsync
public <VOUT> LdapPromise<VOUT> thenAsync(org.forgerock.util.AsyncFunction<? super R,VOUT,LdapException> onResult)
- Specified by:
thenAsyncin interfaceLdapPromise<R>- Specified by:
thenAsyncin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenAsync
public <VOUT,EOUT extends Exception> org.forgerock.util.promise.Promise<VOUT,EOUT> thenAsync(org.forgerock.util.AsyncFunction<? super R,VOUT,EOUT> onResult, org.forgerock.util.AsyncFunction<? super LdapException,VOUT,EOUT> onException)
- Specified by:
thenAsyncin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenAsync
public <VOUT,EOUT extends Exception> org.forgerock.util.promise.Promise<VOUT,EOUT> thenAsync(org.forgerock.util.AsyncFunction<? super R,VOUT,EOUT> onResult, org.forgerock.util.AsyncFunction<? super LdapException,VOUT,EOUT> onException, org.forgerock.util.AsyncFunction<? super RuntimeException,VOUT,EOUT> onRuntimeException)
- Specified by:
thenAsyncin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenCatch
public <EOUT extends Exception> org.forgerock.util.promise.Promise<R,EOUT> thenCatch(org.forgerock.util.Function<? super LdapException,R,EOUT> onException)
- Specified by:
thenCatchin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenCatchRuntimeException
public org.forgerock.util.promise.Promise<R,LdapException> thenCatchRuntimeException(org.forgerock.util.Function<? super RuntimeException,R,LdapException> onRuntimeException)
- Specified by:
thenCatchRuntimeExceptionin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenCatchRuntimeExceptionAsync
public org.forgerock.util.promise.Promise<R,LdapException> thenCatchRuntimeExceptionAsync(org.forgerock.util.AsyncFunction<? super RuntimeException,R,LdapException> onRuntimeException)
- Specified by:
thenCatchRuntimeExceptionAsyncin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenFinally
public LdapPromise<R> thenFinally(Runnable onResultOrException)
- Specified by:
thenFinallyin interfaceLdapPromise<R>- Specified by:
thenFinallyin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
thenCatchAsync
public <EOUT extends Exception> org.forgerock.util.promise.Promise<R,EOUT> thenCatchAsync(org.forgerock.util.AsyncFunction<? super LdapException,R,EOUT> onException)
- Specified by:
thenCatchAsyncin interfaceorg.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
-
getWrappedPromise
public P getWrappedPromise()
-
-