Package org.infinispan.interceptors
Interface AsyncInterceptorChain
-
- All Known Implementing Classes:
EmptyAsyncInterceptorChain
public interface AsyncInterceptorChain
Interceptor chain usingAsyncInterceptor
s. Experimental: The ability to modify the interceptors at runtime may be removed in future versions.- Since:
- 9.0
- Author:
- Dan Berindei
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addInterceptor(AsyncInterceptor interceptor, int position)
Inserts the given interceptor at the specified position in the chain (0 based indexing).boolean
addInterceptorAfter(AsyncInterceptor toAdd, java.lang.Class<? extends AsyncInterceptor> afterInterceptor)
Adds a new interceptor in list after an interceptor of a given type.boolean
addInterceptorBefore(AsyncInterceptor toAdd, java.lang.Class<? extends AsyncInterceptor> beforeInterceptor)
Adds a new interceptor in list before an interceptor of a given type.void
appendInterceptor(AsyncInterceptor ci, boolean isCustom)
Appends at the end.boolean
containsInstance(AsyncInterceptor interceptor)
Checks whether the chain contains the supplied interceptor instance.boolean
containsInterceptorType(java.lang.Class<? extends AsyncInterceptor> interceptorType)
Checks whether the chain contains an interceptor with the given class.boolean
containsInterceptorType(java.lang.Class<? extends AsyncInterceptor> interceptorType, boolean alsoMatchSubClasses)
Checks whether the chain contains an interceptor with the given class, or a subclass.<T extends AsyncInterceptor>
TfindInterceptorExtending(java.lang.Class<T> interceptorClass)
Returns the first interceptor extending the given class, ornull
if there is none.<T extends AsyncInterceptor>
TfindInterceptorWithClass(java.lang.Class<T> interceptorClass)
Returns the first interceptor with the given class, ornull
if there is none.java.util.List<AsyncInterceptor>
getInterceptors()
java.lang.Object
invoke(InvocationContext ctx, org.infinispan.commands.VisitableCommand command)
Walks the command through the interceptor chain.java.util.concurrent.CompletableFuture<java.lang.Object>
invokeAsync(InvocationContext ctx, org.infinispan.commands.VisitableCommand command)
Walks the command through the interceptor chain.void
removeInterceptor(int position)
Removes the interceptor at the given position.void
removeInterceptor(java.lang.Class<? extends AsyncInterceptor> clazz)
Removes all the occurrences of supplied interceptor type from the chain.boolean
replaceInterceptor(AsyncInterceptor replacingInterceptor, java.lang.Class<? extends AsyncInterceptor> toBeReplacedInterceptorType)
Replaces an existing interceptor of the given type in the interceptor chain with a new interceptor instance passed as parameter.int
size()
Returns the number of interceptors in the chain.
-
-
-
Method Detail
-
getInterceptors
java.util.List<AsyncInterceptor> getInterceptors()
- Returns:
- An immutable list of the current interceptors.
-
addInterceptor
void addInterceptor(AsyncInterceptor interceptor, int position)
Inserts the given interceptor at the specified position in the chain (0 based indexing).- Throws:
java.lang.IllegalArgumentException
- if the position is invalid (e.g. 5 and there are only 2 interceptors in the chain)
-
removeInterceptor
void removeInterceptor(int position)
Removes the interceptor at the given position.- Throws:
java.lang.IllegalArgumentException
- if the position is invalid (e.g. 5 and there are only 2 interceptors in the chain)
-
size
int size()
Returns the number of interceptors in the chain.
-
removeInterceptor
void removeInterceptor(java.lang.Class<? extends AsyncInterceptor> clazz)
Removes all the occurrences of supplied interceptor type from the chain.
-
addInterceptorAfter
boolean addInterceptorAfter(AsyncInterceptor toAdd, java.lang.Class<? extends AsyncInterceptor> afterInterceptor)
Adds a new interceptor in list after an interceptor of a given type.- Returns:
- true if the interceptor was added; i.e. the
afterInterceptor
exists
-
addInterceptorBefore
boolean addInterceptorBefore(AsyncInterceptor toAdd, java.lang.Class<? extends AsyncInterceptor> beforeInterceptor)
Adds a new interceptor in list before an interceptor of a given type.- Returns:
- true if the interceptor was added; i.e. the
beforeInterceptor
exists
-
replaceInterceptor
boolean replaceInterceptor(AsyncInterceptor replacingInterceptor, java.lang.Class<? extends AsyncInterceptor> toBeReplacedInterceptorType)
Replaces an existing interceptor of the given type in the interceptor chain with a new interceptor instance passed as parameter.- Parameters:
replacingInterceptor
- the interceptor to add to the interceptor chaintoBeReplacedInterceptorType
- the type of interceptor that should be swapped with the new one- Returns:
- true if the interceptor was replaced
-
appendInterceptor
void appendInterceptor(AsyncInterceptor ci, boolean isCustom)
Appends at the end.
-
invoke
java.lang.Object invoke(InvocationContext ctx, org.infinispan.commands.VisitableCommand command)
Walks the command through the interceptor chain. The received ctx is being passed in.Note: Reusing the context for multiple invocations is allowed, however most context implementations are not thread-safe.
-
invokeAsync
java.util.concurrent.CompletableFuture<java.lang.Object> invokeAsync(InvocationContext ctx, org.infinispan.commands.VisitableCommand command)
Walks the command through the interceptor chain. The received ctx is being passed in.
-
findInterceptorExtending
<T extends AsyncInterceptor> T findInterceptorExtending(java.lang.Class<T> interceptorClass)
Returns the first interceptor extending the given class, ornull
if there is none.
-
findInterceptorWithClass
<T extends AsyncInterceptor> T findInterceptorWithClass(java.lang.Class<T> interceptorClass)
Returns the first interceptor with the given class, ornull
if there is none.
-
containsInstance
boolean containsInstance(AsyncInterceptor interceptor)
Checks whether the chain contains the supplied interceptor instance.
-
containsInterceptorType
boolean containsInterceptorType(java.lang.Class<? extends AsyncInterceptor> interceptorType)
Checks whether the chain contains an interceptor with the given class.
-
containsInterceptorType
boolean containsInterceptorType(java.lang.Class<? extends AsyncInterceptor> interceptorType, boolean alsoMatchSubClasses)
Checks whether the chain contains an interceptor with the given class, or a subclass.
-
-