Package org.jboss.cache.interceptors.base

Examples of org.jboss.cache.interceptors.base.CommandInterceptor


   {
      if (firstInChain.getClass() == clazz)
      {
         firstInChain = firstInChain.getNext();
      }
      CommandInterceptor it = firstInChain.getNext();
      CommandInterceptor prevIt = firstInChain;
      while (it != null)
      {
         if (it.getClass() == clazz)
         {
            prevIt.setNext(it.getNext());
         }
         prevIt = it;
         it = it.getNext();
      }
   }
View Full Code Here


    *
    * @return true if the interceptor was added; i.e. the afterInterceptor exists
    */
   public synchronized boolean addAfterInterceptor(CommandInterceptor toAdd, Class<? extends CommandInterceptor> afterInterceptor)
   {
      CommandInterceptor it = firstInChain;
      while (it != null)
      {
         if (it.getClass().equals(afterInterceptor))
         {
            toAdd.setNext(it.getNext());
            it.setNext(toAdd);
            return true;
         }
         it = it.getNext();
      }
      return false;
   }
View Full Code Here

      {
         toAdd.setNext(firstInChain);
         firstInChain = toAdd;
         return true;
      }
      CommandInterceptor it = firstInChain;
      while (it.getNext() != null)
      {
         if (it.getNext().getClass().equals(beforeInterceptor))
         {
            toAdd.setNext(it.getNext());
            it.setNext(toAdd);
            return true;
         }
         it = it.getNext();
      }
      return false;
   }
View Full Code Here

   /**
    * Appends at the end.
    */
   public void appendIntereceptor(CommandInterceptor ci)
   {
      CommandInterceptor it = firstInChain;
      while (it.hasNext()) it = it.getNext();
      it.setNext(ci);
      // make sure we nullify the "next" pointer in the last interceptor.
      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> getInterceptorsWithClassName(String fqName)
   {
      CommandInterceptor iterator = firstInChain;
      List<CommandInterceptor> result = new ArrayList<CommandInterceptor>(2);
      while (iterator != null)
      {
         if (iterator.getClass().getName().equals(fqName)) result.add(iterator);
         iterator = iterator.getNext();
      }
      return result;
   }
View Full Code Here

      return new InterceptorChainFactory();
   }

   private CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) throws IllegalAccessException, InstantiationException
   {
      CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
      if (chainedInterceptor == null)
      {
         chainedInterceptor = clazz.newInstance();
         componentRegistry.registerComponent(chainedInterceptor, clazz);
      }
      else
      {
         // wipe next/last chaining!!
         chainedInterceptor.setNext(null);
      }
      chainedInterceptor.setStatisticsEnabled(configuration.getExposeManagementStatistics());
      return chainedInterceptor;
   }
View Full Code Here

   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;
   }
View Full Code Here

         interceptor.setNext(firstInChain);
         firstInChain = interceptor;
         return;
      }
      if (firstInChain == null) return;
      CommandInterceptor it = firstInChain;
      int index = 0;
      while (it != null)
      {
         if (++index == position)
         {
            interceptor.setNext(it.getNext());
            it.setNext(interceptor);
            return;
         }
         it = it.getNext();
      }
      throw new IllegalArgumentException("Invalid index: " + index + " !");
   }
View Full Code Here

      if (position == 0)
      {
         firstInChain = firstInChain.getNext();
         return;
      }
      CommandInterceptor it = firstInChain;
      int index = 0;
      while (it != null)
      {
         if (++index == position)
         {
            if (it.getNext() == null) return; //nothing to remove
            it.setNext(it.getNext().getNext());
            return;
         }
         it = it.getNext();
      }
      throw new IllegalArgumentException("Invalid position: " + position + " !");
   }
View Full Code Here

    * Returns the number of interceptors in the chain.
    */
   public int size()
   {
      int size = 0;
      CommandInterceptor it = firstInChain;
      while (it != null)
      {
         size++;
         it = it.getNext();
      }
      return size;

   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.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.