Package org.infinispan.interceptors.base

Examples of org.infinispan.interceptors.base.CommandInterceptor


      if (firstInChain == null) return;
      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

    */
   public void removeInterceptor(Class<? extends CommandInterceptor> clazz) {
      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

    * Adds a new interceptor in list after an interceptor of a given type.
    *
    * @return true if the interceptor was added; i.e. the afterInterceptor exists
    */
   public boolean addInterceptorAfter(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

      if (firstInChain.getClass().equals(beforeInterceptor)) {
         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

      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 synchronized 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 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> getInterceptorsWithClassName(String name) {
      CommandInterceptor iterator = firstInChain;
      List<CommandInterceptor> result = new ArrayList<CommandInterceptor>(2);
      while (iterator != null) {
         if (iterator.getClass().getName().equals(name)) 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

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.