db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/cache ObjectCachePerClassImpl.java
Date Tue, 20 Jul 2004 18:09:16 GMT
arminw      2004/07/20 11:09:16

  Modified:    src/java/org/apache/ojb/broker/cache
                        ObjectCachePerClassImpl.java
  Log:
  add fix by Dave Hodson:
  In RC4, we use the MetaObjectCachePerClassImpl class to handle this,
  setting a particular class' cache to NULL when we wanted no caching for
  that class.
  In 1.0 we're looking at the ObjectCachePerClass class, as
  MetaObjectCachePerClassImpl is no longer available. The cases where we
  want to set the caching for a particular class to NULL (i.e. don't
  cache) no longer work properly. Instead of returning NULL, they return
  the ObjectCacheDefaultImpl class.
  
  Revision  Changes    Path
  1.7       +26 -18    db-ojb/src/java/org/apache/ojb/broker/cache/ObjectCachePerClassImpl.java
  
  Index: ObjectCachePerClassImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/cache/ObjectCachePerClassImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ObjectCachePerClassImpl.java	4 Apr 2004 23:53:33 -0000	1.6
  +++ ObjectCachePerClassImpl.java	20 Jul 2004 18:09:16 -0000	1.7
  @@ -1,13 +1,13 @@
   package org.apache.ojb.broker.cache;
   
  -import org.apache.ojb.broker.PersistenceBroker;
  -import org.apache.ojb.broker.Identity;
  -
  -import java.util.Map;
  +import java.util.Collections;
   import java.util.HashMap;
   import java.util.Iterator;
  +import java.util.Map;
   import java.util.Properties;
  -import java.util.Collections;
  +
  +import org.apache.ojb.broker.Identity;
  +import org.apache.ojb.broker.PersistenceBroker;
   
   /* Copyright 2003-2004 The Apache Software Foundation
    *
  @@ -23,6 +23,13 @@
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
  +
  +/**
  + * Global {@link ObjectCache} implementation.
  + *
  + * @author matthew.baird
  + * @version $Id$
  + */
   public class ObjectCachePerClassImpl extends AbstractMetaCache
   {
       private static Map cachesByClass = Collections.synchronizedMap(new HashMap());
  @@ -60,12 +67,12 @@
        * Sets the ObjectCache implementation to use for objects with the given
        * type and subclasses
        *
  -     * @param objectClass  The object's class, use java.lang.Object to alter
  -     *                     default caching for all objects which have no special
  -     *                     caching defined
  -     * @param cache        The new ObjectCache implementation to use for this
  -     *                     class and subclasses, null to switch off caching
  -     *                     for the given class
  +     * @param objectClass The object's class, use java.lang.Object to alter
  +     *                    default caching for all objects which have no special
  +     *                    caching defined
  +     * @param cache       The new ObjectCache implementation to use for this
  +     *                    class and subclasses, null to switch off caching
  +     *                    for the given class
        */
       public void setClassCache(Class objectClass, ObjectCache cache)
   
  @@ -76,8 +83,8 @@
       /**
        * Sets the ObjectCache implementation for the given class name
        *
  -     * @param className  The name of the class to cache
  -     * @param cache      The ObjectCache to use for this class and subclasses
  +     * @param className The name of the class to cache
  +     * @param cache     The ObjectCache to use for this class and subclasses
        */
       private void setClassCache(String className, ObjectCache cache)
       {
  @@ -87,16 +94,17 @@
       /**
        * Gets the cache for the given class
        *
  -     * @param objectClass  The class to look up the cache for
  -     * @return             The cache
  +     * @param objectClass The class to look up the cache for
  +     * @return The cache
        */
       private ObjectCache getCachePerClass(Class objectClass, int methodCall)
       {
           ObjectCache cache = (ObjectCache) cachesByClass.get(objectClass.getName());
  -        if (cache == null && AbstractMetaCache.METHOD_CACHE == methodCall)
  +        if (cache == null && AbstractMetaCache.METHOD_CACHE == methodCall
  +                && !cachesByClass.containsKey(objectClass.getName()))
           {
  -			cache = new ObjectCacheDefaultImpl(null, null);
  -			setClassCache(objectClass.getName(), cache);
  +            cache = new ObjectCacheDefaultImpl(null, null);
  +            setClassCache(objectClass.getName(), cache);
           }
           return cache;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message