Package org.apache.openjpa.datacache
Class DataCacheManagerImpl
- java.lang.Object
-
- org.apache.openjpa.datacache.DataCacheManagerImpl
-
- All Implemented Interfaces:
DataCacheManager,Closeable
public class DataCacheManagerImpl extends 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 voidclose()Close all caches.ClearableSchedulergetClearableScheduler()Return the runnable which schedules evictions.DataCachegetDataCache(String name)Return the named data cache, or null if it does not exist.DataCachegetDataCache(String name, boolean create)Returns the named cache.CacheDistributionPolicygetDistributionPolicy()Gets the instance-based cache distribution policy, if configured.DataCachePCDataGeneratorgetPCDataGenerator()Return the PCData generator if configured.DataCachegetSystemDataCache()Return the system-wide data cache, or null if caching is not enabled.QueryCachegetSystemQueryCache()Return the system query cache, or null if not configured.voidinitialize(OpenJPAConfiguration conf, ObjectValue dataCache, ObjectValue queryCache)Initialize the manager, supplying the cache configuration.booleanisCachable(ClassMetaData meta)Affirms if the given type is eligible for cache.Map<String,Boolean>listKnownTypes()Returns the names of classes that are known to the cache and whether or not they are currently being cached.DataCacheselectCache(OpenJPAStateManager sm)Select cache for the given managed instance.voidsetTypes(Set<String> includedTypes, Set<String> excludedTypes)voidstartCaching(String cls)Start caching the type matching the provided class name.voidstopCaching(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:DataCacheManagerInitialize the manager, supplying the cache configuration.- Specified by:
initializein interfaceDataCacheManager
-
getSystemDataCache
public DataCache getSystemDataCache()
Description copied from interface:DataCacheManagerReturn the system-wide data cache, or null if caching is not enabled.- Specified by:
getSystemDataCachein interfaceDataCacheManager
-
getDataCache
public DataCache getDataCache(String name)
Description copied from interface:DataCacheManagerReturn the named data cache, or null if it does not exist.- Specified by:
getDataCachein interfaceDataCacheManager
-
getDataCache
public DataCache getDataCache(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:
getDataCachein interfaceDataCacheManagercreate- if true, the cache will be created if it does not already exist
-
getSystemQueryCache
public QueryCache getSystemQueryCache()
Description copied from interface:DataCacheManagerReturn the system query cache, or null if not configured.- Specified by:
getSystemQueryCachein interfaceDataCacheManager
-
getPCDataGenerator
public DataCachePCDataGenerator getPCDataGenerator()
Description copied from interface:DataCacheManagerReturn the PCData generator if configured.- Specified by:
getPCDataGeneratorin interfaceDataCacheManager
-
getClearableScheduler
public ClearableScheduler getClearableScheduler()
Description copied from interface:DataCacheManagerReturn the runnable which schedules evictions.- Specified by:
getClearableSchedulerin interfaceDataCacheManager
-
close
public void close()
Description copied from interface:DataCacheManagerClose all caches.- Specified by:
closein interfaceCloseable- Specified by:
closein 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:
selectCachein 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:
getDistributionPolicyin interfaceDataCacheManager
-
isCachable
public boolean isCachable(ClassMetaData meta)
Affirms if the given type is eligible for cache.
-
startCaching
public void startCaching(String cls)
Description copied from interface:DataCacheManagerStart caching the type matching the provided class name.- Specified by:
startCachingin interfaceDataCacheManager
-
stopCaching
public void stopCaching(String cls)
Description copied from interface:DataCacheManagerStop caching the type matching the provided class name.- Specified by:
stopCachingin interfaceDataCacheManager
-
listKnownTypes
public Map<String,Boolean> listKnownTypes()
Description copied from interface:DataCacheManagerReturns the names of classes that are known to the cache and whether or not they are currently being cached.- Specified by:
listKnownTypesin interfaceDataCacheManager
-
-