このコンテンツは選択した言語では利用できません。

1.3.3.2. Adding Custom Interceptors Declaratively


Each named cache in Red Hat JBoss Data Grid has its own interceptor stack. As a result, custom interceptors can be added on a per named cache basis.
A custom interceptor can be added using XML. Use the following procedure to add custom interceptors.

Procedure 1.1. Adding Custom Interceptors

  1. Define Custom Interceptors

    All custom interceptors must extend org.jboss.cache.interceptors.base.CommandInterceptor. Use the customInterceptors method to add custom interceptors to the cache:
    <namedCache name="cacheWithCustomInterceptors">
       <customInterceptors>
    
    Copy to Clipboard Toggle word wrap
  2. Define the Position of the New Custom Interceptor

    Interceptors must have a defined position. Valid options are:
    • 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.
    <namedCache name="cacheWithCustomInterceptors">
       <customInterceptors>
          <interceptor position="FIRST" class="com.mycompany.CustomInterceptor1">
    
    Copy to Clipboard Toggle word wrap
    • Define Interceptor Properties

      Define specific interceptor properties.
      <namedCache name="cacheWithCustomInterceptors">
         <customInterceptors>
            <interceptor position="FIRST" class="com.mycompany.CustomInterceptor1">
               <properties>
                  <property name="attributeOne" value="value1" />
                  <property name="attributeTwo" value="value2" />
               </properties>
            </interceptor>
      
      Copy to Clipboard Toggle word wrap
  3. Apply Other Custom Interceptors

    In this example, the next custom interceptor is called CustomInterceptor2.
    <namedCache name="cacheWithCustomInterceptors">
       <customInterceptors>
          <interceptor position="FIRST" class="com.mycompany.CustomInterceptor1">
             <properties>
                <property name="attributeOne" value="value1" />
                <property name="attributeTwo" value="value2" />
             </properties>
          </interceptor>
          <interceptor position="LAST" class="com.mycompany.CustomInterceptor2"/>
    
    Copy to Clipboard Toggle word wrap
  4. Define the index, before, and after Attributes.

    • The index identifies the position of this interceptor in the chain, with 0 being the first position. This attribute is mutually exclusive with position, before, and after.
    • The after method places the new interceptor directly after the instance of the named interceptor specified via its fully qualified class name. This attribute is mutually exclusive with position, before, and index.
    • The before method places the new interceptor directly before the instance of the named interceptor specified via its fully qualified class name. This attribute is mutually exclusive with position, after, and index.
    <namedCache name="cacheWithCustomInterceptors">
       <customInterceptors>
          <interceptor position="FIRST" class="com.mycompany.CustomInterceptor1">
             <properties>
                <property name="attributeOne" value="value1" />
                <property name="attributeTwo" value="value2" />
             </properties>
          </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>
    </namedCache>
    
    
    Copy to Clipboard Toggle word wrap

Note

This configuration is only valid for JBoss Data Grid's Library Mode.
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat