Interceptor txInterceptor = null, replicationInterceptor = null, lockInterceptor = null, validationInterceptor = null;
Interceptor createIfNotExistsInterceptor = null, nodeInterceptor = null, invokerInterceptor = null, activationInterceptor = null;
Interceptor passivationInterceptor = null, cacheLoaderInterceptor = null, cacheStoreInterceptor = null, first = null;
Interceptor cacheMgmtInterceptor = null, evictionInterceptor = null, dataGravitatorInterceptor = null;
CacheLoaderManager cacheLoaderManager = cache.getCacheLoaderManager();
if (cacheLoaderManager != null && cacheLoaderManager.getCacheLoader() != null)
{
if (cacheLoaderManager.isPassivation())
{
activationInterceptor = createInterceptor("org.jboss.cache.interceptors.ActivationInterceptor", cache);
passivationInterceptor = createInterceptor("org.jboss.cache.interceptors.PassivationInterceptor", cache);
}
else
{
cacheLoaderInterceptor = createInterceptor("org.jboss.cache.interceptors.CacheLoaderInterceptor", cache);
cacheStoreInterceptor = createInterceptor("org.jboss.cache.interceptors.CacheStoreInterceptor", cache);
}
}
txInterceptor = createInterceptor("org.jboss.cache.interceptors.TxInterceptor", cache);
// if (cache.getBuddyManager() != null && cache.getBuddyManager().isEnableDataGravitation()) dataGravitatorInterceptor = createInterceptor("org.jboss.cache.interceptors.DataGravitatorInterceptor", cache);
if (cache.getBuddyManager() != null)
dataGravitatorInterceptor = createInterceptor("org.jboss.cache.interceptors.DataGravitatorInterceptor", cache);
switch (cache.getCacheModeInternal())
{
case TreeCache.REPL_SYNC:
case TreeCache.REPL_ASYNC:
replicationInterceptor = createInterceptor("org.jboss.cache.interceptors.OptimisticReplicationInterceptor", cache);
// if (!cache.isNodeLockingOptimistic()) cache.setReplicationHandler((Replicatable) replicationInterceptor);
break;
case TreeCache.INVALIDATION_SYNC:
case TreeCache.INVALIDATION_ASYNC:
replicationInterceptor = createInterceptor("org.jboss.cache.interceptors.InvalidationInterceptor", cache);
break;
case TreeCache.LOCAL:
//Nothing...
}
lockInterceptor = createInterceptor("org.jboss.cache.interceptors.OptimisticLockingInterceptor", cache);
validationInterceptor = createInterceptor("org.jboss.cache.interceptors.OptimisticValidatorInterceptor", cache);
createIfNotExistsInterceptor = createInterceptor("org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor", cache);
nodeInterceptor = createInterceptor("org.jboss.cache.interceptors.OptimisticNodeInterceptor", cache);
invokerInterceptor = createInterceptor("org.jboss.cache.interceptors.CallInterceptor", cache);
if (cache.isUsingEviction())
{
evictionInterceptor = createInterceptor(cache.getEvictionInterceptorClass(), cache);
}
if (cache.getUseInterceptorMbeans())
{
cacheMgmtInterceptor = createInterceptor("org.jboss.cache.interceptors.CacheMgmtInterceptor", cache);
if (first == null)
{
first = cacheMgmtInterceptor;
}
else
{
addInterceptor(first, cacheMgmtInterceptor);
}
}
if (txInterceptor != null)
{
if (first == null)
{
first = txInterceptor;
}
else
{
addInterceptor(first, txInterceptor);
}
}
if (first == null)
{
first = replicationInterceptor;
}
else
{
addInterceptor(first, replicationInterceptor);
}
if (passivationInterceptor != null && !cacheLoaderManager.isFetchPersistentState())
{
if (first == null)
first = passivationInterceptor;
else
addInterceptor(first, passivationInterceptor);
}
// add the cache store interceptor here
if (cacheStoreInterceptor != null && !cacheLoaderManager.isFetchPersistentState())
{
if (first == null)
first = cacheStoreInterceptor;
else
addInterceptor(first, cacheStoreInterceptor);
}
// cache loader interceptor is only invoked if we are ready to write to the actual tree cache
if (activationInterceptor != null)
{
if (first == null)
first = activationInterceptor;
else
addInterceptor(first, activationInterceptor);
if (cacheLoaderManager.isFetchPersistentState())
{
if (first == null)
first = passivationInterceptor;
else
addInterceptor(first, passivationInterceptor);
}
}
if (cacheLoaderInterceptor != null)
{
if (first == null)
first = cacheLoaderInterceptor;
else
addInterceptor(first, cacheLoaderInterceptor);
if (cacheLoaderManager.isFetchPersistentState())
{
if (first == null)
first = cacheStoreInterceptor;
else
addInterceptor(first, cacheStoreInterceptor);