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 associated Request.
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 the LdapPromise.
See Also:
  • Method Details

    • handleIntermediateResponse

      public final boolean handleIntermediateResponse(IntermediateResponse response)
      Description copied from interface: IntermediateResponseHandler
      Invoked each time an intermediate response is returned from the Directory Server.
      Specified by:
      handleIntermediateResponse in interface IntermediateResponseHandler
      Parameters:
      response - The intermediate response.
      Returns:
      true if this handler should continue to be notified of any remaining intermediate responses, or false if the remaining responses should be skipped for some reason (e.g. a client side size limit has been reached).
    • isBindOrStartTLS

      public boolean isBindOrStartTLS()
      Returns true if this promise represents the result of a bind or StartTLS request. The default implementation is to return false.
      Returns:
      true if this promise represents the result of a bind or StartTLS request.
    • toString

      public String toString()
      Returns a string representation of this promise's state.
      Overrides:
      toString in class Object
      Returns:
      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()
      Returns true if this request should be canceled once the timeout period expires. The default implementation is to return true which will be appropriate for nearly all requests, the one obvious exception being persistent searches.
      Returns:
      true if this request should be canceled once the timeout period expires.
    • getRequestID

      public int getRequestID()
      Description copied from interface: LdapPromise
      Returns the request ID of the request if appropriate.
      Specified by:
      getRequestID in interface LdapPromise<R>
      Returns:
      The request ID, or -1 if there is no request ID.
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      Specified by:
      cancel in interface Future<R>
      Specified by:
      cancel in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • get

      Specified by:
      get in interface Future<R>
      Specified by:
      get in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      ExecutionException
      InterruptedException
    • get

      public S get(long timeout, TimeUnit unit) throws ExecutionException, TimeoutException, InterruptedException
      Specified by:
      get in interface Future<R>
      Specified by:
      get in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      ExecutionException
      TimeoutException
      InterruptedException
    • getOrThrow

      public S getOrThrow() throws InterruptedException, LdapException
      Specified by:
      getOrThrow in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      InterruptedException
      LdapException
    • getOrThrow

      public S getOrThrow(long timeout, TimeUnit unit) throws InterruptedException, LdapException, TimeoutException
      Specified by:
      getOrThrow in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      InterruptedException
      LdapException
      TimeoutException
    • getOrThrowUninterruptibly

      public S getOrThrowUninterruptibly() throws LdapException
      Specified by:
      getOrThrowUninterruptibly in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      LdapException
    • getOrThrowUninterruptibly

      public S getOrThrowUninterruptibly(long timeout, TimeUnit unit) throws LdapException, TimeoutException
      Specified by:
      getOrThrowUninterruptibly in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
      Throws:
      LdapException
      TimeoutException
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Future<R>
      Specified by:
      isCancelled in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface Future<R>
      Specified by:
      isDone in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnException

      public LdapPromise<S> thenOnException(org.forgerock.util.promise.ExceptionHandler<? super LdapException> onException)
      Specified by:
      thenOnException in interface LdapPromise<R>
      Specified by:
      thenOnException in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnRuntimeException

      public LdapPromise<S> thenOnRuntimeException(org.forgerock.util.promise.RuntimeExceptionHandler onRuntimeException)
      Specified by:
      thenOnRuntimeException in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnResult

      public LdapPromise<S> thenOnResult(org.forgerock.util.promise.ResultHandler<? super S> onResult)
      Specified by:
      thenOnResult in interface LdapPromise<R>
      Specified by:
      thenOnResult in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnResultOrException

      public LdapPromise<S> thenOnResultOrException(Runnable onResultOrException)
      Specified by:
      thenOnResultOrException in interface LdapPromise<R>
      Specified by:
      thenOnResultOrException in interface org.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 S,VOUT,LdapException> onResult)
      Specified by:
      then in interface LdapPromise<R>
      Specified by:
      then in interface org.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 S,VOUT,EOUT> onResult, org.forgerock.util.Function<? super LdapException,VOUT,EOUT> onException)
      Specified by:
      then in interface org.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 S,VOUT,EOUT> onResult, org.forgerock.util.Function<? super LdapException,VOUT,EOUT> onException, org.forgerock.util.Function<? super RuntimeException,VOUT,EOUT> onRuntimeException)
      Specified by:
      then in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenOnResultOrException

      public LdapPromise<S> thenOnResultOrException(org.forgerock.util.promise.ResultHandler<? super S> onResult, org.forgerock.util.promise.ExceptionHandler<? super LdapException> onException)
      Specified by:
      thenOnResultOrException in interface LdapPromise<R>
      Specified by:
      thenOnResultOrException in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenAlways

      public LdapPromise<S> thenAlways(Runnable onResultOrException)
      Specified by:
      thenAlways in interface LdapPromise<R>
      Specified by:
      thenAlways in interface org.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 S,VOUT,LdapException> onResult)
      Specified by:
      thenAsync in interface LdapPromise<R>
      Specified by:
      thenAsync in interface org.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 S,VOUT,EOUT> onResult, org.forgerock.util.AsyncFunction<? super LdapException,VOUT,EOUT> onException)
      Specified by:
      thenAsync in interface org.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 S,VOUT,EOUT> onResult, org.forgerock.util.AsyncFunction<? super LdapException,VOUT,EOUT> onException, org.forgerock.util.AsyncFunction<? super RuntimeException,VOUT,EOUT> onRuntimeException)
      Specified by:
      thenAsync in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenCatch

      public <EOUT extends Exception> org.forgerock.util.promise.Promise<S,EOUT> thenCatch(org.forgerock.util.Function<? super LdapException,S,EOUT> onException)
      Specified by:
      thenCatch in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenCatchRuntimeException

      public org.forgerock.util.promise.Promise<S,LdapException> thenCatchRuntimeException(org.forgerock.util.Function<? super RuntimeException,S,LdapException> onRuntimeException)
      Specified by:
      thenCatchRuntimeException in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenCatchRuntimeExceptionAsync

      public org.forgerock.util.promise.Promise<S,LdapException> thenCatchRuntimeExceptionAsync(org.forgerock.util.AsyncFunction<? super RuntimeException,S,LdapException> onRuntimeException)
      Specified by:
      thenCatchRuntimeExceptionAsync in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenFinally

      public LdapPromise<S> thenFinally(Runnable onResultOrException)
      Specified by:
      thenFinally in interface LdapPromise<R>
      Specified by:
      thenFinally in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • thenCatchAsync

      public <EOUT extends Exception> org.forgerock.util.promise.Promise<S,EOUT> thenCatchAsync(org.forgerock.util.AsyncFunction<? super LdapException,S,EOUT> onException)
      Specified by:
      thenCatchAsync in interface org.forgerock.util.promise.Promise<R,P extends org.forgerock.util.promise.Promise<R,LdapException>>
    • getWrappedPromise

      public org.forgerock.util.promise.PromiseImpl<S,LdapException> getWrappedPromise()