Class InvocationStage
- java.lang.Object
-
- org.infinispan.interceptors.InvocationStage
-
- Direct Known Subclasses:
SyncInvocationStage
public abstract class InvocationStage extends java.lang.ObjectA 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 Summary
Constructors Constructor Description InvocationStage()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.ObjectaddCallback(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationCallback function)After the current stage completes, invokefunctionand return its result.java.lang.ObjectandExceptionally(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationExceptionFunction function)After the current stage completes exceptionally, invokefunctionand return its result.InvocationStageandExceptionallyMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationExceptionFunction function)After the current stage completes exceptionally, invokefunctionand return its result.java.lang.ObjectandFinally(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyAction action)After the current stage completes, invokeaction.InvocationStageandFinallyMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyAction action)After the current stage completes, invokeaction.java.lang.ObjectandHandle(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyFunction function)After the current stage completes, invokefunctionand return its result.InvocationStageandHandleMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyFunction function)After the current stage completes, invokefunctionand return its result.static InvocationStagecompletedNullStage()abstract java.lang.Objectget()Wait for the invocation to complete and return its value.abstract booleanisDone()static InvocationStagemakeStage(java.lang.Object maybeStage)IfmaybeStageis not anInvocationStage, wrap it, otherwise cast it to anInvocationStage.java.lang.ObjectthenAccept(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessAction action)After the current stage completes successfully, invokeaction.InvocationStagethenAcceptMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessAction action)After the current stage completes successfully, invokeaction.java.lang.ObjectthenApply(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessFunction function)After the current stage completes successfully, invokefunctionand return its result.InvocationStagethenApplyMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessFunction function)After the current stage completes successfully, invokefunctionand return its result.abstract java.util.concurrent.CompletableFuture<java.lang.Object>toCompletableFuture()CompletableFutureconversion.
-
-
-
Method Detail
-
get
public abstract java.lang.Object get() throws java.lang.ThrowableWait 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:
trueif the invocation is complete.
-
toCompletableFuture
public abstract java.util.concurrent.CompletableFuture<java.lang.Object> toCompletableFuture()
CompletableFutureconversion.
-
thenApply
public java.lang.Object thenApply(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessFunction function)
After the current stage completes successfully, invokefunctionand return its result.The result may be either a plain value,
this, or a newInvocationStage. Iffunctionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
thenAccept
public java.lang.Object thenAccept(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessAction action)
After the current stage completes successfully, invokeaction.The result may be either a plain value,
this, or a newInvocationStage. Ifactionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
andExceptionally
public java.lang.Object andExceptionally(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationExceptionFunction function)
After the current stage completes exceptionally, invokefunctionand return its result.The result may be either a plain value,
this, or a newInvocationStage. Iffunctionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
andFinally
public java.lang.Object andFinally(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyAction action)
After the current stage completes, invokeaction.The result may be either a plain value,
this, or a newInvocationStage. Ifactionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
andHandle
public java.lang.Object andHandle(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyFunction function)
After the current stage completes, invokefunctionand return its result.The result may be either a plain value,
this, or a newInvocationStage. Iffunctionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
addCallback
public abstract java.lang.Object addCallback(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationCallback function)
After the current stage completes, invokefunctionand return its result.The result may be either a plain value, or a new
InvocationStage. Iffunctionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
thenApplyMakeStage
public InvocationStage thenApplyMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessFunction function)
After the current stage completes successfully, invokefunctionand return its result.The result may be either
this, or a newInvocationStage. Iffunctionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
thenAcceptMakeStage
public InvocationStage thenAcceptMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessAction action)
After the current stage completes successfully, invokeaction.The result may be either
this, or a newInvocationStage. Ifactionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
andExceptionallyMakeStage
public InvocationStage andExceptionallyMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationExceptionFunction function)
After the current stage completes exceptionally, invokefunctionand return its result.The result may be either
this, or a newInvocationStage. Iffunctionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
andFinallyMakeStage
public InvocationStage andFinallyMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyAction action)
After the current stage completes, invokeaction.The result may be either
this, or a newInvocationStage. Ifactionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
andHandleMakeStage
public InvocationStage andHandleMakeStage(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyFunction function)
After the current stage completes, invokefunctionand return its result.The result may be either
this, or a newInvocationStage. Iffunctionthrows an exception, the resultInvocationStagewill complete with the same exception.
-
makeStage
public static InvocationStage makeStage(java.lang.Object maybeStage)
IfmaybeStageis not anInvocationStage, wrap it, otherwise cast it to anInvocationStage.
-
completedNullStage
public static InvocationStage completedNullStage()
- Returns:
- an
InvocationStageinstance completed successfully with valuenull.
-
-