Package 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 asjakarta.persistence.sharedCache.mode
determined the type of the instance being cachable.
For example, a specific policy will never be active for whenjakarta.persistence.sharedCache.mode
is set toNONE
.
Distribution Policies are configurable. So a specific policy can be configured as<property name="openjpa.CacheDistributionPolicy" value="com.acme.FooPolicy(param1='xyz',param2=true)"/>
wherecom.acme.FooPolicy
is an implementation of this interface and defines bean style setter and getter methods for String propertyparam1
and boolean propertyparam2
.- Since:
- 2.0.0
- Author:
- Pinaki Poddar
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
selectCache(OpenJPAStateManager sm, java.lang.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
java.lang.String selectCache(OpenJPAStateManager sm, java.lang.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 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.
-
-