org.jboss.cache
Class CacheManagerImpl

java.lang.Object
  extended by org.jboss.cache.CacheManagerImpl
All Implemented Interfaces:
CacheManager

public class CacheManagerImpl
extends Object
implements CacheManager

Basic implementation of CacheManager.

Version:
$Revision: 1 $
Author:
Brian Stansberry

Constructor Summary
CacheManagerImpl()
          Create a new CacheRegistryImpl.
CacheManagerImpl(ConfigurationRegistry configRegistry, org.jgroups.ChannelFactory factory)
          Create a new CacheRegistryImpl using the provided ConfigurationRegistry and ChannelFactory.
CacheManagerImpl(String configFileName, org.jgroups.ChannelFactory factory)
          Create a new CacheRegistryImpl using the provided ChannelFactory and using the provided file name to create an XmlParsingConfigurationRegistry.
 
Method Summary
protected  Cache<Object,Object> createCache(Configuration config)
          Extension point for subclasses, where we actually use a CacheFactory to create a cache.
 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.
 ConfigurationRegistry getConfigurationRegistry()
           
 void registerCache(Cache<Object,Object> cache, String configName)
           
 void releaseCache(String configName)
          Notifies the registry that the caller is no longer using the given cache.
 void setChannelFactory(org.jgroups.ChannelFactory channelFactory)
           
 void setConfigurationRegistry(ConfigurationRegistry configRegistry)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheManagerImpl

public CacheManagerImpl()
Create a new CacheRegistryImpl.


CacheManagerImpl

public CacheManagerImpl(ConfigurationRegistry configRegistry,
                        org.jgroups.ChannelFactory factory)
Create a new CacheRegistryImpl using the provided ConfigurationRegistry and ChannelFactory.


CacheManagerImpl

public CacheManagerImpl(String configFileName,
                        org.jgroups.ChannelFactory factory)
Create a new CacheRegistryImpl using the provided ChannelFactory and using the provided file name to create an XmlParsingConfigurationRegistry.

Method Detail

getChannelFactory

public org.jgroups.ChannelFactory getChannelFactory()
Description copied from interface: CacheManager
Gets the JGroups ChannelFactory that will be injected into any Configuration that has a multiplexer stack configured.

Specified by:
getChannelFactory in interface CacheManager
Returns:

getConfigurationNames

public Set<String> getConfigurationNames()
Description copied from interface: CacheManager
Gets the names of all the configurations of which this object is aware.

Specified by:
getConfigurationNames in interface CacheManager
Returns:
a set of names. Will not be null.

getCacheNames

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

Specified by:
getCacheNames in interface CacheManager
Returns:
a set of names. Will not be null.

getCache

public Cache<Object,Object> getCache(String configName,
                                     boolean create)
                              throws Exception
Description copied from interface: CacheManager
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 CacheManager.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.

Specified by:
getCache in interface CacheManager
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 CacheManager.getConfigurationNames() does not include configName
Exception - if there is a problem instantiating the cache

createCache

protected Cache<Object,Object> createCache(Configuration config)
Extension point for subclasses, where we actually use a CacheFactory to create a cache. This default implementation uses DefaultCacheFactory.

Parameters:
config - the Configuration for the cache
Returns:
the Cache

releaseCache

public void releaseCache(String configName)
Description copied from interface: CacheManager
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.

Specified by:
releaseCache in interface CacheManager

getConfigurationRegistry

public ConfigurationRegistry getConfigurationRegistry()

setConfigurationRegistry

public void setConfigurationRegistry(ConfigurationRegistry configRegistry)

setChannelFactory

public void setChannelFactory(org.jgroups.ChannelFactory channelFactory)

registerCache

public void registerCache(Cache<Object,Object> cache,
                          String configName)

start

public void start()
           throws Exception
Throws:
Exception

stop

public void stop()


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