Package org.jboss.cache.interceptors.base

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


    */
   public static void replaceInterceptorChain(CacheSPI<?, ?> 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


   {
      Iterator ints = cache.getInterceptorChain().iterator();
      CacheStoreInterceptor csi = null;
      while (ints.hasNext())
      {
         CommandInterceptor i = (CommandInterceptor) ints.next();
         if (i instanceof CacheStoreInterceptor)
         {
            csi = (CacheStoreInterceptor) i;
            break;
         }
View Full Code Here

   @BeforeMethod
   public void setUp() throws Exception
   {
      cache = createCache();

      CommandInterceptor interceptor = TestingUtil.findInterceptor(cache, OptimisticCreateIfNotExistsInterceptor.class);
      CommandInterceptor nodeInterceptor = TestingUtil.findInterceptor(cache, OptimisticNodeInterceptor.class);
      dummy = new MockInterceptor();

      interceptor.setNext(nodeInterceptor);
      nodeInterceptor.setNext(dummy);

      TestingUtil.replaceInterceptorChain(cache, interceptor);

      mgr = cache.getTransactionManager();
   }
View Full Code Here

         before = getAttributeValue(interceptorElement, "before");
         if (!existsAttribute(before)) before = null;
         after = getAttributeValue(interceptorElement, "after");
         if (!existsAttribute(after)) after = null;

         CommandInterceptor interceptor = buildCommandInterceptor(interceptorElement);

         CustomInterceptorConfig customInterceptorConfig = new CustomInterceptorConfig(interceptor, first, last, index, after, before);
         interceptorConfigs.add(customInterceptorConfig);
      }
      return interceptorConfigs;
View Full Code Here

    */
   private CommandInterceptor buildCommandInterceptor(Element element)
   {
      String interceptorClass = getAttributeValue(element, "class");
      if (!existsAttribute(interceptorClass)) throw new ConfigurationException("Interceptor class cannot be empty!");
      CommandInterceptor result;
      try
      {
         result = (CommandInterceptor) Util.loadClass(interceptorClass).newInstance();
      }
      catch (Exception e)
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

         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

   public List<CommandInterceptor> asList()
   {
      if (firstInChain == null) return Collections.emptyList();

      List<CommandInterceptor> retval = new LinkedList<CommandInterceptor>();
      CommandInterceptor tmp = firstInChain;
      do
      {
         retval.add(tmp);
         tmp = tmp.getNext();
      }
      while (tmp != null);
      return Collections.unmodifiableList(retval);
   }
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.