reduce performance cost of isCacheable().

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@897308 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2010-01-08 19:40:10 +00:00
parent 3065f2febb
commit 5cef9cff17
1 changed files with 10 additions and 13 deletions

View File

@ -160,20 +160,17 @@ public class DataCacheManagerImpl
* @return TRUE or FALSE if cache mode is configured. null otherwise.
*/
private Boolean isCacheableByMode(ClassMetaData meta) {
switch (DataCacheMode.valueOf(_conf.getDataCacheMode())) {
case ALL: // include everything, regardless of annotation or xml configuration
String mode = _conf.getDataCacheMode();
if (DataCacheMode.ALL.toString().equalsIgnoreCase(mode))
return true;
case NONE: // exclude everything, regardless of annotation of xml configuration
if (DataCacheMode.NONE.toString().equalsIgnoreCase(mode))
return false;
case ENABLE_SELECTIVE: // cache only those entities which were explicitly enabled
if (DataCacheMode.ENABLE_SELECTIVE.toString().equalsIgnoreCase(mode))
return Boolean.TRUE.equals(meta.getCacheEnabled());
case DISABLE_SELECTIVE: // exclude *only* the entities which are explicitly excluded
if (DataCacheMode.DISABLE_SELECTIVE.toString().equalsIgnoreCase(mode))
return !Boolean.FALSE.equals(meta.getCacheEnabled());
case UNSPECIFIED:
default: // not determinable by mode
return null;
}
}
/**
* Is the given type cacheable by @DataCache annotation.