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.
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 -
Method Summary
Modifier and TypeMethodDescriptionGets the excluded types, if configured.Gets the included types, if configured.selectCache(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 DefaultCacheDistributionPolicy
endConfiguration, setConfiguration, startConfigurationMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Configurable
endConfiguration, setConfiguration, startConfiguration
-
Constructor Details
-
TypeBasedCacheDistributionPolicy
public TypeBasedCacheDistributionPolicy()
-
-
Method Details
-
getExcludedTypes
-
setExcludedTypes
Sets excluded types from a semicolon separated list of type names. -
getIncludedTypes
-
setIncludedTypes
Sets included types from a semicolon separated list of type names. -
selectCache
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.
-