FileDocCategorySizeDatePackage
TreeCacheProvider.javaAPI DocHibernate 3.2.53498Fri May 05 14:27:18 BST 2006org.hibernate.cache

TreeCacheProvider

public class TreeCacheProvider extends Object implements CacheProvider
Support for a standalone JBossCache (TreeCache) instance. The JBossCache is configured via a local config resource.
author
Gavin King

Fields Summary
public static final String
CONFIG_RESOURCE
public static final String
DEFAULT_CONFIG
private static final Log
log
private org.jboss.cache.TreeCache
cache
private TransactionManager
transactionManager
Constructors Summary
Methods Summary
public CachebuildCache(java.lang.String regionName, java.util.Properties properties)
Construct and configure the Cache representation of a named cache region.

param
regionName the name of the cache region
param
properties configuration settings
return
The Cache representation of the named cache region.
throws
CacheException Indicates an error building the cache region.


	                                         	 
	        
		return new TreeCache(cache, regionName, transactionManager);
	
public org.jboss.cache.TreeCachegetUnderlyingCache()

		return cache;
	
public booleanisMinimalPutsEnabledByDefault()

		return true;
	
public longnextTimestamp()

		return System.currentTimeMillis() / 100;
	
public voidstart(java.util.Properties properties)
Prepare the underlying JBossCache TreeCache instance.

param
properties All current config settings.
throws
CacheException Indicates a problem preparing cache for use.

		String resource = properties.getProperty( Environment.CACHE_PROVIDER_CONFIG );

		if ( resource == null ) {
			resource = properties.getProperty( CONFIG_RESOURCE );
		}
		if ( resource == null ) {
			resource = DEFAULT_CONFIG;
		}
		log.debug( "Configuring TreeCache from resource [" + resource + "]" );
		try {
			cache = new org.jboss.cache.TreeCache();
			PropertyConfigurator config = new PropertyConfigurator();
			config.configure( cache, resource );
			TransactionManagerLookup transactionManagerLookup = TransactionManagerLookupFactory.getTransactionManagerLookup(properties);
			if (transactionManagerLookup!=null) {
				cache.setTransactionManagerLookup( new TransactionManagerLookupAdaptor(transactionManagerLookup, properties) );
				transactionManager = transactionManagerLookup.getTransactionManager(properties);
			}
			cache.start();
		}
		catch (Exception e) {
			throw new CacheException(e);
		}
	
public voidstop()

		if (cache!=null) {
			cache.stop();
			cache.destroy();
			cache=null;
		}