第 15 章 自定义拦截器
重要
自定义拦截器在 Data Grid 中已弃用,并将在以后的版本中删除。
自定义拦截器是通过能够影响或响应对缓存的任何修改来扩展数据中心的方法。这种修改示例包括添加/删除/更新或事务提交。
15.1. 声明性添加自定义拦截器 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
自定义拦截器可以针对每个命名的缓存添加。这是因为每个命名缓存都有自己的拦截器堆栈。以下 xml 片段描述了添加自定义拦截器的方法。
<local-cache name="cacheWithCustomInterceptors">
<!-- Define custom interceptors. -->
<!-- Custom interceptors should extend
org.infinispan.interceptors.BaseCustomAsyncInterceptor -->
<custom-interceptors>
<interceptor position="FIRST" class="com.mycompany.CustomInterceptor1">
<property name="attributeOne">value1</property>
<property name="attributeTwo">value2</property>
</interceptor>
<interceptor position="LAST" class="com.mycompany.CustomInterceptor2"/>
<interceptor index="3" class="com.mycompany.CustomInterceptor1"/>
<interceptor before="org.infinispanpan.interceptors.CallInterceptor"
class="com.mycompany.CustomInterceptor2"/>
<interceptor after="org.infinispanpan.interceptors.CallInterceptor"
class="com.mycompany.CustomInterceptor1"/>
</custom-interceptors>
</local-cache>