|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface CacheManager
A CacheManager is used for looking up Caches and controls their lifecycle. It represents a collection of caches.
To the extent that implementations have configuration at the CacheManager level, it is a way for these caches to share common configuration. For example a CacheManager might be clustered so all caches in that CacheManager will participate in the same cluster.Caching
new
of a concrete implementation, if supported by an implementationCaching.getCacheManager()
. This is a
useful idiom if you only want to use one CacheManager.
Named CacheManagers can be obtained using Caching.getCacheManager(name)
.
Method Summary | ||
---|---|---|
|
createCacheBuilder(String cacheName)
Creates a new CacheBuilder for the named cache to be managed by this cache manager. |
|
|
getCache(String cacheName)
Looks up a named cache. |
|
Iterable<Cache<?,?>> |
getCaches()
Returns an iterable over the caches managed by this CacheManager. |
|
String |
getName()
Get the name of this cache manager |
|
Status |
getStatus()
Returns the status of this CacheManager. |
|
UserTransaction |
getUserTransaction()
This method will return a UserTransaction. |
|
boolean |
isSupported(OptionalFeature optionalFeature)
Indicates whether a optional feature is supported by this CacheManager. |
|
boolean |
removeCache(String cacheName)
Remove a cache from the CacheManager. |
|
void |
shutdown()
Shuts down the CacheManager. |
|
|
unwrap(Class<T> cls)
Return an object of the specified type to allow access to the provider-specific API. |
Method Detail |
---|
String getName()
Status getStatus()
Status
todo RI should block until transition completed and needs internal transitional states<K,V> CacheBuilder<K,V> createCacheBuilder(String cacheName)
CacheBuilder
for 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 of
CacheConfiguration
,
specifies a CacheLoader
and registrs listeners is:
Cache<Integer, String> myCache1 = cacheManager. <Integer, String>createCacheBuilder("myCache1"). setCacheLoader(cl). 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 when
CacheBuilder.build()
is called.
If there is an existing Cache of the same name associated with this CacheManager when build is invoked,
the old Cache will be stopped.
cacheName
- the name of the cache to build. A cache name must consist of at least one non-whitespace character.
IllegalStateException
- if the CacheManager is not in Status.STARTED
state.
CacheException
- if a cache with that name already exists or there was an error adding the cache to the CacheManager
IllegalArgumentException
- if an illegal cache name is specified
NullPointerException
- if the cache name is null<K,V> Cache<K,V> getCache(String cacheName)
cacheName
- the name of the cache to look for
IllegalStateException
- if the CacheManager is not Status.STARTED
Iterable<Cache<?,?>> getCaches()
UnsupportedOperationException
- if an attempt it made to remove an elementboolean removeCache(String cacheName)
cacheName
- the cache name
IllegalStateException
- if the cache is not Status.STARTED
NullPointerException
- if cacheName is nullUserTransaction getUserTransaction()
UnsupportedOperationException
- if JTA is not supportedboolean isSupported(OptionalFeature optionalFeature)
optionalFeature
- the feature to check for
void shutdown()
CacheLifecycle.stop()
method will be invoked, in no guaranteed order.
If the stop throws an exception, the exception will be consumed silently.
Calls to getStatus()
will block until shutdown completes.
During the execution of the method calls to getStatus()
will block.
On completion the CacheManager's status is changed to Status.STOPPED
, and the manager's owned caches will be empty &
getCaches()
will return an empty collection.
A given CacheManager instance cannot be restarted after it has been stopped. A new one must be created.
IllegalStateException
- if an operation is performed on CacheManager while stopping or stopped.<T> T unwrap(Class<T> cls)
IllegalArgumentException
is thrown.
cls
- the class of the object to be returned. This is normally either the underlying implementation class or an interface that it implements.
IllegalArgumentException
- if the provider doesn't support the specified class.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |