29.4.4. プラグ可能なインターセプターとロックポリシー
基本的なエンティティ bean のライフサイクルおよび動作は
standardjboss.xml 記述子で定義されるコンテナー設定により定義されることがわかりました。今度は Standard CMP 2.x EntityBean 設定の container-interceptors 定義を見てみることにします。
<container-interceptors>
<interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
<interceptor>org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>
<interceptor metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.EntityCreationInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.EntityLockInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.EntityInstanceInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.EntityReentranceInterceptor</interceptor>
<interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.EntitySynchronizationInterceptor</interceptor>
<interceptor>org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor</interceptor>
</container-interceptors>
上記に示すインターセプターはエンティティ bean のほとんどの動作を定義します。以下に本項に関連のあるインターセプターについて記します。
- EntityLockInterceptor: このインターセプターの役割は呼び出しが続行される前に取得されなければならないロックをすべてスケジュールすることです。このインターセプターは非常に軽量ですべてのロック機能動作をプラグ可能なロックポリシーに委譲します。
- EntityInstanceInterceptor: このインターセプターの役割はキャッシュ内でエンティティ bean を検索する、または新しいエンティティ bean を作成することです。また、このインターセプターは一度にメモリ内に存在する bean のアクティブなインスタンスが必ず 1 つのみであるようにします。
- EntitySynchronizationInterceptor:このインターセプターの役割は基盤となるストレージでキャッシュの状態を同期することです。 EJB 仕様の
ejbLoadおよびejbStoreのセマンティックでこれを行います。トランザクションが存在すると、トランザクションの分離によって引き起こされます。 コールバックを基盤となるトランザクションモニターに JTA インターフェース経由で登録します。トランザクションがない場合、このポリシーは呼び出しから戻ると状態を格納します。その仕様の同期ポリシー A、B、C の他 JBoss 固有のコミットオプション D もここで処理されます。