org.jboss.seam.cache
Class CacheProvider<T>

java.lang.Object
  extended by org.jboss.seam.cache.CacheProvider<T>
Direct Known Subclasses:
AbstractJBossCacheProvider, EhCacheProvider

public abstract class CacheProvider<T>
extends Object

CacheProvider provides methods to control and manipulate the configured cache

Author:
Sebastian Hennebrueder, Pete Muir

Field Summary
static String DEFAULT_REGION
          the region name to be used if no region is specified
 
Constructor Summary
CacheProvider()
           
 
Method Summary
abstract  void clear()
          Removes all objects from all cache regions
 Object get(String key)
          Fetches an object for the given key from the cache and returns it if found.
<E> E
get(String key, E type)
          Fetches an object for the given key from the cache and returns it if found.
abstract  Object get(String region, String key)
          Fetches an object for the given key from the cache and returns it if found.
<E> E
get(String region, String key, E type)
          Fetches an object for the given key from the cache and returns it if found.
 String getConfiguration()
          Get the configuration file used by the cache
protected  InputStream getConfigurationAsStream()
           
 String getDefaultRegion()
           
abstract  T getDelegate()
           
static CacheProvider instance()
           
static
<T> CacheProvider<T>
instance(Class<? extends T> type)
           
 void put(String key, Object object)
          Put an object into the cache.
abstract  void put(String region, String key, Object object)
          Puts an object into the cache.
 void remove(String key)
          Removes an object from the cache.
abstract  void remove(String region, String key)
          Removes an object from the cache.
 void setConfiguration(String cfgResourceName)
          Set the configuration file to be used by the cache
 void setDefaultRegion(String defaultRegion)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REGION

public static final String DEFAULT_REGION
the region name to be used if no region is specified

See Also:
Constant Field Values
Constructor Detail

CacheProvider

public CacheProvider()
Method Detail

getDelegate

public abstract T getDelegate()
Returns:
- the cache the cache provider delegates to

getConfiguration

public String getConfiguration()
Get the configuration file used by the cache


getConfigurationAsStream

protected InputStream getConfigurationAsStream()

setConfiguration

public void setConfiguration(String cfgResourceName)
Set the configuration file to be used by the cache


get

public Object get(String key)
Fetches an object for the given key from the cache and returns it if found. Only the default cache region will be searched.

Parameters:
key - - a key to identify the object.
Returns:
- the object if found or null if not

get

public <E> E get(String key,
                 E type)
Fetches an object for the given key from the cache and returns it if found. Only the default cache region will be searched.

Parameters:
key - - a key to identify the object.
type - - the type of the object to return
Returns:
- the object if found or null if not

get

public abstract Object get(String region,
                           String key)
Fetches an object for the given key from the cache and returns it if found. Only the specified cache region will be searched.

Parameters:
region - - the name of a cache region
key - - a key to identify the object.
Returns:
- the object if found or null if not

get

public <E> E get(String region,
                 String key,
                 E type)
Fetches an object for the given key from the cache and returns it if found. Only the specified cache region will be searched.

Parameters:
region - - the name of a cache region
key - - a key to identify the object.
type - - the type of object to return
Returns:
- the object if found or null if not

put

public void put(String key,
                Object object)
Put an object into the cache. The object is placed in the default cache region under the given key.

Parameters:
key - - a key to identify the object
object - - the object to be stored in the cache

put

public abstract void put(String region,
                         String key,
                         Object object)
Puts an object into the cache. The object is placed in the specified cache region under the given key.

Parameters:
region - - the name of a cache region
key - - a key to identify the object
object - - the object to be stored in the cache

remove

public void remove(String key)
Removes an object from the cache. The object is removed from the default cache region under the given key.

Parameters:
key - - a key to identify the object

remove

public abstract void remove(String region,
                            String key)
Removes an object from the cache. The object is removed from the specified cache region under the given key.

Parameters:
region - - the name of a cache region
key - - a key to identify the object

clear

public abstract void clear()
Removes all objects from all cache regions


getDefaultRegion

public String getDefaultRegion()

setDefaultRegion

public void setDefaultRegion(String defaultRegion)

instance

public static CacheProvider instance()

instance

public static <T> CacheProvider<T> instance(Class<? extends T> type)