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

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


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

  Modified:    src/org/jboss/cache  CacheImpl.java
  Log:
  JBCACHE-1045 and made ICF a singleton
  
  Revision  Changes    Path
  1.66      +41 -47    JBossCache/src/org/jboss/cache/CacheImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheImpl.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -b -r1.65 -r1.66
  --- CacheImpl.java	22 May 2007 08:47:50 -0000	1.65
  +++ CacheImpl.java	22 May 2007 11:43:35 -0000	1.66
  @@ -363,7 +363,7 @@
       */
      public List<Interceptor> getInterceptors()
      {
  -      return InterceptorChainFactory.asList(interceptor_chain);
  +      return InterceptorChainFactory.getInstance().asList(interceptor_chain);
      }
   
      /**
  @@ -574,6 +574,15 @@
         setUseReplQueue(configuration.isUseReplQueue());
         setIsolationLevel(configuration.getIsolationLevel());
   
  +      getRegionManager();// make sure we create one
  +      createEvictionPolicy();
  +
  +      getRegionManager().setDefaultInactive(configuration.isInactiveOnStartup());
  +      createCalled = true;
  +   }
  +
  +   private void createTransactionManager()
  +   {
         // See if we had a TransactionManager injected into our config
         this.tm = configuration.getRuntimeConfig().getTransactionManager();
         if (tm == null)
  @@ -616,49 +625,6 @@
               log.debug("failed looking up TransactionManager, will not use transactions", e);
            }
         }
  -
  -      // create cache loader
  -      if (configuration.getCacheLoaderConfig() != null && cacheLoaderManager == null)
  -      {
  -         initialiseCacheLoaderManager();
  -      }
  -
  -      getRegionManager();// make sure we create one
  -      createEvictionPolicy();
  -
  -      switch (configuration.getCacheMode())
  -      {
  -         case LOCAL:
  -            log.debug("cache mode is local, will not create the channel");
  -            break;
  -         case REPL_SYNC:
  -         case REPL_ASYNC:
  -         case INVALIDATION_ASYNC:
  -         case INVALIDATION_SYNC:
  -
  -            if (log.isDebugEnabled()) log.debug("cache mode is " + configuration.getCacheMode());
  -
  -            initialiseChannelAndRpcDispatcher();
  -
  -            setBuddyReplicationConfig(configuration.getBuddyReplicationConfig());
  -            break;
  -         default:
  -            throw new IllegalArgumentException("cache mode " + configuration.getCacheMode() + " is invalid");
  -      }
  -
  -      // build interceptor chain
  -      try
  -      {
  -         interceptor_chain = new InterceptorChainFactory().buildInterceptorChain(this);
  -      }
  -      catch (Exception e)
  -      {
  -         throw new CacheException("Unable to build interceptor chain", e);
  -      }
  -
  -      getRegionManager().setDefaultInactive(configuration.isInactiveOnStartup());
  -
  -      createCalled = true;
      }
   
      protected boolean shouldFetchStateOnStartup()
  @@ -681,21 +647,44 @@
            create();
         }
   
  +      createTransactionManager();
  +
         // cache loaders should be initialised *before* any state transfers take place to prevent
         // exceptions involving cache loaders not being started. - Manik
  +      // create cache loader
  +      if (configuration.getCacheLoaderConfig() != null && cacheLoaderManager == null)
  +      {
  +         initialiseCacheLoaderManager();
  +      }
         if (cacheLoaderManager != null)
         {
            cacheLoaderManager.startCacheLoader();
         }
   
  +      // now that we have a TM we can init the interceptor chain
  +      // build interceptor chain
  +      try
  +      {
  +         interceptor_chain = InterceptorChainFactory.getInstance().buildInterceptorChain(this);
  +      }
  +      catch (Exception e)
  +      {
  +         throw new CacheException("Unable to build interceptor chain", e);
  +      }
  +
         switch (configuration.getCacheMode())
         {
            case LOCAL:
  +            log.debug("cache mode is local, will not create the channel");
               break;
            case REPL_SYNC:
            case REPL_ASYNC:
            case INVALIDATION_ASYNC:
            case INVALIDATION_SYNC:
  +            if (log.isDebugEnabled()) log.debug("cache mode is " + configuration.getCacheMode());
  +            initialiseChannelAndRpcDispatcher();
  +            setBuddyReplicationConfig(configuration.getBuddyReplicationConfig());
  +
               try
               {
                  channel.connect(configuration.getClusterName());
  @@ -790,6 +779,7 @@
            log.info("stop(): closing the channel");
            channel.close();
            channel = null;
  +         configuration.getRuntimeConfig().setChannel(null);
         }
         if (disp != null)
         {
  @@ -824,7 +814,11 @@
            notifier.setEvictionPolicyListener(null);
         }
   
  -      createCalled = false;
  +      // unset transaction manager reference
  +      tm = null;
  +
  +      // JBCACHE-1045
  +//      createCalled = false;
         started = false;
      }
   
  @@ -4073,7 +4067,7 @@
         interceptors.add(position, i);
   
         // now correct the chaining of interceptors...
  -      Interceptor linkedChain = InterceptorChainFactory.correctInterceptorChaining(interceptors);
  +      Interceptor linkedChain = InterceptorChainFactory.getInstance().correctInterceptorChaining(interceptors);
   
         setInterceptorChain(linkedChain);
      }
  @@ -4082,7 +4076,7 @@
      {
         List<Interceptor> i = getInterceptors();
         i.remove(position);
  -      setInterceptorChain(InterceptorChainFactory.correctInterceptorChaining(i));
  +      setInterceptorChain(InterceptorChainFactory.getInstance().correctInterceptorChaining(i));
      }
   
      public RPCManager getRPCManager()
  
  
  



More information about the jboss-cvs-commits mailing list