org.hibernate.cache.infinispan
Class InfinispanRegionFactory

java.lang.Object
  extended by org.hibernate.cache.infinispan.InfinispanRegionFactory
All Implemented Interfaces:
RegionFactory
Direct Known Subclasses:
JndiInfinispanRegionFactory

public class InfinispanRegionFactory
extends Object
implements RegionFactory

A RegionFactory for Infinispan-backed cache regions.

Since:
3.5
Author:
Chris Bredesen, Galder ZamarreƱo

Field Summary
static String COLLECTION_CACHE_RESOURCE_PROP
          Name of the configuration that should be used for collection caches.
static String DEF_ENTITY_RESOURCE
          Default value for ENTITY_CACHE_RESOURCE_PROP.
static String DEF_INFINISPAN_CONFIG_RESOURCE
          Default value for INFINISPAN_CONFIG_RESOURCE_PROP.
static String DEF_QUERY_RESOURCE
          Default value for QUERY_CACHE_RESOURCE_PROP.
static String DEF_TIMESTAMPS_RESOURCE
          Default value for TIMESTAMPS_CACHE_RESOURCE_PROP.
static String ENTITY_CACHE_RESOURCE_PROP
          Name of the configuration that should be used for entity caches.
static String INFINISPAN_CONFIG_RESOURCE_PROP
          Classpath or filesystem resource containing Infinispan configurations the factory should use.
static String INFINISPAN_GLOBAL_STATISTICS_PROP
           
static String QUERY_CACHE_RESOURCE_PROP
          Name of the configuration that should be used for query caches.
static String TIMESTAMPS_CACHE_RESOURCE_PROP
          Name of the configuration that should be used for timestamp caches.
 
Constructor Summary
InfinispanRegionFactory()
          Create a new instance using the default configuration.
InfinispanRegionFactory(Properties props)
          Create a new instance using conifguration properties in props.
 
Method Summary
 CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata)
          Build a cache region specialized for storing collection data.
 EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata)
          Build a cache region specialized for storing entity data.
 QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties)
          Build a cache region specialized for storing query results
 TimestampsRegion buildTimestampsRegion(String regionName, Properties properties)
          Build a cache region specialized for storing update-timestamps data.
protected  org.infinispan.manager.EmbeddedCacheManager createCacheManager(Properties properties)
           
protected  ClassLoaderAwareCache createCacheWrapper(org.infinispan.AdvancedCache cache)
           
protected  TimestampsRegionImpl createTimestampsRegion(CacheAdapter cacheAdapter, String regionName)
           
 org.infinispan.manager.EmbeddedCacheManager getCacheManager()
           
 AccessType getDefaultAccessType()
          Get the default access type for entity and collection regions.
 Set<String> getDefinedConfigurations()
           
