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,19 +160,16 @@ public class DataCacheManagerImpl
* @return TRUE or FALSE if cache mode is configured. null otherwise. * @return TRUE or FALSE if cache mode is configured. null otherwise.
*/ */
private Boolean isCacheableByMode(ClassMetaData meta) { private Boolean isCacheableByMode(ClassMetaData meta) {
switch (DataCacheMode.valueOf(_conf.getDataCacheMode())) { String mode = _conf.getDataCacheMode();
case ALL: // include everything, regardless of annotation or xml configuration if (DataCacheMode.ALL.toString().equalsIgnoreCase(mode))
return true; return true;
case NONE: // exclude everything, regardless of annotation of xml configuration if (DataCacheMode.NONE.toString().equalsIgnoreCase(mode))
return false; 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()); 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()); return !Boolean.FALSE.equals(meta.getCacheEnabled());
case UNSPECIFIED: return null;
default: // not determinable by mode
return null;
}
} }
/** /**