[jboss-cvs] JBossCache/src/org/jboss/cache/factories ...

Manik Surtani manik at jboss.org
Tue May 22 07:43:34 EDT 2007


  User: msurtani
  Date: 07/05/22 07:43:34

  Modified:    src/org/jboss/cache/factories  InterceptorChainFactory.java
  Log:
  JBCACHE-1045 and made ICF a singleton
  
  Revision  Changes    Path
  1.40      +37 -6     JBossCache/src/org/jboss/cache/factories/InterceptorChainFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: InterceptorChainFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/factories/InterceptorChainFactory.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -b -r1.39 -r1.40
  --- InterceptorChainFactory.java	27 Feb 2007 21:57:35 -0000	1.39
  +++ InterceptorChainFactory.java	22 May 2007 11:43:34 -0000	1.40
  @@ -24,7 +24,27 @@
    */
   public class InterceptorChainFactory
   {
  -   private static Log log = LogFactory.getLog(InterceptorChainFactory.class);
  +   private Log log = LogFactory.getLog(InterceptorChainFactory.class);
  +   private static InterceptorChainFactory singleton;
  +
  +   private InterceptorChainFactory()
  +   {
  +      // private ctor
  +   }
  +
  +   public static InterceptorChainFactory getInstance()
  +   {
  +      if (singleton == null)
  +      {
  +         synchronized (InterceptorChainFactory.class)
  +         {
  +            if (singleton == null) singleton = new InterceptorChainFactory();
  +         }
  +      }
  +
  +      return singleton;
  +   }
  +
   
      public Interceptor buildInterceptorChain(CacheImpl cache) throws IllegalAccessException, ClassNotFoundException, InstantiationException
      {
  @@ -38,7 +58,7 @@
         }
      }
   
  -   public static Interceptor setLastInterceptorPointer(Interceptor first, Interceptor last)
  +   public Interceptor setLastInterceptorPointer(Interceptor first, Interceptor last)
      {
         Interceptor i = first;
         while (i != null)
  @@ -171,7 +191,6 @@
         else
            addInterceptor(first, notificationInterceptor);
   
  -
         // create the stack from the bottom up
   //      if (activation_interceptor != null)
   //      {
  @@ -611,7 +630,7 @@
         return setLastInterceptorPointer(first, invokerInterceptor);
      }
   
  -   public static String printInterceptorChain(Interceptor i)
  +   public String printInterceptorChain(Interceptor i)
      {
         StringBuffer sb = new StringBuffer();
         if (i != null)
  @@ -625,7 +644,7 @@
         return sb.toString();
      }
   
  -   public static List<Interceptor> asList(Interceptor interceptor)
  +   public List<Interceptor> asList(Interceptor interceptor)
      {
         if (interceptor == null)
         {
  @@ -655,7 +674,7 @@
       * @param interceptors
       * @return the first interceptor in the chain.
       */
  -   public static Interceptor correctInterceptorChaining(List<Interceptor> interceptors)
  +   public Interceptor correctInterceptorChaining(List<Interceptor> interceptors)
      {
         Interceptor first = null, last = null;
   
  @@ -675,4 +694,16 @@
         // now set the 'last' pointer.
         return setLastInterceptorPointer(first, last);
      }
  +
  +   /**
  +    * Initialises the interceptors with a CacheSPI instance.  Essentially calls setCache().  This is done AFTER the interceptor chain
  +    * is created, and when Cache.start() is called, so the interceptors get a fully initialised cache.
  +    *
  +    * @param chain interceptor chain
  +    * @param cache cache instance
  +    */
  +   public void initialiseInterceptors(Interceptor firstInterceptor, CacheSPI cache)
  +   {
  +      for (Interceptor i : asList(firstInterceptor)) i.setCache(cache);
  +   }
   }
  
  
  



More information about the jboss-cvs-commits mailing list