protected  TransactionManager getTransactionManager()
           
 Map<String,TypeOverrides> getTypeOverrides()
          Returns an unmodifiable map containing configured entity/collection type configuration overrides.
 boolean isMinimalPutsEnabledByDefault()
          By default should we perform "minimal puts" when using this second level cache implementation?
 long nextTimestamp()
          Generate a timestamp.
 void setCacheManager(org.infinispan.manager.EmbeddedCacheManager manager)
           
 void start(Settings settings, Properties properties)
          Lifecycle callback to perform any necessary initialization of the underlying cache implementation(s).
 void stop()
          Lifecycle callback to perform any necessary cleanup of the underlying cache implementation(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFINISPAN_CONFIG_RESOURCE_PROP

public static final String INFINISPAN_CONFIG_RESOURCE_PROP
Classpath or filesystem resource containing Infinispan configurations the factory should use.

See Also:
DEF_INFINISPAN_CONFIG_RESOURCE, Constant Field Values

INFINISPAN_GLOBAL_STATISTICS_PROP

public static final String INFINISPAN_GLOBAL_STATISTICS_PROP
See Also:
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 Infinispan cache instance we use for entity caching.

See Also:
ENTITY_CACHE_RESOURCE_PROP, DEF_ENTITY_RESOURCE, Constant Field Values

TIMESTAMPS_CACHE_RESOURCE_PROP

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

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

public static final String DEF_INFINISPAN_CONFIG_RESOURCE
Default value for INFINISPAN_CONFIG_RESOURCE_PROP. Specifies the "infinispan-configs.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_TIMESTAMPS_RESOURCE

public static final String DEF_TIMESTAMPS_RESOURCE
Default value for TIMESTAMPS_CACHE_RESOURCE_PROP.

See Also:
Constant Field Values

DEF_QUERY_RESOURCE

public static final String DEF_QUERY_RESOURCE
Default value for QUERY_CACHE_RESOURCE_PROP.

See Also:
Constant Field Values
Constructor Detail

InfinispanRegionFactory

public InfinispanRegionFactory()
Create a new instance using the default configuration.


InfinispanRegionFactory

public InfinispanRegionFactory(Properties props)
Create a new instance using conifguration properties in props.

Parameters:
props - Environmental properties; currently unused.
Method Detail

buildCollectionRegion

public CollectionRegion buildCollectionRegion(String regionName,
                                              Properties properties,
                                              CacheDataDescription metadata)
                                       throws CacheException
Build a cache region specialized for storing collection data.

Specified by:
buildCollectionRegion in interface RegionFactory
Parameters:
regionName - The name of the region.
properties - Configuration properties.
metadata - Information regarding the type of data to be cached
Returns:
The built region
Throws:
CacheException - Indicates problems building the region.

buildEntityRegion

public EntityRegion buildEntityRegion(String regionName,
                                      Properties properties,
                                      CacheDataDescription metadata)
                               throws CacheException
Build a cache region specialized for storing entity data.

Specified by:
buildEntityRegion in interface RegionFactory
Parameters:
regionName - The name of the region.
properties - Configuration properties.
metadata - Information regarding the type of data to be cached
Returns:
The built region
Throws:
CacheException - Indicates problems building the region.

buildQueryResultsRegion

public QueryResultsRegion buildQueryResultsRegion(String regionName,
                                                  Properties properties)
                                           throws CacheException
Build a cache region specialized for storing query results

Specified by:
buildQueryResultsRegion in interface RegionFactory
Parameters:
regionName - The name of the region.
properties - Configuration properties.
Returns:
The built region
Throws:
CacheException - Indicates problems building the region.

buildTimestampsRegion

public TimestampsRegion buildTimestampsRegion(String regionName,
                                              Properties properties)
                                       throws CacheException
Build a cache region specialized for storing update-timestamps data.

Specified by:
buildTimestampsRegion in interface RegionFactory
Parameters:
regionName - The name of the region.
properties - Configuration properties.
Returns:
The built region
Throws:
CacheException - Indicates problems building the region.

createTimestampsRegion

protected TimestampsRegionImpl createTimestampsRegion(CacheAdapter cacheAdapter,
                                                      String regionName)

getTransactionManager

protected TransactionManager getTransactionManager()

isMinimalPutsEnabledByDefault

public boolean isMinimalPutsEnabledByDefault()
By default should we perform "minimal puts" when using this second level cache implementation?

Specified by:
isMinimalPutsEnabledByDefault in interface RegionFactory
Returns:
True if "minimal puts" should be performed by default; false otherwise.

getDefaultAccessType

public AccessType getDefaultAccessType()
Description copied from interface: RegionFactory
Get the default access type for entity and collection regions.

Specified by:
getDefaultAccessType in interface RegionFactory
Returns:
This factory's default access type.

nextTimestamp

public long nextTimestamp()
Generate a timestamp.

This is generally used for cache content locking/unlocking purposes depending upon the access-strategy being used.

Specified by:
nextTimestamp in interface RegionFactory
Returns:
The generated timestamp.

setCacheManager

public void setCacheManager(org.infinispan.manager.EmbeddedCacheManager manager)

getCacheManager

public org.infinispan.manager.EmbeddedCacheManager getCacheManager()

start

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

Specified by:
start in interface RegionFactory
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 cache implementation(s). Called exactly once during SessionFactory.close().

Specified by:
stop in interface RegionFactory

getTypeOverrides

public Map<String,TypeOverrides> getTypeOverrides()
Returns an unmodifiable map containing configured entity/collection type configuration overrides. This method should be used primarily for testing/checking purpouses.

Returns:
an unmodifiable map.

getDefinedConfigurations

public Set<String> getDefinedConfigurations()

createCacheManager

protected org.infinispan.manager.EmbeddedCacheManager createCacheManager(Properties properties)
                                                                  throws CacheException
Throws:
CacheException

createCacheWrapper

protected ClassLoaderAwareCache createCacheWrapper(org.infinispan.AdvancedCache cache)


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