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

   /**
    * 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 false;
   }

   public synchronized boolean containsInterceptorType(Class<? extends CommandInterceptor> interceptorType) {
      CommandInterceptor it = firstInChain;
      while (it != null) {
         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);

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

            break;
         case LOCAL:
            //Nothing...
      }

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

   private void buildCustomInterceptors(InterceptorChain interceptorChain, CustomInterceptorsConfiguration customInterceptors) {
      for (InterceptorConfiguration config : customInterceptors.interceptors()) {
         if (interceptorChain.containsInterceptorType(config.interceptor().getClass())) continue;

         CommandInterceptor customInterceptor = config.interceptor();
         register(customInterceptor.getClass(), customInterceptor);
         if (config.first())
            interceptorChain.addInterceptor(customInterceptor, 0);
         else if (config.last())
            interceptorChain.appendInterceptor(customInterceptor, true);
         else if (config.index() >= 0)
View Full Code Here

*/
@DefaultFactoryFor(classes = InterceptorChain.class)
public class InterceptorChainFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {

   public CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) {
      CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
      if (chainedInterceptor == null) {
         chainedInterceptor = Util.getInstance(clazz);
         try {
            componentRegistry.registerComponent(chainedInterceptor, clazz);
         }
         catch (RuntimeException e) {
            log.warn("Problems creating interceptor " + clazz);
            throw e;
         }
      } else {
         // wipe next/last chaining!!
         chainedInterceptor.setNext(null);
      }
      return chainedInterceptor;
   }
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.