Package org.infinispan.interceptors.base

Examples of org.infinispan.interceptors.base.CommandInterceptor


         if (firstInChain.getClass().equals(toBeReplacedInterceptorType)) {
            replacingInterceptor.setNext(firstInChain.getNext());
            firstInChain = replacingInterceptor;
            return true;
         }
         CommandInterceptor it = firstInChain;
         CommandInterceptor previous = firstInChain;
         while (it.getNext() != null) {
            CommandInterceptor current = it.getNext();
            if (current.getClass().equals(toBeReplacedInterceptorType)) {
               replacingInterceptor.setNext(current.getNext());
               previous.setNext(replacingInterceptor);
               return true;
            }
            previous = current;
            it = current;
View Full Code Here


    * Appends at the end.
    */
   public void appendInterceptor(CommandInterceptor ci, boolean isCustom) {
      if (isCustom) validateCustomInterceptor(ci.getClass());
      // Called when building interceptor chain and so concurrent start calls are protected already
      CommandInterceptor it = firstInChain;
      while (it.hasNext()) it = it.getNext();
      it.setNext(ci);
      // make sure we nullify the "next" pointer in the last interceptors.
      ci.setNext(null);
   }
View Full Code Here

    * Returns all the interceptors that have the fully qualified name of their class equal with the supplied class
    * name.
    */
   public List<CommandInterceptor> getInterceptorsWithClass(Class clazz) {
      // Called when building interceptor chain and so concurrent start calls are protected already
      CommandInterceptor iterator = firstInChain;
      List<CommandInterceptor> result = new ArrayList<CommandInterceptor>(2);
      while (iterator != null) {
         if (iterator.getClass() == clazz) result.add(iterator);
         iterator = iterator.getNext();
      }
      return result;
   }
View Full Code Here

      return result;
   }

   public String toString() {
      StringBuilder sb = new StringBuilder();
      CommandInterceptor i = firstInChain;
      while (i != null) {
         sb.append("\n\t>> ");
         sb.append(i.getClass().getName());
         i = i.getNext();
      }
      return sb.toString();
   }
View Full Code Here

   /**
    * Checks whether the chain contains the supplied interceptor instance.
    */
   public boolean containsInstance(CommandInterceptor interceptor) {
      CommandInterceptor it = firstInChain;
      while (it != null) {
         if (it == interceptor) return true;
         it = it.getNext();
      }
      return false;
   }
View Full Code Here

      return containsInterceptorType(interceptorType, false);
   }

   public boolean containsInterceptorType(Class<? extends CommandInterceptor> interceptorType, boolean alsoMatchSubClasses) {
      // Called when building interceptor chain and so concurrent start calls are protected already
      CommandInterceptor it = firstInChain;
      while (it != null) {
         if (alsoMatchSubClasses) {
            if (interceptorType.isAssignableFrom(it.getClass())) return true;
         } else {
            if (it.getClass().equals(interceptorType)) return true;
         }
         it = it.getNext();
      }
      return false;
   }
View Full Code Here

public class InterceptorChainFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {

   private static final Log log = LogFactory.getLog(InterceptorChainFactory.class);

   public CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) {
      CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
      if (chainedInterceptor == null) {
         chainedInterceptor = Util.getInstance(clazz);
         register(clazz, chainedInterceptor);
      } else {
         // wipe next/last chaining!!
         chainedInterceptor.setNext(null);
      }
      return chainedInterceptor;
   }
