Package org.apache.openjpa.datacache
Class DataCacheManagerImpl
- java.lang.Object
-
- org.apache.openjpa.datacache.DataCacheManagerImpl
-
- All Implemented Interfaces:
DataCacheManager
,Closeable
public class DataCacheManagerImpl extends java.lang.Object implements Closeable, DataCacheManager
Default data cache manager provides handle to utilities PCDataGenerator, ClearableScheduler and CacheDistributionPolicy for the cache operation. This implementation also determines whether a managed type is eligible to cache.- Author:
- Abe White, Patrick Linskey, Pinaki Poddar
-
-
Constructor Summary
Constructors Constructor Description DataCacheManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close all caches.ClearableScheduler
getClearableScheduler()
Return the runnable which schedules evictions.DataCache
getDataCache(java.lang.String name)
Return the named data cache, or null if it does not exist.DataCache
getDataCache(java.lang.String name, boolean create)
Returns the named cache.CacheDistributionPolicy
getDistributionPolicy()
Gets the instance-based cache distribution policy, if configured.DataCachePCDataGenerator
getPCDataGenerator()
Return the PCData generator if configured.DataCache
getSystemDataCache()
Return the system-wide data cache, or null if caching is not enabled.QueryCache
getSystemQueryCache()
Return the system query cache, or null if not configured.void
initialize(OpenJPAConfiguration conf, ObjectValue dataCache, ObjectValue queryCache)
Initialize the manager, supplying the cache configuration.boolean
isCachable(ClassMetaData meta)
Affirms if the given type is eligible for cache.java.util.Map<java.lang.String,java.lang.Boolean>
listKnownTypes()
Returns the names of classes that are known to the cache and whether or not they are currently being cached.DataCache
selectCache(OpenJPAStateManager sm)
Select cache for the given managed instance.void
setTypes(java.util.Set<java.lang.String> includedTypes, java.util.Set<java.lang.String> excludedTypes)
void
startCaching(java.lang.String cls)
Start caching the type matching the provided class name.void
stopCaching(java.lang.String cls)
Stop caching the type matching the provided class name.
-
-
-
Method Detail
-
initialize
public void initialize(OpenJPAConfiguration conf, ObjectValue dataCache, ObjectValue queryCache)
Description copied from interface:DataCacheManager
Initialize the manager, supplying the cache configuration.- Specified by:
initialize
in interfaceDataCacheManager
-
getSystemDataCache
public DataCache getSystemDataCache()
Description copied from interface:DataCacheManager
Return the system-wide data cache, or null if caching is not enabled.- Specified by:
getSystemDataCache
in interfaceDataCacheManager
-
getDataCache
public DataCache getDataCache(java.lang.String name)
Description copied from interface:DataCacheManager
Return the named data cache, or null if it does not exist.- Specified by:
getDataCache
in interfaceDataCacheManager
-
getDataCache
public DataCache getDataCache(java.lang.String name, boolean create)
Returns the named cache. If the given name is name or the name of the cache plugin then returns the main cache. Otherwise, delegates to the main cache to obtain a partition.- Specified by:
getDataCache
in interfaceDataCacheManager
create
- if true, the cache will be created if it does not already exist
-
getSystemQueryCache
public QueryCache getSystemQueryCache()
Description copied from interface:DataCacheManager
Return the system query cache, or null if not configured.- Specified by:
getSystemQueryCache
in interfaceDataCacheManager
-
getPCDataGenerator
public DataCachePCDataGenerator getPCDataGenerator()
Description copied from interface:DataCacheManager
Return the PCData generator if configured.- Specified by:
getPCDataGenerator
in interfaceDataCacheManager
-
getClearableScheduler
public ClearableScheduler getClearableScheduler()
Description copied from interface:DataCacheManager
Return the runnable which schedules evictions.- Specified by:
getClearableScheduler
in interfaceDataCacheManager
-
close
public void close()
Description copied from interface:DataCacheManager
Close all caches.- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceDataCacheManager
-
selectCache
public DataCache selectCache(OpenJPAStateManager sm)
Select cache for the given managed instance. If type based verification affirms the type to be cached then the instance based policy is called to determine the target cache.- Specified by:
selectCache
in interfaceDataCacheManager
- Parameters:
sm
- the managed proxy instance- Returns:
- the cache that will store the state of the given managed instance.
-
getDistributionPolicy
public CacheDistributionPolicy getDistributionPolicy()
Gets the instance-based cache distribution policy, if configured.- Specified by:
getDistributionPolicy
in interfaceDataCacheManager
-
isCachable
public boolean isCachable(ClassMetaData meta)
Affirms if the given type is eligible for cache.
-
setTypes
public void setTypes(java.util.Set<java.lang.String> includedTypes, java.util.Set<java.lang.String> excludedTypes)
-
startCaching
public void startCaching(java.lang.String cls)
Description copied from interface:DataCacheManager
Start caching the type matching the provided class name.- Specified by:
startCaching
in interfaceDataCacheManager
-
stopCaching
public void stopCaching(java.lang.String cls)
Description copied from interface:DataCacheManager
Stop caching the type matching the provided class name.- Specified by:
stopCaching
in interfaceDataCacheManager
-
listKnownTypes
public java.util.Map<java.lang.String,java.lang.Boolean> listKnownTypes()
Description copied from interface:DataCacheManager
Returns the names of classes that are known to the cache and whether or not they are currently being cached.- Specified by:
listKnownTypes
in interfaceDataCacheManager
-
-