org.apache.openjpa.datacache
Class TypeBasedCacheDistributionPolicy

java.lang.Object
  extended by org.apache.openjpa.datacache.DefaultCacheDistributionPolicy
      extended by 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
TypeBasedCacheDistributionPolicy()
           
 
Method Summary
 Set<String> getExcludedTypes()
          Gets the excluded types, if configured.
 Set<String> getIncludedTypes()
          Gets the included types, if configured.
 String selectCache(OpenJPAStateManager sm, Object context)
          Selects the name of the cache where the given managed proxy object state be cached.
 void setExcludedTypes(String types)
          Sets excluded types from a semicolon separated list of type names.
 void setIncludedTypes(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
 

Constructor Detail

TypeBasedCacheDistributionPolicy

public TypeBasedCacheDistributionPolicy()
Method Detail

getExcludedTypes

public Set<String> getExcludedTypes()
Gets the excluded types, if configured.


setExcludedTypes

public void setExcludedTypes(String types)
Sets excluded types from a semicolon separated list of type names.


getIncludedTypes

public Set<String> getIncludedTypes()
Gets the included types, if configured.


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: CacheDistributionPolicy
Selects the name of the cache where the given managed proxy object state be cached.

Specified by:
selectCache in interface CacheDistributionPolicy
Overrides:
selectCache in class DefaultCacheDistributionPolicy
Parameters:
sm - the managed proxy object to be cached. The actual managed instance can be accessed from the proxy instance simply as sm.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.


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.