Class AsyncHandle<T>

  • Type Parameters:
    T - type of the operation output
    Direct Known Subclasses:
    DecoratorAsyncHandle

    public abstract class AsyncHandle<T>
    extends java.lang.Object
    This handle is used to complete an operation invocation (with an output value or an error) or report progress. The invocation will block until either setResult(Object) or setError(RuntimeException) marks the operation as complete.

    Completing the operation more than once is forbidden. Reporting progress after the operation is complete is forbidden for the service implementation (i.e. the server side). However on the client side progress updates might be delivered after the result. For example consider client with an application thread pool - the thread that delivers a progress update might be scheduled before the thread that delivers the result.

    Thread-safety: The implementation must be thread-safe. The methods of the callback might be invoked on different threads (for example consider client with an I/O reactor thread pool and/or an application thread pool).

    • Constructor Summary

      Constructors 
      Constructor Description
      AsyncHandle()  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract void setError​(java.lang.RuntimeException error)
      Completes the invocation with an error.
      abstract void setResult​(T result)
      Completes the invocation with an output value.
      abstract void updateProgress​(DataValue progress)
      Reports progress for the operation invocation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AsyncHandle

        public AsyncHandle()
    • Method Detail

      • updateProgress

        public abstract void updateProgress​(DataValue progress)
        Reports progress for the operation invocation. May be invoked multiple times.
        Parameters:
        progress - progress status of the operation invocation
        Throws:
        java.lang.IllegalStateException - if the operation is already completed
      • setResult

        public abstract void setResult​(T result)
        Completes the invocation with an output value. Must not be called after the operation is already completed (with either an output or an error).
        Parameters:
        result - operation output
        Throws:
        java.lang.IllegalStateException - if the operation is already completed
      • setError

        public abstract void setError​(java.lang.RuntimeException error)
        Completes the invocation with an error. Must not be called after the operation is already completed (with either an output or an error).
        Parameters:
        error - operation error
        Throws:
        java.lang.IllegalStateException - if the operation is already completed