org.apache.openjpa.datacache
Interface CacheDistributionPolicy

All Superinterfaces:
Configurable
All Known Implementing Classes:
DefaultCacheDistributionPolicy, TypeBasedCacheDistributionPolicy

public interface CacheDistributionPolicy
extends Configurable

A policy determines whether a given entity should be cached and if true, in which named partition of the cache.
This policy is activated for each instance if and only if the cache settings specified in metadata such as JPA specification defined @Cacheable annotation or OpenJPA specific @DataCache annotation or configuration property such as javax.persistence.sharedCache.mode determined the type of the instance being cachable.
For example, a specific policy will never be active for when javax.persistence.sharedCache.mode is set to NONE.
Distribution Policies are configurable. So a specific policy can be configured as

  <property name="openjpa.CacheDistributionPolicy" value="com.acme.FooPolicy(param1='xyz',param2=true)"/>
 
where com.acme.FooPolicy is an implementation of this interface and defines bean style setter and getter methods for String property param1 and boolean property param2.

Since:
2.0.0
Author:
Pinaki Poddar

Method Summary
 String selectCache(OpenJPAStateManager sm, Object context)
          Selects the name of the cache where the given managed proxy object state be cached.
 
Methods inherited from interface org.apache.openjpa.lib.conf.Configurable
endConfiguration, setConfiguration, startConfiguration
 

Method Detail

selectCache

String selectCache(OpenJPAStateManager sm,
                   Object context)
Selects the name of the cache where the given managed proxy object state be cached.

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-2012 Apache Software Foundation. All Rights Reserved.