Package org.jboss.cache.interceptors.base

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


      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

   {
      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

   /**
    * 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

   @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

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.