public InterceptorChain buildInterceptorChain() throws IllegalAccessException, InstantiationException, ClassNotFoundException
{
boolean optimistic = configuration.isNodeLockingOptimistic();
// load the icInterceptor first
CommandInterceptor first = createInterceptor(InvocationContextInterceptor.class);
InterceptorChain interceptorChain = new InterceptorChain(first);
// add the interceptor chain to the registry first, since some interceptors may ask for it.
componentRegistry.registerComponent(interceptorChain, InterceptorChain.class);
// load the cache management interceptor next
if (configuration.getExposeManagementStatistics())
interceptorChain.appendIntereceptor(createInterceptor(CacheMgmtInterceptor.class));
// load the tx interceptor
interceptorChain.appendIntereceptor(createInterceptor(optimistic ? OptimisticTxInterceptor.class : TxInterceptor.class));
if (configuration.isUseLazyDeserialization())
interceptorChain.appendIntereceptor(createInterceptor(MarshalledValueInterceptor.class));
interceptorChain.appendIntereceptor(createInterceptor(NotificationInterceptor.class));
switch (configuration.getCacheMode())
{
case REPL_SYNC:
case REPL_ASYNC:
interceptorChain.appendIntereceptor(optimistic ? createInterceptor(OptimisticReplicationInterceptor.class) : createInterceptor(ReplicationInterceptor.class));
break;
case INVALIDATION_SYNC:
case INVALIDATION_ASYNC:
interceptorChain.appendIntereceptor(createInterceptor(InvalidationInterceptor.class));
break;
case LOCAL:
//Nothing...
}
if (!optimistic)
{
interceptorChain.appendIntereceptor(createInterceptor(PessimisticLockInterceptor.class));
}
if (configuration.isUsingCacheLoaders())
{
if (configuration.getCacheLoaderConfig().isPassivation())
{
interceptorChain.appendIntereceptor(createInterceptor(ActivationInterceptor.class));
interceptorChain.appendIntereceptor(createInterceptor(PassivationInterceptor.class));
}
else
{
interceptorChain.appendIntereceptor(createInterceptor(CacheLoaderInterceptor.class));
interceptorChain.appendIntereceptor(createInterceptor(CacheStoreInterceptor.class));
}
}
if (configuration.isUsingBuddyReplication())
interceptorChain.appendIntereceptor(createInterceptor(DataGravitatorInterceptor.class));
if (optimistic)
{
interceptorChain.appendIntereceptor(createInterceptor(OptimisticLockingInterceptor.class));
interceptorChain.appendIntereceptor(createInterceptor(OptimisticValidatorInterceptor.class));
interceptorChain.appendIntereceptor(createInterceptor(OptimisticCreateIfNotExistsInterceptor.class));
}
// eviction interceptor to come before the optimistic node interceptor
if (configuration.getEvictionConfig() != null && configuration.getEvictionConfig().isValidConfig())
interceptorChain.appendIntereceptor(createInterceptor(configuration.isUsingBuddyReplication() ? BuddyRegionAwareEvictionInterceptor.class : EvictionInterceptor.class));
if (optimistic) interceptorChain.appendIntereceptor(createInterceptor(OptimisticNodeInterceptor.class));
CommandInterceptor callInterceptor = createInterceptor(CallInterceptor.class);
interceptorChain.appendIntereceptor(callInterceptor);
if (log.isTraceEnabled()) log.trace("Finished building interceptor chain.");
return interceptorChain;
}