Class InvocationStage
- java.lang.Object
-
- org.infinispan.interceptors.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 Summary
Constructors Constructor Description InvocationStage()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <C extends org.infinispan.commands.VisitableCommand>
java.lang.ObjectaddCallback(InvocationContext ctx, C command, InvocationCallback<C> function)
After the current stage completes, invokefunction
and return its result.<C extends org.infinispan.commands.VisitableCommand>
java.lang.ObjectandExceptionally(InvocationContext ctx, C command, InvocationExceptionFunction<C> function)
After the current stage completes exceptionally, invokefunction
and return its result.<C extends org.infinispan.commands.VisitableCommand>
InvocationStageandExceptionallyMakeStage(InvocationContext ctx, C command, InvocationExceptionFunction<C> function)
After the current stage completes exceptionally, invokefunction
and return its result.<C extends org.infinispan.commands.VisitableCommand>
java.lang.ObjectandFinally(InvocationContext ctx, C command, InvocationFinallyAction<C> action)
After the current stage completes, invokeaction
.<C extends org.infinispan.commands.VisitableCommand>
InvocationStageandFinallyMakeStage(InvocationContext ctx, C command, InvocationFinallyAction<C> action)
After the current stage completes, invokeaction
.<C extends org.infinispan.commands.VisitableCommand>
java.lang.ObjectandHandle(InvocationContext ctx, C command, InvocationFinallyFunction<C> function)
After the current stage completes, invokefunction
and return its result.<C extends org.infinispan.commands.VisitableCommand>
InvocationStageandHandleMakeStage(InvocationContext ctx, C command, InvocationFinallyFunction<C> function)
After the current stage completes, invokefunction
and return its result.static InvocationStage
completedNullStage()
abstract java.lang.Object
get()
Wait for the invocation to complete and return its value.abstract boolean
isDone()
static InvocationStage
makeStage(java.lang.Object maybeStage)
IfmaybeStage
is not anInvocationStage
, wrap it, otherwise cast it to anInvocationStage
.<C extends org.infinispan.commands.VisitableCommand>
java.lang.ObjectthenAccept(InvocationContext ctx, C command, InvocationSuccessAction<C> action)
After the current stage completes successfully, invokeaction
.<C extends org.infinispan.commands.VisitableCommand>
InvocationStagethenAcceptMakeStage(InvocationContext ctx, C command, InvocationSuccessAction<C> action)
After the current stage completes successfully, invokeaction
.<C extends org.infinispan.commands.VisitableCommand>
java.lang.ObjectthenApply(InvocationContext ctx, C command, InvocationSuccessFunction<C> function)
After the current stage completes successfully, invokefunction
and return its result.<C extends org.infinispan.commands.VisitableCommand>
InvocationStagethenApplyMakeStage(InvocationContext ctx, C command, InvocationSuccessFunction<C> function)
After the current stage completes successfully, invokefunction
and return its result.java.lang.Object
thenReturn(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, java.lang.Object returnValue)
Overrides the return value of thisInvocationStage
if it is completed successfully.abstract java.util.concurrent.CompletableFuture<java.lang.Object>
toCompletableFuture()
CompletableFuture
conversion.
-
-
-
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, invokefunction
and return its result.The result may be either a plain value,
this
, or a newInvocationStage
. Iffunction
throws an exception, the resultInvocationStage
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, invokeaction
.The result may be either a plain value,
this
, or a newInvocationStage
. Ifaction
throws an exception, the resultInvocationStage
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, invokefunction
and return its result.The result may be either a plain value,
this
, or a newInvocationStage
. Iffunction
throws an exception, the resultInvocationStage
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, invokeaction
.The result may be either a plain value,
this
, or a newInvocationStage
. Ifaction
throws an exception, the resultInvocationStage
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, invokefunction
and return its result.The result may be either a plain value,
this
, or a newInvocationStage
. Iffunction
throws an exception, the resultInvocationStage
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, invokefunction
and return its result.The result may be either a plain value, or a new
InvocationStage
. Iffunction
throws an exception, the resultInvocationStage
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, invokefunction
and return its result.The result may be either
this
, or a newInvocationStage
. Iffunction
throws an exception, the resultInvocationStage
will complete with the same exception.
-
thenAcceptMakeStage
public <C extends org.infinispan.commands.VisitableCommand> InvocationStage thenAcceptMakeStage(InvocationContext ctx, C command, InvocationSuccessAction<C> action)
After the current stage completes successfully, invokeaction
.The result may be either
this
, or a newInvocationStage
. Ifaction
throws an exception, the resultInvocationStage
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, invokefunction
and return its result.The result may be either
this
, or a newInvocationStage
. Iffunction
throws an exception, the resultInvocationStage
will complete with the same exception.
-
andFinallyMakeStage
public <C extends org.infinispan.commands.VisitableCommand> InvocationStage andFinallyMakeStage(InvocationContext ctx, C command, InvocationFinallyAction<C> action)
After the current stage completes, invokeaction
.The result may be either
this
, or a newInvocationStage
. Ifaction
throws an exception, the resultInvocationStage
will complete with the same exception.
-
andHandleMakeStage
public <C extends org.infinispan.commands.VisitableCommand> InvocationStage andHandleMakeStage(InvocationContext ctx, C command, InvocationFinallyFunction<C> function)
After the current stage completes, invokefunction
and return its result.The result may be either
this
, or a newInvocationStage
. Iffunction
throws an exception, the resultInvocationStage
will complete with the same exception.
-
makeStage
public static InvocationStage makeStage(java.lang.Object maybeStage)
IfmaybeStage
is not anInvocationStage
, wrap it, otherwise cast it to anInvocationStage
.
-
completedNullStage
public static InvocationStage completedNullStage()
- Returns:
- an
InvocationStage
instance completed successfully with valuenull
.
-
thenReturn
public java.lang.Object thenReturn(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, java.lang.Object returnValue)
Overrides the return value of thisInvocationStage
if it is completed successfully. The result may be eitherrv
, a newInvocationStage
orthis
-
-