Class InvocationStage

  • Direct Known Subclasses:
    ExceptionSyncInvocationStage, SyncInvocationStage

    public abstract class InvocationStage
    extends java.lang.Object
    A partial command invocation, either completed or in progress.

    It is similar to a CompletionStage, but it allows more callback functions to be stateless by passing the context and the invoked command as parameters.

    Unlike CompletionStage, adding a callback can delay the completion of the initial stage and change its result.

    Since:
    9.0
    Author:
    Dan Berindei
    • Constructor Detail

      • InvocationStage

        public InvocationStage()
    • Method Detail

      • get

        public abstract java.lang.Object get()
                                      throws java.lang.Throwable
        Wait for the invocation to complete and return its value.
        Throws:
        java.lang.Throwable - Any exception raised during the invocation.
      • isDone

        public abstract boolean isDone()
        Returns:
        true if the invocation is complete.
      • toCompletableFuture

        public abstract java.util.concurrent.CompletableFuture<java.lang.Object> toCompletableFuture()
        CompletableFuture conversion.
      • thenApply

        public <C extends org.infinispan.commands.VisitableCommand> java.lang.Object thenApply​(InvocationContext ctx,
                                                                                               C command,
                                                                                               InvocationSuccessFunction<C> function)
        After the current stage completes successfully, invoke function and return its result.

        The result may be either a plain value, this, or a new InvocationStage. If function throws an exception, the result InvocationStage will complete with the same exception.

      • thenAccept

        public <C extends org.infinispan.commands.VisitableCommand> java.lang.Object thenAccept​(InvocationContext ctx,
                                                                                                C command,
                                                                                                InvocationSuccessAction<C> action)
        After the current stage completes successfully, invoke action.

        The result may be either a plain value, this, or a new InvocationStage. If action throws an exception, the result InvocationStage will complete with the same exception.

      • andExceptionally

        public <C extends org.infinispan.commands.VisitableCommand> java.lang.Object andExceptionally​(InvocationContext ctx,
                                                                                                      C command,
                                                                                                      InvocationExceptionFunction<C> function)
        After the current stage completes exceptionally, invoke function and return its result.

        The result may be either a plain value, this, or a new InvocationStage. If function throws an exception, the result InvocationStage will complete with the same exception.

      • andFinally

        public <C extends org.infinispan.commands.VisitableCommand> java.lang.Object andFinally​(InvocationContext ctx,
                                                                                                C command,
                                                                                                InvocationFinallyAction<C> action)
        After the current stage completes, invoke action.

        The result may be either a plain value, this, or a new InvocationStage. If action throws an exception, the result InvocationStage will complete with the same exception.

      • andHandle

        public <C extends org.infinispan.commands.VisitableCommand> java.lang.Object andHandle​(InvocationContext ctx,
                                                                                               C command,
                                                                                               InvocationFinallyFunction<C> function)
        After the current stage completes, invoke function and return its result.

        The result may be either a plain value, this, or a new InvocationStage. If function throws an exception, the result InvocationStage will complete with the same exception.

      • addCallback

        public abstract <C extends org.infinispan.commands.VisitableCommand> java.lang.Object addCallback​(InvocationContext ctx,
                                                                                                          C command,
                                                                                                          InvocationCallback<C> function)
        After the current stage completes, invoke function and return its result.

        The result may be either a plain value, or a new InvocationStage. If function throws an exception, the result InvocationStage will complete with the same exception.

      • thenApplyMakeStage

        public <C extends org.infinispan.commands.VisitableCommand> InvocationStage thenApplyMakeStage​(InvocationContext ctx,
                                                                                                       C command,
                                                                                                       InvocationSuccessFunction<C> function)
        After the current stage completes successfully, invoke function and return its result.

        The result may be either this, or a new InvocationStage. If function throws an exception, the result InvocationStage will complete with the same exception.

      • andExceptionallyMakeStage

        public <C extends org.infinispan.commands.VisitableCommand> InvocationStage andExceptionallyMakeStage​(InvocationContext ctx,
                                                                                                              C command,
                                                                                                              InvocationExceptionFunction<C> function)
        After the current stage completes exceptionally, invoke function and return its result.

        The result may be either this, or a new InvocationStage. If function throws an exception, the result InvocationStage will complete with the same exception.

      • makeStage

        public static InvocationStage makeStage​(java.lang.Object maybeStage)
        If maybeStage is not an InvocationStage, wrap it, otherwise cast it to an InvocationStage.
      • completedNullStage

        public static InvocationStage completedNullStage()
        Returns:
        an InvocationStage instance completed successfully with value null.
      • thenReturn

        public java.lang.Object thenReturn​(InvocationContext ctx,
                                           org.infinispan.commands.VisitableCommand command,
                                           java.lang.Object returnValue)
        Overrides the return value of this InvocationStage if it is completed successfully. The result may be either rv, a new InvocationStage or this