Author: curtisr7
Date: Thu Feb 25 18:32:35 2010
New Revision: 916388

URL: http://svn.apache.org/viewvc?rev=916388&view=rev
Log:
OPENJPA-1539: Allow DataCacheManagerImpl.isCachable(ClassMetaData meta) to 
cache the cacheability for each given type.

Modified:
    
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheManagerImpl.java

Modified: 
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheManagerImpl.java
URL: 
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheManagerImpl.java?rev=916388&r1=916387&r2=916388&view=diff
==============================================================================
--- 
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheManagerImpl.java
 (original)
+++ 
openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheManagerImpl.java
 Thu Feb 25 18:32:35 2010
@@ -18,23 +18,17 @@
  */
 package org.apache.openjpa.datacache;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.enhance.PCDataGenerator;
 import org.apache.openjpa.kernel.OpenJPAStateManager;
-import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.conf.ObjectValue;
 import org.apache.openjpa.lib.util.Closeable;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.util.ImplHelper;
 
-import serp.util.Strings;
-
 /**
  * Default data cache manager provides handle to utilities {...@linkplain 
PCDataGenerator}, {...@linkplain DataCacheScheduler}
  * and {...@linkplain CacheDistributionPolicy} for the cache operation. This 
implementation also determines whether a
@@ -53,7 +47,8 @@
     private DataCachePCDataGenerator _pcGenerator = null;
     private DataCacheScheduler _scheduler = null;
     private CacheDistributionPolicy _policy = new 
DefaultCacheDistributionPolicy();
-
+    private Map<ClassMetaData,Boolean> _cacheable = new HashMap<ClassMetaData, 
Boolean>();
+    
     public void initialize(OpenJPAConfiguration conf, ObjectValue dataCache, 
ObjectValue queryCache) {
         _conf = conf;
         _cache = (DataCache) dataCache.instantiate(DataCache.class, conf);
@@ -137,10 +132,16 @@
      * Affirms if the given type is eligible for cache.
      */
     public boolean isCachable(ClassMetaData meta) {
+        Boolean res = _cacheable.get(meta);
+        if(res != null){
+            return res;
+        }
+
         Boolean isCachable = isCacheableByMode(meta);
         if (isCachable == null) {
            isCachable = isCacheableByType(meta);
         }
+        _cacheable.put(meta, isCachable);
         return isCachable;
     }
     


Reply via email to