org.jboss.cache
Interface CacheManager

All Known Implementing Classes:
CacheManagerImpl

public interface CacheManager

Factory and registry for JBoss Cache instances configured using named configurations.

Version:
$Revision: 7168 $
Author:
Brian Stansberry

Method Summary
 Cache<Object,Object> getCache(String configName, boolean create)
          Get a cache configured according to the given configuration name, optionally instantiating the cache if it hasn't already been instantiated.
 Set<String> getCacheNames()
          Gets the name of all caches that are registered, i.e.
 org.jgroups.ChannelFactory getChannelFactory()
          Gets the JGroups ChannelFactory that will be injected into any Configuration that has a multiplexer stack configured.
 Set<String> getConfigurationNames()
          Gets the names of all the configurations of which this object is aware.
 void releaseCache(String configName)
          Notifies the registry that the caller is no longer using the given cache.
 

Method Detail

getConfigurationNames

Set<String> getConfigurationNames()
Gets the names of all the configurations of which this object is aware.

Returns:
a set of names. Will not be null.

getCacheNames

Set<String> getCacheNames()
Gets the name of all caches that are registered, i.e. that can be by a call to getCache(name, false).

Returns:
a set of names. Will not be null.

getChannelFactory

org.jgroups.ChannelFactory getChannelFactory()
Gets the JGroups ChannelFactory that will be injected into any Configuration that has a multiplexer stack configured.

Returns:
a channel factory

getCache

Cache<Object,Object> getCache(String configName,
                              boolean create)
                              throws Exception
Get a cache configured according to the given configuration name, optionally instantiating the cache if it hasn't already been instantiated.

The caller is free to invoke the Cache.create() and Cache.start() lifecycle methods on the returned cache, but the @link Cache#stop()} and Cache.destroy() methods should not be invoked, since it is quite possible other users are still using the cache. Use releaseCache(String) to notify this registry that the caller is no longer using a cache; let the registry control stopping and destroying the cache.

If invoking this method leads to the instantiation of the cache, create() and start() will not be invoked on the cache before it is returned.

Parameters:
configName - the name of the configuration
create - should the cache be instantiated if it hasn't already been?
Returns:
the cache, or null if create is false and the cache hasn't been created previously.
Throws:
IllegalArgumentException - if this object is unaware of configName; i.e. the set returned from getConfigurationNames() does not include configName
Exception - if there is a problem instantiating the cache

releaseCache

void releaseCache(String configName)
Notifies the registry that the caller is no longer using the given cache. The registry may perform cleanup operations, such as stopping and destroying the cache.

Parameters:
configName -


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.