org.hibernate.cache.jbc.builder
Class SharedCacheInstanceManager

java.lang.Object
  extended by org.hibernate.cache.jbc.builder.SharedCacheInstanceManager
All Implemented Interfaces:
CacheInstanceManager
Direct Known Subclasses:
JndiSharedCacheInstanceManager

public class SharedCacheInstanceManager
extends Object
implements CacheInstanceManager

A CacheInstanceManager implementation where we use a single JBoss Cache instance for each type of region. If operating on a cluster, the cache must be configured for REPL_SYNC if query caching is enabled. If query caching is not used, REPL_SYNC or INVALIDATION_SYNC are valid, with INVALIDATION_SYNC preferred.

Author:
Steve Ebersole, Brian Stansberry

Field Summary
static String CACHE_RESOURCE_PROP
          Classpath or filesystem resource containing JBoss Cache configuration settings the Cache should use.
static String CHANNEL_FACTORY_RESOURCE_PROP
          Classpath or filesystem resource containing JGroups protocol stack configurations the org.jgroups.ChannelFactory should use.
static String DEF_JGROUPS_RESOURCE
          Default value for CHANNEL_FACTORY_RESOURCE_PROP.
static String DEFAULT_CACHE_RESOURCE
          Default name for the JBoss Cache configuration file.
static String LEGACY_CACHE_RESOURCE_PROP
          Legacy name for configuration property CACHE_RESOURCE_PROP.
static String LEGACY_CHANNEL_FACTORY_RESOURCE_PROP
          Legacy name for configuration property CHANNEL_FACTORY_RESOURCE_PROP.
 
Constructor Summary
SharedCacheInstanceManager()
           
SharedCacheInstanceManager(org.jboss.cache.Cache cache)
           
SharedCacheInstanceManager(org.jgroups.ChannelFactory channelFactory)
           
 
Method Summary
protected  void configureTransactionManager(org.jboss.cache.Cache cache, Settings settings, Properties properties)
          Injects the TransactionManager found via Settings.getTransactionManagerLookup() into the cache.
protected  org.jboss.cache.Cache createSharedCache(Settings settings, Properties properties)
          Create a cache using the given settings and properties.
 org.jboss.cache.Cache getCollectionCacheInstance()
          Retrieve a handle to the Cache instance to be used for storing collection data.
 org.jboss.cache.Cache getEntityCacheInstance()
          Retrieve a handle to the Cache instance to be used for storing entity data.
 org.jboss.cache.Cache getQueryCacheInstance()
          Retrieve a handle to the Cache instance to be used for storing query results.
 org.jboss.cache.Cache getTimestampsCacheInstance()
          Retrieve a handle to the Cache instance to be used for storing timestamps.
 void start(Settings settings, Properties properties)
          Lifecycle callback to perform any necessary initialization of the CacheInstanceManager.
 void stop()
          Lifecycle callback to perform any necessary cleanup of the underlying CacheInstanceManager.
protected  void stopSharedCache(org.jboss.cache.Cache cache)
          Stops the shared cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_RESOURCE_PROP

public static final String CACHE_RESOURCE_PROP
Classpath or filesystem resource containing JBoss Cache configuration settings the Cache should use.

See Also:
DEFAULT_CACHE_RESOURCE, Constant Field Values

LEGACY_CACHE_RESOURCE_PROP

public static final String LEGACY_CACHE_RESOURCE_PROP
Legacy name for configuration property CACHE_RESOURCE_PROP.

See Also:
DEFAULT_CACHE_RESOURCE, Constant Field Values

DEFAULT_CACHE_RESOURCE

public static final String DEFAULT_CACHE_RESOURCE
Default name for the JBoss Cache configuration file.

See Also:
Constant Field Values

CHANNEL_FACTORY_RESOURCE_PROP

public static final String CHANNEL_FACTORY_RESOURCE_PROP
Classpath or filesystem resource containing JGroups protocol stack configurations the org.jgroups.ChannelFactory should use.

See Also:
DEF_JGROUPS_RESOURCE, Constant Field Values

LEGACY_CHANNEL_FACTORY_RESOURCE_PROP

public static final String LEGACY_CHANNEL_FACTORY_RESOURCE_PROP
Legacy name for configuration property CHANNEL_FACTORY_RESOURCE_PROP.

See Also:
DEF_JGROUPS_RESOURCE, Constant Field Values

DEF_JGROUPS_RESOURCE

public static final String DEF_JGROUPS_RESOURCE
Default value for CHANNEL_FACTORY_RESOURCE_PROP. Specifies the "jgroups-stacks.xml" file in this package.

See Also:
Constant Field Values
Constructor Detail

SharedCacheInstanceManager

public SharedCacheInstanceManager()

SharedCacheInstanceManager

public SharedCacheInstanceManager(org.jgroups.ChannelFactory channelFactory)

SharedCacheInstanceManager

public SharedCacheInstanceManager(org.jboss.cache.Cache cache)
Method Detail

getEntityCacheInstance

public org.jboss.cache.Cache getEntityCacheInstance()
Retrieve a handle to the Cache instance to be used for storing entity data.

Specified by:
getEntityCacheInstance in interface CacheInstanceManager
Returns:
The entity data cache instance.

getCollectionCacheInstance

public org.jboss.cache.Cache getCollectionCacheInstance()
Retrieve a handle to the Cache instance to be used for storing collection data.

Specified by:
getCollectionCacheInstance in interface CacheInstanceManager
Returns:
The collection data cache instance.

getQueryCacheInstance

public org.jboss.cache.Cache getQueryCacheInstance()
Retrieve a handle to the Cache instance to be used for storing query results.

Specified by:
getQueryCacheInstance in interface CacheInstanceManager
Returns:
The query result cache instance.

start

public void start(Settings settings,
                  Properties properties)
           throws CacheException
Lifecycle callback to perform any necessary initialization of the CacheInstanceManager. Called exactly once during the construction of a SessionFactoryImpl.

Specified by:
start in interface CacheInstanceManager
Parameters:
settings - The settings in effect.
properties - The defined cfg properties
Throws:
CacheException - Indicates problems starting the L2 cache impl; considered as a sign to stop SessionFactory building.

getTimestampsCacheInstance

public org.jboss.cache.Cache getTimestampsCacheInstance()
Retrieve a handle to the Cache instance to be used for storing timestamps.

Specified by:
getTimestampsCacheInstance in interface CacheInstanceManager
Returns:
The timestamps cache instance.

stop

public void stop()
Lifecycle callback to perform any necessary cleanup of the underlying CacheInstanceManager. Called exactly once during SessionFactory.close().

Specified by:
stop in interface CacheInstanceManager

createSharedCache

protected org.jboss.cache.Cache createSharedCache(Settings settings,
                                                  Properties properties)
Create a cache using the given settings and properties.

Parameters:
settings - The Hibernate settings
properties - The configuration properties
Returns:
The created cache

configureTransactionManager

protected void configureTransactionManager(org.jboss.cache.Cache cache,
                                           Settings settings,
                                           Properties properties)
Injects the TransactionManager found via Settings.getTransactionManagerLookup() into the cache.

Parameters:
cache - The cache instance
settings - The Hibernate settings
properties - The configuration properties
Throws:
CacheException - if cache is already started and is configured with a different TransactionManager than the one we would inject

stopSharedCache

protected void stopSharedCache(org.jboss.cache.Cache cache)
Stops the shared cache.

Parameters:
cache - the shared cache


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.