Class AsyncMethodFutureAdapter<T>

  • Type Parameters:
    T - return type (can be Void).
    All Implemented Interfaces:
    AsyncMethodCallback<T>

    public final class AsyncMethodFutureAdapter<T>
    extends java.lang.Object
    implements AsyncMethodCallback<T>
    A simple adapter that bridges AsyncMethodCallback with CompletableFuture-returning style clients. Compiler generated code will invoke this adapter to implement FutureClients.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> AsyncMethodFutureAdapter<T> create()  
      java.util.concurrent.CompletableFuture<T> getFuture()  
      void onComplete​(T response)
      This method will be called when the remote side has completed invoking your method call and the result is fully read.
      void onError​(java.lang.Exception exception)
      This method will be called when there is either an unexpected client-side exception like an IOException or else when the remote method raises an exception, either declared in the IDL or due to an unexpected server-side error.
      • Methods inherited from class java.lang.Object

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

      • getFuture

        public java.util.concurrent.CompletableFuture<T> getFuture()
      • onComplete

        public void onComplete​(T response)
        Description copied from interface: AsyncMethodCallback
        This method will be called when the remote side has completed invoking your method call and the result is fully read. For oneway method calls, this method will be called as soon as we have completed writing out the request.
        Specified by:
        onComplete in interface AsyncMethodCallback<T>
        Parameters:
        response - The return value of the asynchronously invoked method; null for void methods which includes oneway methods.
      • onError

        public void onError​(java.lang.Exception exception)
        Description copied from interface: AsyncMethodCallback
        This method will be called when there is either an unexpected client-side exception like an IOException or else when the remote method raises an exception, either declared in the IDL or due to an unexpected server-side error.
        Specified by:
        onError in interface AsyncMethodCallback<T>
        Parameters:
        exception - The exception encountered processing the the asynchronous method call, may be a local exception or an unmarshalled remote exception.