View Full Code Here

            configuration.getTransactionLockingMode() == LockingMode.OPTIMISTIC && configuration.isEnableVersioning();

      boolean invocationBatching = configuration.isInvocationBatchingEnabled();
      // load the icInterceptor first

      CommandInterceptor first;
      if (invocationBatching) {
         first = createInterceptor(BatchingInterceptor.class);
      } else {
         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);

      // add marshallable check interceptor for situations where we want to figure out before marshalling
      if (isUsingMarshalledValues(configuration) || configuration.isUseAsyncMarshalling()
            || configuration.isUseReplQueue() || hasAsyncStore())
         interceptorChain.appendInterceptor(createInterceptor(IsMarshallableInterceptor.class));

      // NOW add the ICI if we are using batching!
      if (invocationBatching) {
         interceptorChain.appendInterceptor(createInterceptor(InvocationContextInterceptor.class));
      }

      // load the cache management interceptor next
      if (configuration.isExposeJmxStatistics())
         interceptorChain.appendInterceptor(createInterceptor(CacheMgmtInterceptor.class));

      // load the state transfer lock interceptor
      // the state transfer lock ensures that the cache member list is up-to-date
      // so it's necessary even if state transfer is disabled
      if (configuration.getCacheMode().isDistributed() || configuration.getCacheMode().isReplicated())
         interceptorChain.appendInterceptor(createInterceptor(StateTransferLockInterceptor.class));

      // load the tx interceptor
      if (configuration.isTransactionalCache()) {
         if (configuration.getCacheMode().isDistributed())
            interceptorChain.appendInterceptor(createInterceptor(DistTxInterceptor.class));
         else
            interceptorChain.appendInterceptor(createInterceptor(TxInterceptor.class));
      }

      if (isUsingMarshalledValues(configuration))
         interceptorChain.appendInterceptor(createInterceptor(MarshalledValueInterceptor.class));

      interceptorChain.appendInterceptor(createInterceptor(NotificationInterceptor.class));

      if (configuration.isUseEagerLocking()) {
         configuration.fluent().transaction().lockingMode(LockingMode.PESSIMISTIC);
      }

      if (configuration.isTransactionalCache()) {
         if (configuration.getTransactionLockingMode() == LockingMode.PESSIMISTIC) {
            interceptorChain.appendInterceptor(createInterceptor(PessimisticLockingInterceptor.class));
         } else {
            interceptorChain.appendInterceptor(createInterceptor(OptimisticLockingInterceptor.class));
         }
      } else {
         interceptorChain.appendInterceptor(createInterceptor(NonTransactionalLockingInterceptor.class));
      }

      if (needsVersionAwareComponents && configuration.getCacheMode().isClustered())
         interceptorChain.appendInterceptor(createInterceptor(VersionedEntryWrappingInterceptor.class));
      else
         interceptorChain.appendInterceptor(createInterceptor(EntryWrappingInterceptor.class));

      if (configuration.isUsingCacheLoaders()) {
         if (configuration.getCacheLoaderManagerConfig().isPassivation()) {
            interceptorChain.appendInterceptor(createInterceptor(ActivationInterceptor.class));
            interceptorChain.appendInterceptor(createInterceptor(PassivationInterceptor.class));
         } else {
            interceptorChain.appendInterceptor(createInterceptor(CacheLoaderInterceptor.class));
            switch (configuration.getCacheMode()) {
               case DIST_SYNC:
               case DIST_ASYNC:
                  interceptorChain.appendInterceptor(createInterceptor(DistCacheStoreInterceptor.class));
                  break;
               default:
                  interceptorChain.appendInterceptor(createInterceptor(CacheStoreInterceptor.class));
                  break;
            }
         }
      }

      if (configuration.isEnableDeadlockDetection()) {
         interceptorChain.appendInterceptor(createInterceptor(DeadlockDetectingInterceptor.class));
      }

      switch (configuration.getCacheMode()) {
         case REPL_SYNC:
            if (needsVersionAwareComponents) {
               interceptorChain.appendInterceptor(createInterceptor(VersionedReplicationInterceptor.class));
               break;
            }
         case REPL_ASYNC:
            interceptorChain.appendInterceptor(createInterceptor(ReplicationInterceptor.class));
            break;
         case INVALIDATION_SYNC:
         case INVALIDATION_ASYNC:
            interceptorChain.appendInterceptor(createInterceptor(InvalidationInterceptor.class));
            break;
         case DIST_SYNC:
            if (needsVersionAwareComponents) {
               interceptorChain.appendInterceptor(createInterceptor(VersionedDistributionInterceptor.class));
               break;
            }
         case DIST_ASYNC:
            interceptorChain.appendInterceptor(createInterceptor(DistributionInterceptor.class));
            break;
         case LOCAL:
            //Nothing...
      }

      CommandInterceptor callInterceptor = createInterceptor(CallInterceptor.class);
      interceptorChain.appendInterceptor(callInterceptor);
      if (log.isTraceEnabled()) log.trace("Finished building default interceptor chain.");
      buildCustomInterceptors(interceptorChain, configuration.getCustomInterceptors());
      return interceptorChain;
   }
View Full Code Here

      if (cfg.getInterceptor() != null) return cfg.getInterceptor().getClass();
      return Util.loadClass(cfg.getClassName(), configuration.getClassLoader());
   }

   private CommandInterceptor getOrCreateCustomInterceptor(CustomInterceptorConfig cfg) {
      CommandInterceptor result = cfg.getInterceptor();
      if (result == null) {
         result = Util.getInstance(cfg.getClassName(), configuration.getClassLoader());
      }
      register(result.getClass(), result);
      return result;
   }
View Full Code Here

    * @param interceptor the first interceptor in the new chain.
    */
   public static void replaceInterceptorChain(Cache cache, CommandInterceptor interceptor) {
      ComponentRegistry cr = extractComponentRegistry(cache);
      // make sure all interceptors here are wired.
      CommandInterceptor i = interceptor;
      do {
         cr.wireDependencies(i);
      }
      while ((i = i.getNext()) != null);

      InterceptorChain inch = cr.getComponent(InterceptorChain.class);
      inch.setFirstInChain(interceptor);
   }
View Full Code Here

TOP

Related Classes of org.infinispan.interceptors.base.CommandInterceptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.