org.hibernate.cache.jbc2.builder
Class MultiplexingCacheInstanceManager

java.lang.Object
  extended by org.hibernate.cache.jbc2.builder.MultiplexingCacheInstanceManager
All Implemented Interfaces:
CacheInstanceManager
Direct Known Subclasses:
JndiMultiplexingCacheInstanceManager

public class MultiplexingCacheInstanceManager
extends Object
implements CacheInstanceManager

Allows building separate Cache instances for each type of region, with the expectation that a single multiplexed JGroups resource (i.e. a multiplexed channel or a shared transport channel) will be shared between the caches.

Author:
Steve Ebersole, Brian Stansberry

Field Summary
static String CACHE_FACTORY_RESOURCE_PROP
          Classpath or filesystem resource containing JBoss Cache configurations the factory 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 COLLECTION_CACHE_RESOURCE_PROP
          Name of the configuration that should be used for collection caches.
static String DEF_CACHE_FACTORY_RESOURCE
          Default value for CACHE_FACTORY_RESOURCE_PROP.
static String DEF_ENTITY_RESOURCE
          Default value for ENTITY_CACHE_RESOURCE_PROP.
static String DEF_JGROUPS_RESOURCE
          Default value for CHANNEL_FACTORY_RESOURCE_PROP.
static String DEF_QUERY_RESOURCE
          Default value for ENTITY_CACHE_RESOURCE_PROP.
static String DEF_TS_RESOURCE
          Default value for TIMESTAMP_CACHE_RESOURCE_PROP.
static String ENTITY_CACHE_RESOURCE_PROP
          Name of the configuration that should be used for entity caches.
static String QUERY_CACHE_RESOURCE_PROP
          Name of the configuration that should be used for query caches.
static String TIMESTAMP_CACHE_RESOURCE_PROP
          Name of the configuration that should be used for timestamp caches.
 
Constructor Summary
MultiplexingCacheInstanceManager()
          Create a new MultiplexingCacheInstanceManager.
MultiplexingCacheInstanceManager(org.jboss.cache.Cache jbcEntityCache, org.jboss.cache.Cache jbcCollectionCache, org.jboss.cache.Cache jbcTsCache, org.jboss.cache.Cache jbcQueryCache)
          Create a new MultiplexingCacheInstanceManager using the provided Caches.
 
Method Summary
 org.jboss.cache.CacheManager getCacheFactory()
          Getter for property 'cacheFactory'.
 org.jgroups.ChannelFactory getChannelFactory()
          Getter for property 'channelFactory'.
 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 setCacheFactory(org.jboss.cache.CacheManager factory)
          Setter for property 'cacheFactory'.
 void setChannelFactory(org.jgroups.ChannelFactory factory)
          Setter for property 'channelFactory'.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_FACTORY_RESOURCE_PROP

public static final String CACHE_FACTORY_RESOURCE_PROP
Classpath or filesystem resource containing JBoss Cache configurations the factory should use.

See Also:
DEF_CACHE_FACTORY_RESOURCE, 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

ENTITY_CACHE_RESOURCE_PROP

public static final String ENTITY_CACHE_RESOURCE_PROP
Name of the configuration that should be used for entity caches.

See Also:
DEF_ENTITY_RESOURCE, Constant Field Values

COLLECTION_CACHE_RESOURCE_PROP

public static final String COLLECTION_CACHE_RESOURCE_PROP
Name of the configuration that should be used for collection caches. No default value, as by default we try to use the same JBoss Cache instance we use for entity caching.

See Also:
ENTITY_CACHE_RESOURCE_PROP, DEF_ENTITY_RESOURCE, Constant Field Values

TIMESTAMP_CACHE_RESOURCE_PROP

public static final String TIMESTAMP_CACHE_RESOURCE_PROP
Name of the configuration that should be used for timestamp caches.

See Also:
DEF_TS_RESOURCE, Constant Field Values

QUERY_CACHE_RESOURCE_PROP

public static final String QUERY_CACHE_RESOURCE_PROP
Name of the configuration that should be used for query caches.

See Also:
DEF_QUERY_RESOURCE, Constant Field Values

DEF_CACHE_FACTORY_RESOURCE

public static final String DEF_CACHE_FACTORY_RESOURCE
Default value for CACHE_FACTORY_RESOURCE_PROP. Specifies the "jbc2-configs.xml" file in this package.

See Also:
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

DEF_ENTITY_RESOURCE

public static final String DEF_ENTITY_RESOURCE
Default value for ENTITY_CACHE_RESOURCE_PROP.

See Also:
Constant Field Values

DEF_TS_RESOURCE

public static final String DEF_TS_RESOURCE
Default value for TIMESTAMP_CACHE_RESOURCE_PROP.

See Also:
Constant Field Values

DEF_QUERY_RESOURCE

public static final String DEF_QUERY_RESOURCE
Default value for ENTITY_CACHE_RESOURCE_PROP.

See Also:
Constant Field Values
Constructor Detail

MultiplexingCacheInstanceManager

public MultiplexingCacheInstanceManager()
Create a new MultiplexingCacheInstanceManager.


MultiplexingCacheInstanceManager

public MultiplexingCacheInstanceManager(org.jboss.cache.Cache jbcEntityCache,
                                        org.jboss.cache.Cache jbcCollectionCache,
                                        org.jboss.cache.Cache jbcTsCache,
                                        org.jboss.cache.Cache jbcQueryCache)
Create a new MultiplexingCacheInstanceManager using the provided Caches.

If this constructor is used, the start(Settings, Properties) method will make no attempt to create a cache factory or obtain caches from it. Only the Caches passed as arguments to this constructor will be available.

Parameters:
jbcEntityCache - The entity cache
jbcCollectionCache - the collection cache
jbcTsCache - The timestamps cache
jbcQueryCache - The query cache
Method Detail

getCacheFactory

public org.jboss.cache.CacheManager getCacheFactory()
Getter for property 'cacheFactory'.

Returns:
Value for property 'cacheFactory'.
See Also:
setCacheFactory(org.jboss.cache.CacheManager)

setCacheFactory

public void setCacheFactory(org.jboss.cache.CacheManager factory)
Setter for property 'cacheFactory'.

Parameters:
factory - Value to set for property 'cacheFactory'.
See Also:
getCacheFactory()

getChannelFactory

public org.jgroups.ChannelFactory getChannelFactory()
Getter for property 'channelFactory'.

Returns:
Value for property 'channelFactory'.
See Also:
setChannelFactory(org.jgroups.ChannelFactory)

setChannelFactory

public void setChannelFactory(org.jgroups.ChannelFactory factory)
Setter for property 'channelFactory'.

Parameters:
factory - Value to set for property 'channelFactory'.
See Also:
getChannelFactory()

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.

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.

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.

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


Copyright © 2009 Hibernate.org. All Rights Reserved.