org.jboss.cache
Interface CacheFactory<K,V>

All Known Implementing Classes:
DefaultCacheFactory

@ThreadSafe
public interface CacheFactory<K,V>

This factory constructs a cache from a given or default configuration set.

Typical usage would be:

   CacheFactory factory = DefaultCacheFactory.getInstance();
   Cache cache = factory.createCache("replSync-service.xml"); // expects this file to be in classpath
   cache.stop();
 
Factory methods provide options for creating a cache using In addition, methods provide anadditional option to create and return a cache without starting it.

Since:
2.0.0
Author:
Manik Surtani (manik@jboss.org)
See Also:
Cache, DefaultCacheFactory

Method Summary
 Cache<K,V> createCache()
          Creates and starts a Cache instance using default configuration settings.
 Cache<K,V> createCache(boolean start)
          Creates and optionally starts a Cache instance using default configuration settings.
 Cache<K,V> createCache(Configuration configuration)
          Creates a Cache instance based on a Configuration passed in.
 Cache<K,V> createCache(Configuration configuration, boolean start)
          Creates Cache instance, and optionally starts it, based on a Configuration passed in.
 Cache<K,V> createCache(InputStream is)
          Creates a Cache instance based on an InputStream passed in, which should be a stream to a valid XML configuration file.
 Cache<K,V> createCache(InputStream is, boolean start)
          Creates a Cache instance based on an InputStream passed in, which should be a stream to a valid XML configuration file.
 Cache<K,V> createCache(String configFileName)
          Creates and starts a Cache instance.
 Cache<K,V> createCache(String configFileName, boolean start)
          Creates Cache instance, and optionally starts it.
 

Method Detail

createCache

Cache<K,V> createCache()
                       throws ConfigurationException
Creates and starts a Cache instance using default configuration settings. See Configuration for default values.

Returns:
a cache
Throws:
ConfigurationException - if there are problems with the default configuration

createCache

Cache<K,V> createCache(boolean start)
                       throws ConfigurationException
Creates and optionally starts a Cache instance using default configuration settings. See Configuration for default values.

Parameters:
start - if true, starts the cache
Returns:
a cache
Throws:
ConfigurationException - if there are problems with the default configuration

createCache

Cache<K,V> createCache(String configFileName)
                       throws ConfigurationException
Creates and starts a Cache instance. The following are all valid calls:
    factory.createCache("myCacheService.xml"); // file is in class path
    factory.createCache("etc/myCacheService.xml"); // file is in etc/ relative to the directory you started the JVM
    factory.createCache("/home/jbosscache/myCacheService.xml"); // file is in the /home/jbosscache directory
 

Parameters:
configFileName - the named XML file should exist in the classpath or should be a fully qualified or relative (to your JVM working directory) path to a file on the local file system. Note that the classpath is checked first for the existence of this file.
Returns:
a running Cache instance
Throws:
ConfigurationException - if there are problems with the configuration

createCache

Cache<K,V> createCache(String configFileName,
                       boolean start)
                       throws ConfigurationException
Creates Cache instance, and optionally starts it.

Parameters:
configFileName - the named XML file should exist in the classpath or should be a fully qualified or relative (to your JVM working directory) path to a file on the local file system. Note that the classpath is checked first for the existence of this file.
start - if true, the cache is started before returning.
Returns:
an optionally running Cache instance
Throws:
ConfigurationException - if there are problems with the configuration
See Also:
for examples on valid config file names.

createCache

Cache<K,V> createCache(Configuration configuration)
                       throws ConfigurationException
Creates a Cache instance based on a Configuration passed in.

Ensure that the Configuration you pass in is not used by another cache instance in the same JVM, as it may be concurrently modified. Clone the configuration, if shared, using Configuration.clone().

Parameters:
configuration - the Configuration object that is passed in to setCache the Cache.
Returns:
a running Cache instance
Throws:
ConfigurationException - if there are problems with the configuration

createCache

Cache<K,V> createCache(Configuration configuration,
                       boolean start)
                       throws ConfigurationException
Creates Cache instance, and optionally starts it, based on a Configuration passed in.

Ensure that the Configuration you pass in is not used by another cache instance in the same JVM, as it may be concurrently modified. Clone the configuration, if shared, using Configuration.clone().

Parameters:
configuration - the Configuration object that is passed in to setCache the Cache.
start - if true, the cache is started before returning.
Returns:
an optionally running Cache instance
Throws:
ConfigurationException - if there are problems with the configuration

createCache

Cache<K,V> createCache(InputStream is)
                       throws ConfigurationException
Creates a Cache instance based on an InputStream passed in, which should be a stream to a valid XML configuration file.

Parameters:
is - the InputStream
Returns:
a running Cache instance
Throws:
ConfigurationException - if there are problems with the configuration
Since:
2.1.0

createCache

Cache<K,V> createCache(InputStream is,
                       boolean start)
                       throws ConfigurationException
Creates a Cache instance based on an InputStream passed in, which should be a stream to a valid XML configuration file.

Parameters:
is - the InputStream
start - if true, the cache is started before returning.
Returns:
a running Cache instance
Throws:
ConfigurationException - if there are problems with the configuration
Since:
2.1.0


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