37.2. Adding Custom Interceptors Declaratively
Procedure 37.1. Adding Custom Interceptors
<local-cache name="cacheWithCustomInterceptors">
<custom-interceptors>
<interceptor position="FIRST" class="com.mycompany.CustomInterceptor1">
<property name="attributeOne" value="value1" />
<property name="attributeTwo" value="value2" />
</interceptor>
<interceptor position="LAST" class="com.mycompany.CustomInterceptor2"/>
<interceptor index="3" class="com.mycompany.CustomInterceptor1"/>
<interceptor before="org.infinispan.interceptors.CallInterceptor" class="com.mycompany.CustomInterceptor2"/>
<interceptor after="org.infinispan.interceptors.CallInterceptor" class="com.mycompany.CustomInterceptor1"/>
</customInterceptors>
</local-cache>
Define Custom Interceptors
All custom interceptors must extendorg.infinispan.interceptors.base.BaseCustomInterceptor.Define the Position of the New Custom Interceptor
Interceptors must have a defined position. These options are mutually exclusive, meaning an interceptor cannot have both a position attribute and index attribute. Valid options are:via Position Attribute
FIRST- Specifies that the new interceptor is placed first in the chain.LAST- Specifies that the new interceptor is placed last in the chain.OTHER_THAN_FIRST_OR_LAST- Specifies that the new interceptor can be placed anywhere except first or last in the chain.
via Index Attribute
- The
indexidentifies the position of this interceptor in the chain. This index begins at 0, being the first position in the chain, and goes up to a number of interceptors in a given configuration.
via Before or After Attributes
- The
afterattributes places the new interceptor directly after the instance of the named interceptor, specified via its fully qualified class name. - The
beforeattribute places the new interceptor directly before the instance of the named interceptor, specified via its fully qualified class name.
Define Interceptor Properties
Define specific interceptor properties.
Apply Other Custom Interceptors
In this example, the next custom interceptor is called CustomInterceptor2.
Note
OTHER_THAN_FIRST_OR_LAST may cause the CacheManager to fail.
Note

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.