Class BaseAsyncInterceptor
- java.lang.Object
-
- org.infinispan.interceptors.BaseAsyncInterceptor
-
- All Implemented Interfaces:
AsyncInterceptor
- Direct Known Subclasses:
DDAsyncInterceptor,TransactionSynchronizerInterceptor
public abstract class BaseAsyncInterceptor extends java.lang.Object implements AsyncInterceptor
Base class for an interceptor in the new asynchronous invocation chain.- Since:
- 9.0
- Author:
- Dan Berindei
-
-
Field Summary
Fields Modifier and Type Field Description protected ConfigurationcacheConfiguration
-
Constructor Summary
Constructors Constructor Description BaseAsyncInterceptor()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectasyncInvokeNext(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, java.util.Collection<? extends java.util.concurrent.CompletionStage<?>> delays)Suspend invocation until alldelayscomplete, then if successful invoke the next interceptor.java.lang.ObjectasyncInvokeNext(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, java.util.concurrent.CompletionStage<?> delay)Suspend the invocation untildelaycompletes, then if successful invoke the next interceptor.java.lang.ObjectasyncInvokeNext(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationStage invocationStage)Suspend the invocation untilinvocationStagecompletes, then if successful invoke the next interceptor.static InvocationStageasyncValue(java.util.concurrent.CompletionStage<?> valueFuture)Suspend the invocation untilvalueFuturecompletes, then return its result without running the remaining interceptors.java.lang.ObjectinvokeNext(InvocationContext ctx, org.infinispan.commands.VisitableCommand command)Invoke the next interceptor, possibly with a new command.java.lang.ObjectinvokeNextAndExceptionally(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationExceptionFunction function)Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished with an exception.java.lang.ObjectinvokeNextAndFinally(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyAction action)Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished, with or without an exception.java.lang.ObjectinvokeNextAndHandle(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyFunction function)Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished, with or without an exception.java.lang.ObjectinvokeNextThenAccept(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessAction action)Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished successfully.java.lang.ObjectinvokeNextThenApply(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessFunction function)Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished successfully.protected static booleanisSuccessfullyDone(java.lang.Object maybeStage)static InvocationStagemakeStage(java.lang.Object rv)Encode the result of aninvokeNext(InvocationContext, VisitableCommand)in anInvocationStage.voidsetNextInterceptor(AsyncInterceptor nextInterceptor)Used internally to set up the interceptor.static java.lang.ObjectvalueOrException(java.lang.Object rv, java.lang.Throwable throwable)Return the value ifthrowable != null, throw the exception otherwise.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.interceptors.AsyncInterceptor
visitCommand
-
-
-
-
Field Detail
-
cacheConfiguration
protected Configuration cacheConfiguration
-
-
Method Detail
-
setNextInterceptor
public final void setNextInterceptor(AsyncInterceptor nextInterceptor)
Used internally to set up the interceptor.- Specified by:
setNextInterceptorin interfaceAsyncInterceptor
-
invokeNext
public final java.lang.Object invokeNext(InvocationContext ctx, org.infinispan.commands.VisitableCommand command)
Invoke the next interceptor, possibly with a new command.Use
invokeNextThenApply(InvocationContext, VisitableCommand, InvocationSuccessFunction)orinvokeNextThenAccept(InvocationContext, VisitableCommand, InvocationSuccessAction)instead if you need to process the return value of the next interceptor.Note:
invokeNext(ctx, command)does not throw exceptions. In order to handle exceptions from the next interceptors, you must useinvokeNextAndHandle(InvocationContext, VisitableCommand, InvocationFinallyFunction),invokeNextAndFinally(InvocationContext, VisitableCommand, InvocationFinallyAction), orinvokeNextAndExceptionally(InvocationContext, VisitableCommand, InvocationExceptionFunction).
-
invokeNextThenApply
public final java.lang.Object invokeNextThenApply(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessFunction function)
Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished successfully.You need to wrap the result with
makeStage(Object)if you need to add another handler.
-
invokeNextThenAccept
public final java.lang.Object invokeNextThenAccept(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationSuccessAction action)
Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished successfully.You need to wrap the result with
makeStage(Object)if you need to add another handler.
-
invokeNextAndExceptionally
public final java.lang.Object invokeNextAndExceptionally(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationExceptionFunction function)
Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished with an exception.You need to wrap the result with
makeStage(Object)if you need to add another handler.
-
invokeNextAndFinally
public final java.lang.Object invokeNextAndFinally(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyAction action)
Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished, with or without an exception.You need to wrap the result with
makeStage(Object)if you need to add another handler.
-
invokeNextAndHandle
public final java.lang.Object invokeNextAndHandle(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationFinallyFunction function)
Invoke the next interceptor, possibly with a new command, and execute anInvocationCallbackafter all the interceptors have finished, with or without an exception.You need to wrap the result with
makeStage(Object)if you need to add another handler.
-
asyncValue
public static InvocationStage asyncValue(java.util.concurrent.CompletionStage<?> valueFuture)
Suspend the invocation untilvalueFuturecompletes, then return its result without running the remaining interceptors.The caller can add a callback that will run when
valueFuturecompletes, e.g.asyncValue(v).thenApply(ctx, command, (rCtx, rCommand, rv, t) -> invokeNext(rCtx, rCommand)). For this particular scenario, however, it's simpler to useasyncInvokeNext(InvocationContext, VisitableCommand, CompletionStage).
-
asyncInvokeNext
public final java.lang.Object asyncInvokeNext(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, java.util.concurrent.CompletionStage<?> delay)
Suspend the invocation untildelaycompletes, then if successful invoke the next interceptor.If
delaycompletes exceptionally, skip the next interceptor and continue with the exception.You need to wrap the result with
makeStage(Object)if you need to add another handler.
-
asyncInvokeNext
public final java.lang.Object asyncInvokeNext(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, InvocationStage invocationStage)
Suspend the invocation untilinvocationStagecompletes, then if successful invoke the next interceptor.If
invocationStagecompletes exceptionally, skip the next interceptor and continue with the exception.You need to wrap the result with
makeStage(Object)if you need to add another handler.
-
asyncInvokeNext
public final java.lang.Object asyncInvokeNext(InvocationContext ctx, org.infinispan.commands.VisitableCommand command, java.util.Collection<? extends java.util.concurrent.CompletionStage<?>> delays)
Suspend invocation until alldelayscomplete, then if successful invoke the next interceptor. If the list is empty or null, invoke the next interceptor immediately.If any of
delayscompletes exceptionally, skip the next interceptor and continue with the exception.You need to wrap the result with
makeStage(Object)if you need to add another handler.
-
valueOrException
public static java.lang.Object valueOrException(java.lang.Object rv, java.lang.Throwable throwable) throws java.lang.ThrowableReturn the value ifthrowable != null, throw the exception otherwise.- Throws:
java.lang.Throwable
-
makeStage
public static InvocationStage makeStage(java.lang.Object rv)
Encode the result of aninvokeNext(InvocationContext, VisitableCommand)in anInvocationStage.May not create a new instance, if the result is already an
InvocationStage.
-
isSuccessfullyDone
protected static boolean isSuccessfullyDone(java.lang.Object maybeStage)
-
-