FileDocCategorySizeDatePackage
AbstractJndiBoundCacheProvider.javaAPI DocHibernate 3.2.52342Tue Mar 15 23:01:18 GMT 2005org.hibernate.cache

AbstractJndiBoundCacheProvider

public abstract class AbstractJndiBoundCacheProvider extends Object implements CacheProvider
Support for CacheProvider implementations which are backed by caches bound into JNDI namespace.
author
Steve Ebersole

Fields Summary
private static final Log
log
private Object
cache
Constructors Summary
Methods Summary
public java.lang.ObjectgetCache()

		return cache;
	
private java.lang.ObjectlocateCache(java.lang.String jndiNamespace, java.util.Properties jndiProperties)


		Context ctx = null;
		try {
			ctx = new InitialContext( jndiProperties );
			return ctx.lookup( jndiNamespace );
		}
		catch (NamingException ne) {
			String msg = "Unable to retreive Cache from JNDI [" + jndiNamespace + "]";
			log.info( msg, ne );
			throw new CacheException( msg );
		}
		finally {
			if ( ctx != null ) {
				try {
					ctx.close();
				}
				catch( NamingException ne ) {
					log.info( "Unable to release initial context", ne );
				}
			}
		}
	
protected voidprepare(java.util.Properties properties)


	    
		// Do nothing; subclasses may override.
	
protected voidrelease()

		// Do nothing; subclasses may override.
	
public final voidstart(java.util.Properties properties)
Callback to perform any necessary initialization of the underlying cache implementation during SessionFactory construction.

param
properties current configuration settings.

		String jndiNamespace = properties.getProperty( Environment.CACHE_NAMESPACE );
		if ( StringHelper.isEmpty( jndiNamespace ) ) {
			throw new CacheException( "No JNDI namespace specified for cache" );
		}
		cache = locateCache( jndiNamespace, NamingHelper.getJndiProperties( properties ) );
		prepare( properties );
	
public final voidstop()
Callback to perform any necessary cleanup of the underlying cache implementation during SessionFactory.close().

		release();
		cache = null;