Package org.wso2.carbon.caching.impl
Class CarbonCacheManager
- java.lang.Object
-
- org.wso2.carbon.caching.impl.CarbonCacheManager
-
- All Implemented Interfaces:
CacheManager
public class CarbonCacheManager extends Object implements CacheManager
TODO: class description
-
-
Constructor Summary
Constructors Constructor Description CarbonCacheManager(String name, CacheManagerFactoryImpl cacheManagerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <K,V>
CacheBuilder<K,V>createCacheBuilder(String cacheName)Creates a newCacheBuilderfor the named cache to be managed by this cache manager.booleanequals(Object o)<K,V>
Cache<K,V>getCache(String cacheName)Looks up a named cache.Iterable<Cache<?,?>>getCaches()Returns an Iterable over the caches managed by this CacheManager.StringgetName()Get the name of this cache managerintgetOwnerTenantId()StatusgetStatus()Returns the status of this CacheManager.UserTransactiongetUserTransaction()This method will return a UserTransaction.inthashCode()booleanisSupported(OptionalFeature optionalFeature)Indicates whether a optional feature is supported by this CacheManager.booleanremoveCache(String cacheName)Remove a cache from the CacheManager.voidshutdown()Shuts down the CacheManager.<T> Tunwrap(Class<T> cls)Return an object of the specified type to allow access to the provider-specific API.
-
-
-
Constructor Detail
-
CarbonCacheManager
public CarbonCacheManager(String name, CacheManagerFactoryImpl cacheManagerFactory)
-
-
Method Detail
-
getOwnerTenantId
public int getOwnerTenantId()
-
getName
public String getName()
Description copied from interface:CacheManagerGet the name of this cache manager- Specified by:
getNamein interfaceCacheManager- Returns:
- the name of this cache manager
-
getStatus
public Status getStatus()
Description copied from interface:CacheManagerReturns the status of this CacheManager. Calls to this method will block while the state is changing.- Specified by:
getStatusin interfaceCacheManager- Returns:
- one of
Status
-
createCacheBuilder
public <K,V> CacheBuilder<K,V> createCacheBuilder(String cacheName)
Description copied from interface:CacheManagerCreates a newCacheBuilderfor the named cache to be managed by this cache manager. An example which creates a cache using default cache configuration is:Cache<Integer, Date> myCache2 = cacheManager. <Integer, Date>createCacheBuilder("myCache2"). build();An example usage which programmatically sets many parameters ofCacheConfiguration, specifies aCacheLoaderand registrs listeners is:Cache<Integer, String> myCache1 = cacheManager. <Integer, String>createCacheBuilder("myCache1"). setCacheLoader(cl). setStoreByValue(true). setReadThrough(true). setWriteThrough(false). setStatisticsEnabled(true). setTransactionEnabled(false). registerCacheEntryListener(listener1, NotificationScope.LOCAL, false). registerCacheEntryListener(listener2, NotificationScope.LOCAL, false). build();The returned CacheBuilder is associated with this CacheManager. The Cache will be created, added to the caches controlled by this CacheManager and started whenCacheBuilder.build()is called. If there is an existing Cache of the same name associated with this CacheManager when build is invoked, an exception is thrown.- Specified by:
createCacheBuilderin interfaceCacheManager- Parameters:
cacheName- the name of the cache to build. A cache name must consist of at least one non-whitespace character.- Returns:
- the CacheBuilder for the named cache
-
getCache
public <K,V> Cache<K,V> getCache(String cacheName)
Description copied from interface:CacheManagerLooks up a named cache.- Specified by:
getCachein interfaceCacheManager- Parameters:
cacheName- the name of the cache to look for- Returns:
- the Cache or null if it does exist
-
getCaches
public Iterable<Cache<?,?>> getCaches()
Description copied from interface:CacheManagerReturns an Iterable over the caches managed by this CacheManager. The Iterable is immutable (iterator.remove will throw an IllegalStateException) and independent of the cache manager; if the caches managed by the cache manager change the Iterable is not affected- Specified by:
getCachesin interfaceCacheManager- Returns:
- an Iterable over the managed Caches
-
removeCache
public boolean removeCache(String cacheName)
Description copied from interface:CacheManagerRemove a cache from the CacheManager. The cache will be stopped.- Specified by:
removeCachein interfaceCacheManager- Parameters:
cacheName- the cache name- Returns:
- true if the cache was removed
-
getUserTransaction
public UserTransaction getUserTransaction()
Description copied from interface:CacheManagerThis method will return a UserTransaction.- Specified by:
getUserTransactionin interfaceCacheManager- Returns:
- the UserTransaction.
-
isSupported
public boolean isSupported(OptionalFeature optionalFeature)
Description copied from interface:CacheManagerIndicates whether a optional feature is supported by this CacheManager.- Specified by:
isSupportedin interfaceCacheManager- Parameters:
optionalFeature- the feature to check for- Returns:
- true if the feature is supported
-
shutdown
public void shutdown()
Description copied from interface:CacheManagerShuts down the CacheManager. For each cache in the cache manager theCacheLifecycle.stop()method will be invoked, in no guaranteed order. If the stop throws an exception, the exception is ignored. Calls toCacheManager.getStatus()will block until shutdown completes. On completion the CacheManager's status is changed toStatus.STOPPED, and the manager's owned caches will be empty andCacheManager.getCaches()will return an empty collection. A given CacheManager instance cannot be restarted after it has been stopped. A new one must be created.- Specified by:
shutdownin interfaceCacheManager
-
unwrap
public <T> T unwrap(Class<T> cls)
Description copied from interface:CacheManagerReturn an object of the specified type to allow access to the provider-specific API. If the provider's implementation does not support the specified class, theIllegalArgumentExceptionis thrown.- Specified by:
unwrapin interfaceCacheManager- Parameters:
cls- the class of the object to be returned. This is normally either the underlying implementation class or an interface that it implements.- Returns:
- an instance of the specified class
-
-