OPENJPA-1539: Allow DataCacheManagerImpl.isCachable(ClassMetaData meta) to cache the cacheability for each given type.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@916388 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Richard G. Curtis 2010-02-25 18:32:35 +00:00
parent 7b1ee0cbcc
commit 767f670490
1 changed files with 10 additions and 9 deletions

View File

@ -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,6 +47,7 @@ public class DataCacheManagerImpl
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;
@ -137,10 +132,16 @@ public class DataCacheManagerImpl
* 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;
}