[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/misc ...

Manik Surtani manik at jboss.org
Thu Jul 19 08:55:57 EDT 2007


  User: msurtani
  Date: 07/07/19 08:55:57

  Modified:    tests/functional/org/jboss/cache/misc  TestingUtil.java
  Log:
  added unitity method to inject interceptors into a running cache
  
  Revision  Changes    Path
  1.16      +25 -0     JBossCache/tests/functional/org/jboss/cache/misc/TestingUtil.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TestingUtil.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/misc/TestingUtil.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -b -r1.15 -r1.16
  --- TestingUtil.java	17 Jul 2007 02:03:26 -0000	1.15
  +++ TestingUtil.java	19 Jul 2007 12:55:57 -0000	1.16
  @@ -11,6 +11,7 @@
   import org.jboss.cache.CacheImpl;
   import org.jboss.cache.CacheSPI;
   import org.jboss.cache.interceptors.Interceptor;
  +import org.jboss.cache.util.CachePrinter;
   
   import java.io.File;
   import java.util.List;
  @@ -44,6 +45,30 @@
      }
   
      /**
  +    * Injects an interceptor after a specified interceptor in a running cache.  Your new interceptor need not be
  +    * initialised with pointers to the next interceptor, etc. as this method does all that for you, including calling
  +    * setCache().
  +    *
  +    * @param cache                         running cache instance
  +    * @param interceptorToInject           interceptor instance to inject.
  +    * @param interceptorAfterWhichToInject class of interceptor to search for in the chain and after which to add your interceptor
  +    */
  +   public static void injectInterceptor(CacheSPI<?, ?> cache, Interceptor interceptorToInject, Class<? extends Interceptor> interceptorAfterWhichToInject)
  +   {
  +      System.out.println("Old interceptor chain: " + CachePrinter.printCacheInterceptors(cache));
  +      interceptorToInject.setCache(cache);
  +      int index = -1;
  +      for (Interceptor i : cache.getInterceptorChain())
  +      {
  +         index++;
  +         if (interceptorAfterWhichToInject.isInstance(i)) break;
  +      }
  +
  +      cache.addInterceptor(interceptorToInject, index + 1);
  +      System.out.println("New interceptor chain: " + CachePrinter.printCacheInterceptors(cache));
  +   }
  +
  +   /**
       * Loops, continually calling {@link #areCacheViewsComplete(org.jboss.cache.Cache[])}
       * until it either returns true or <code>timeout</code> ms have elapsed.
       *
  
  
  



More information about the jboss-cvs-commits mailing list