use of org.infinispan.interceptors.impl.IsMarshallableInterceptor in project infinispan by infinispan.
the class InterceptorChainFactory method buildInterceptorChain.
private AsyncInterceptorChain buildInterceptorChain() {
TransactionMode transactionMode = configuration.transaction().transactionMode();
boolean needsVersionAwareComponents = Configurations.isTxVersioned(configuration);
AsyncInterceptorChain interceptorChain = new AsyncInterceptorChainImpl();
boolean invocationBatching = configuration.invocationBatching().enabled();
CacheMode cacheMode = configuration.clustering().cacheMode();
// load the icInterceptor first
if (invocationBatching) {
interceptorChain.appendInterceptor(createInterceptor(new BatchingInterceptor(), BatchingInterceptor.class), false);
}
interceptorChain.appendInterceptor(createInterceptor(new InvocationContextInterceptor(), InvocationContextInterceptor.class), false);
if (!configuration.transaction().transactionMode().isTransactional()) {
interceptorChain.appendInterceptor(createInterceptor(new VersionInterceptor(), VersionInterceptor.class), false);
}
// add marshallable check interceptor for situations where we want to figure out before marshalling
if (hasAsyncStore())
interceptorChain.appendInterceptor(createInterceptor(new IsMarshallableInterceptor(), IsMarshallableInterceptor.class), false);
// load the cache management interceptor next
if (configuration.statistics().available()) {
interceptorChain.appendInterceptor(createInterceptor(new CacheMgmtInterceptor(), CacheMgmtInterceptor.class), false);
}
// the only exception is non-tx invalidation mode, which ignores lock owners
if (cacheMode.needsStateTransfer() || cacheMode.isInvalidation() && transactionMode.isTransactional()) {
interceptorChain.appendInterceptor(createInterceptor(new StateTransferInterceptor(), StateTransferInterceptor.class), false);
}
if (cacheMode.needsStateTransfer()) {
if (transactionMode.isTransactional()) {
interceptorChain.appendInterceptor(createInterceptor(new TransactionSynchronizerInterceptor(), TransactionSynchronizerInterceptor.class), false);
}
if (configuration.clustering().partitionHandling().whenSplit() != PartitionHandling.ALLOW_READ_WRITES) {
interceptorChain.appendInterceptor(createInterceptor(new PartitionHandlingInterceptor(), PartitionHandlingInterceptor.class), false);
}
}
// load the tx interceptor
if (transactionMode.isTransactional())
interceptorChain.appendInterceptor(createInterceptor(new TxInterceptor<>(), TxInterceptor.class), false);
if (!cacheMode.isScattered()) {
if (transactionMode.isTransactional()) {
if (configuration.transaction().lockingMode() == LockingMode.PESSIMISTIC) {
interceptorChain.appendInterceptor(createInterceptor(new PessimisticLockingInterceptor(), PessimisticLockingInterceptor.class), false);
} else {
interceptorChain.appendInterceptor(createInterceptor(new OptimisticLockingInterceptor(), OptimisticLockingInterceptor.class), false);
}
} else {
interceptorChain.appendInterceptor(createInterceptor(new NonTransactionalLockingInterceptor(), NonTransactionalLockingInterceptor.class), false);
}
}
// This needs to be after locking interceptor to guarantee that locks are still held when raising notifications
if (transactionMode.isTransactional() && configuration.transaction().notifications()) {
interceptorChain.appendInterceptor(createInterceptor(new NotificationInterceptor(), NotificationInterceptor.class), false);
}
if (configuration.sites().hasBackups()) {
if (transactionMode == TransactionMode.TRANSACTIONAL) {
if (configuration.transaction().lockingMode() == LockingMode.OPTIMISTIC) {
interceptorChain.appendInterceptor(createInterceptor(new OptimisticBackupInterceptor(), OptimisticBackupInterceptor.class), false);
} else {
interceptorChain.appendInterceptor(createInterceptor(new PessimisticBackupInterceptor(), PessimisticBackupInterceptor.class), false);
}
} else {
interceptorChain.appendInterceptor(createInterceptor(new NonTransactionalBackupInterceptor(), NonTransactionalBackupInterceptor.class), false);
}
}
// This needs to be added after the locking interceptor (for tx caches) but before the wrapping interceptor.
if (configuration.clustering().l1().enabled()) {
interceptorChain.appendInterceptor(createInterceptor(new L1LastChanceInterceptor(), L1LastChanceInterceptor.class), false);
}
if (configuration.clustering().hash().groups().enabled()) {
interceptorChain.appendInterceptor(createInterceptor(new GroupingInterceptor(), GroupingInterceptor.class), false);
}
if (cacheMode.isScattered()) {
interceptorChain.appendInterceptor(createInterceptor(new PrefetchInterceptor(), PrefetchInterceptor.class), false);
}
if (needsVersionAwareComponents) {
interceptorChain.appendInterceptor(createInterceptor(new VersionedEntryWrappingInterceptor(), VersionedEntryWrappingInterceptor.class), false);
} else if (cacheMode.isScattered()) {
if (configuration.clustering().biasAcquisition() == BiasAcquisition.NEVER) {
interceptorChain.appendInterceptor(createInterceptor(new RetryingEntryWrappingInterceptor(), RetryingEntryWrappingInterceptor.class), false);
} else {
interceptorChain.appendInterceptor(createInterceptor(new BiasedEntryWrappingInterceptor(), BiasedEntryWrappingInterceptor.class), false);
}
} else {
interceptorChain.appendInterceptor(createInterceptor(new EntryWrappingInterceptor(), EntryWrappingInterceptor.class), false);
}
// Has to be after entry wrapping interceptor so it can properly see context values even when removed
if (transactionMode.isTransactional()) {
if (configuration.memory().evictionStrategy().isExceptionBased()) {
interceptorChain.appendInterceptor(createInterceptor(new TransactionalExceptionEvictionInterceptor(), TransactionalExceptionEvictionInterceptor.class), false);
}
}
if (configuration.persistence().usingStores()) {
addPersistenceInterceptors(interceptorChain, configuration, configuration.persistence().stores());
}
if (configuration.clustering().l1().enabled()) {
if (transactionMode.isTransactional()) {
interceptorChain.appendInterceptor(createInterceptor(new L1TxInterceptor(), L1TxInterceptor.class), false);
} else {
interceptorChain.appendInterceptor(createInterceptor(new L1NonTxInterceptor(), L1NonTxInterceptor.class), false);
}
}
if (configuration.sites().hasAsyncEnabledBackups() && cacheMode.isClustered()) {
if (transactionMode == TransactionMode.TRANSACTIONAL) {
if (configuration.transaction().lockingMode() == LockingMode.OPTIMISTIC) {
interceptorChain.appendInterceptor(createInterceptor(new OptimisticTxIracLocalSiteInterceptor(), OptimisticTxIracLocalSiteInterceptor.class), false);
} else {
interceptorChain.appendInterceptor(createInterceptor(new PessimisticTxIracLocalInterceptor(), PessimisticTxIracLocalInterceptor.class), false);
}
} else {
interceptorChain.appendInterceptor(createInterceptor(new NonTxIracLocalSiteInterceptor(), NonTxIracLocalSiteInterceptor.class), false);
}
}
switch(cacheMode) {
case INVALIDATION_SYNC:
case INVALIDATION_ASYNC:
interceptorChain.appendInterceptor(createInterceptor(new InvalidationInterceptor(), InvalidationInterceptor.class), false);
break;
case DIST_SYNC:
case REPL_SYNC:
if (needsVersionAwareComponents) {
interceptorChain.appendInterceptor(createInterceptor(new VersionedDistributionInterceptor(), VersionedDistributionInterceptor.class), false);
break;
}
case DIST_ASYNC:
case REPL_ASYNC:
if (transactionMode.isTransactional()) {
interceptorChain.appendInterceptor(createInterceptor(new TxDistributionInterceptor(), TxDistributionInterceptor.class), false);
} else {
if (cacheMode.isDistributed() && Configurations.isEmbeddedMode(globalConfiguration)) {
interceptorChain.appendInterceptor(createInterceptor(new TriangleDistributionInterceptor(), TriangleDistributionInterceptor.class), false);
} else {
interceptorChain.appendInterceptor(createInterceptor(new NonTxDistributionInterceptor(), NonTxDistributionInterceptor.class), false);
}
}
break;
case SCATTERED_SYNC:
if (configuration.clustering().biasAcquisition() != BiasAcquisition.NEVER) {
interceptorChain.appendInterceptor(createInterceptor(new BiasedScatteredDistributionInterceptor(), BiasedScatteredDistributionInterceptor.class), false);
} else {
interceptorChain.appendInterceptor(createInterceptor(new ScatteredDistributionInterceptor(), ScatteredDistributionInterceptor.class), false);
}
break;
case LOCAL:
}
if (cacheMode.isClustered()) {
// local caches not involved in Cross Site Replication
interceptorChain.appendInterceptor(createInterceptor(new NonTxIracRemoteSiteInterceptor(needsVersionAwareComponents), NonTxIracRemoteSiteInterceptor.class), false);
}
AsyncInterceptor callInterceptor = createInterceptor(new CallInterceptor(), CallInterceptor.class);
interceptorChain.appendInterceptor(callInterceptor, false);
log.trace("Finished building default interceptor chain.");
buildCustomInterceptors(interceptorChain, configuration.customInterceptors());
return interceptorChain;
}
Aggregations