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

Manik Surtani msurtani at jboss.com
Wed Jan 10 11:25:22 EST 2007


  User: msurtani
  Date: 07/01/10 11:25:22

  Modified:    src/org/jboss/cache/factories   DefaultCacheFactory.java
                        CacheFactory.java
  Log:
  Removed cloning cache configs by default
  
  Revision  Changes    Path
  1.15      +4 -35     JBossCache/src/org/jboss/cache/factories/DefaultCacheFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DefaultCacheFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/factories/DefaultCacheFactory.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -b -r1.14 -r1.15
  --- DefaultCacheFactory.java	5 Jan 2007 11:42:53 -0000	1.14
  +++ DefaultCacheFactory.java	10 Jan 2007 16:25:22 -0000	1.15
  @@ -48,8 +48,7 @@
   
      public Cache createCache() throws ConfigurationException
      {
  -      // don't bother cloning the cfg since we're creating it here.
  -      return createCache(new Configuration(), true, false);
  +      return createCache(new Configuration(), true);
      }
   
      public Cache createCache(String configFileName) throws ConfigurationException
  @@ -61,8 +60,7 @@
      {
         XmlConfigurationParser parser = new XmlConfigurationParser();
         Configuration c = parser.parseFile(configFileName);
  -      // don't bother cloning the cfg since we're creating it here.
  -      return createCache(c, start, false);
  +      return createCache(c, start);
      }
   
      /**
  @@ -74,8 +72,7 @@
       */
      public Cache createCache(Configuration configuration) throws ConfigurationException
      {
  -      // make sure we clone any configs passed in from the outside world.
  -      return createCache(configuration, true, true);
  +      return createCache(configuration, true);
      }
   
      /**
  @@ -88,38 +85,10 @@
       */
      public Cache createCache(Configuration configuration, boolean start) throws ConfigurationException
      {
  -      // make sure we clone any configs passed in from the outside world, in case it is reused by several caches.
  -      // We don't want updates to one cache instance be reflected in others.
  -      return createCache(configuration, start, true);
  -   }
  -
  -   /**
  -    * Creates a cache with the option of starting the cache and cloning the configuration.
  -    *
  -    * @param configuration      with which to create a cache
  -    * @param start              whether we start the cache or not
  -    * @param cloneConfiguration whether we clone the cfg or not
  -    * @return a cache
  -    * @throws ConfigurationException if there are problems with the cfg
  -    */
  -   private Cache createCache(Configuration configuration, boolean start, boolean cloneConfiguration) throws ConfigurationException
  -   {
  -      Configuration toUse = configuration;
  -      if (cloneConfiguration)
  -      {
  -         try
  -         {
  -            toUse = configuration.clone();
  -         }
  -         catch (CloneNotSupportedException e)
  -         {
  -            log.error("Unable to clone configuration?", e);
  -         }
  -      }
         try
         {
            CacheImpl cache = new CacheImpl();
  -         cache.setConfiguration(toUse);
  +         cache.setConfiguration(configuration);
            if (start) cache.start();
            return cache;
         }
  
  
  
  1.7       +6 -4      JBossCache/src/org/jboss/cache/factories/CacheFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CacheFactory.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/factories/CacheFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- CacheFactory.java	5 Jan 2007 11:42:53 -0000	1.6
  +++ CacheFactory.java	10 Jan 2007 16:25:22 -0000	1.7
  @@ -63,8 +63,9 @@
   
      /**
       * Creates a {@link Cache} instance based on a {@link org.jboss.cache.config.Configuration} passed in.
  -    * Implementations should clone the configuration passed in before using it, to ensure the reference is not
  -    * shared and cannot be affected by the configuration changing unexpectedly.
  +    * <p/>
  +    * Ensure that the Configuration you pass in is not used by another cache instance in the same JVM, as this may have untoward
  +    * consequences.  {@link org.jboss.cache.config.Configuration#clone()} is your friend.
       *
       * @param configuration the {@link Configuration} object that is passed in to configure the {@link Cache}.
       * @return a running {@link Cache} instance
  @@ -75,8 +76,9 @@
   
      /**
       * Creates {@link Cache} instance, and optionally starts it, based on a {@link org.jboss.cache.config.Configuration} passed in.
  -    * Implementations should clone the configuration passed in before using it, to ensure the reference is not
  -    * shared and cannot be affected by the configuration changing unexpectedly.
  +    * <p/>
  +    * Ensure that the Configuration you pass in is not used by another cache instance in the same JVM, as this may have untoward
  +    * consequences.  {@link org.jboss.cache.config.Configuration#clone()} is your friend.
       *
       * @param configuration the {@link Configuration} object that is passed in to configure the {@link Cache}.
       * @param start         if true, the cache is started before returning.
  
  
  



More information about the jboss-cvs-commits mailing list