org.apache.openjpa.datacache
Class DataCacheManagerImpl

java.lang.Object
  extended by 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
DataCacheManagerImpl()
           
 
Method Summary
 void close()
          Close all caches.
 ClearableScheduler getClearableScheduler()
          Return the runnable which schedules evictions.
 DataCache getDataCache(String name)
          Return the named data cache, or null if it does not exist.
 DataCache getDataCache(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.
 DataCache selectCache(OpenJPAStateManager sm)
          Select cache for the given managed instance.
 void setTypes(Set<String> includedTypes, Set<String> excludedTypes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataCacheManagerImpl

public DataCacheManagerImpl()
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 interface DataCacheManager

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 interface DataCacheManager

getDataCache

public DataCache getDataCache(String name)
Description copied from interface: DataCacheManager
Return the named data cache, or null if it does not exist.

Specified by:
getDataCache in interface DataCacheManager

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:
getDataCache in interface DataCacheManager
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 interface DataCacheManager

getPCDataGenerator

public DataCachePCDataGenerator getPCDataGenerator()
Description copied from interface: DataCacheManager
Return the PCData generator if configured.

Specified by:
getPCDataGenerator in interface DataCacheManager

getClearableScheduler

public ClearableScheduler getClearableScheduler()
Description copied from interface: DataCacheManager
Return the runnable which schedules evictions.

Specified by:
getClearableScheduler in interface DataCacheManager

close

public void close()
Description copied from interface: DataCacheManager
Close all caches.

Specified by:
close in interface DataCacheManager
Specified by:
close in interface Closeable

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 interface DataCacheManager
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 interface DataCacheManager

isCachable

public boolean isCachable(ClassMetaData meta)
Affirms if the given type is eligible for cache.


setTypes

public void setTypes(Set<String> includedTypes,
                     Set<String> excludedTypes)


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