Package org.apache.openjpa.datacache
Class TypeBasedCacheDistributionPolicy
- java.lang.Object
-
- org.apache.openjpa.datacache.DefaultCacheDistributionPolicy
-
- org.apache.openjpa.datacache.TypeBasedCacheDistributionPolicy
-
- All Implemented Interfaces:
CacheDistributionPolicy,Configurable
public class TypeBasedCacheDistributionPolicy extends DefaultCacheDistributionPolicy implements CacheDistributionPolicy
A cache distribution policy based on the type of the managed objects.
The policy is configured by specifying list of included or excluded types. The lists are specified as fully-qualified persistence class names separated by semicolon.
The policy checks for the given instance by its type whether the class name appears in exclusion or inclusion lists. If the class name appears in exclusion list then the instance is not cached. Otherwise, if an inclusion list exists and the class name appears in inclusion list or @DataCache annotation is specified on the class meta data, then the instance is cached.- Author:
- Pinaki Poddar
-
-
Constructor Summary
Constructors Constructor Description TypeBasedCacheDistributionPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>getExcludedTypes()Gets the excluded types, if configured.Set<String>getIncludedTypes()Gets the included types, if configured.StringselectCache(OpenJPAStateManager sm, Object context)Selects the name of the cache where the given managed proxy object state be cached.voidsetExcludedTypes(String types)Sets excluded types from a semicolon separated list of type names.voidsetIncludedTypes(String types)Sets included types from a semicolon separated list of type names.-
Methods inherited from class org.apache.openjpa.datacache.DefaultCacheDistributionPolicy
endConfiguration, setConfiguration, startConfiguration
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.openjpa.lib.conf.Configurable
endConfiguration, setConfiguration, startConfiguration
-
-
-
-
Method Detail
-
setExcludedTypes
public void setExcludedTypes(String types)
Sets excluded types from a semicolon separated list of type names.
-
setIncludedTypes
public void setIncludedTypes(String types)
Sets included types from a semicolon separated list of type names.
-
selectCache
public String selectCache(OpenJPAStateManager sm, Object context)
Description copied from interface:CacheDistributionPolicySelects the name of the cache where the given managed proxy object state be cached.- Specified by:
selectCachein interfaceCacheDistributionPolicy- Overrides:
selectCachein classDefaultCacheDistributionPolicy- Parameters:
sm- the managed proxy object to be cached. The actual managed instance can be accessed from the proxy instance simply assm.getManagedInstance().context- the context of invocation. No specific semantics is attributed currently. Can be null.- Returns:
- name of the cache or null, implying that that the instance should not be cached.
-
-