FileDocCategorySizeDatePackage
HibernateService.javaAPI DocHibernate 3.2.54593Thu Mar 17 03:48:04 GMT 2005org.hibernate.jmx

HibernateService

public class HibernateService extends org.hibernate.util.ExternalSessionFactoryConfig implements HibernateServiceMBean
Implementation of HibernateServiceMBean. Creates a SessionFactory and binds it to the specified JNDI name.

All mapping documents are loaded as resources by the MBean.
see
HibernateServiceMBean
see
org.hibernate.SessionFactory
author
John Urberg, Gavin King

Fields Summary
private static final Log
log
private String
boundName
private Properties
properties
Constructors Summary
Methods Summary
org.hibernate.SessionFactorybuildSessionFactory()

		log.info( "starting service at JNDI name: " + boundName );
		log.info( "service properties: " + properties );
		return buildConfiguration().buildSessionFactory();
	
public voidcreateSchema()

		new SchemaExport( buildConfiguration() ).create(false, true);
	
public voiddropSchema()

		new SchemaExport( buildConfiguration() ).drop(false, true);
	
public java.lang.StringgetAutoCloseSessionEnabled()

		return getProperty(Environment.AUTO_CLOSE_SESSION);
	
public java.lang.StringgetDatasource()

		return getProperty(Environment.DATASOURCE);
	
protected java.util.MapgetExtraProperties()

		return properties;
	
public java.lang.StringgetFlushBeforeCompletionEnabled()

		return getProperty(Environment.FLUSH_BEFORE_COMPLETION);
	
public java.lang.StringgetJndiName()

		return getProperty(Environment.SESSION_FACTORY_NAME);
	
public java.lang.StringgetName()

		return getProperty(Environment.SESSION_FACTORY_NAME);
	
public java.lang.StringgetPassword()

		return getProperty(Environment.PASS);
	
public java.util.PropertiesgetProperties()

		return buildProperties();
	
public java.lang.StringgetProperty(java.lang.String property)

		return properties.getProperty(property);
	
public java.lang.StringgetPropertyList()

		return buildProperties().toString();
	
public java.lang.StringgetTransactionManagerLookupStrategy()

		return getProperty(Environment.TRANSACTION_MANAGER_STRATEGY);
	
public java.lang.StringgetTransactionStrategy()

		return getProperty(Environment.TRANSACTION_STRATEGY);
	
public java.lang.StringgetUserName()

		return getProperty(Environment.USER);
	
public java.lang.StringgetUserTransactionName()

		return getProperty(Environment.USER_TRANSACTION);
	
public voidsetAutoCloseSessionEnabled(java.lang.String enabled)

		setProperty(Environment.AUTO_CLOSE_SESSION, enabled);
	
public voidsetDatasource(java.lang.String datasource)

		setProperty(Environment.DATASOURCE, datasource);
	
public voidsetFlushBeforeCompletionEnabled(java.lang.String enabled)

		setProperty(Environment.FLUSH_BEFORE_COMPLETION, enabled);
	
public voidsetJndiName(java.lang.String jndiName)

		setProperty(Environment.SESSION_FACTORY_NAME, jndiName);
	
public voidsetPassword(java.lang.String password)

		setProperty(Environment.PASS, password);
	
public voidsetProperty(java.lang.String property, java.lang.String value)

		properties.setProperty(property, value);
	
public voidsetTransactionManagerLookupStrategy(java.lang.String lkpStrategy)

		setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, lkpStrategy);
	
public voidsetTransactionStrategy(java.lang.String txnStrategy)

		setProperty(Environment.TRANSACTION_STRATEGY, txnStrategy);
	
public voidsetUserName(java.lang.String userName)

		setProperty(Environment.USER, userName);
	
public voidsetUserTransactionName(java.lang.String utName)

		setProperty(Environment.USER_TRANSACTION, utName);
	
public voidstart()



	     
		boundName = getJndiName();
		try {
			buildSessionFactory();
		}
		catch (HibernateException he) {
			log.info( "Could not build SessionFactory using the MBean classpath - will try again using client classpath: " + he.getMessage() );
			log.debug("Error was", he);
			new SessionFactoryStub(this);
		}
	
public voidstop()

		log.info("stopping service");
		try {
			InitialContext context = NamingHelper.getInitialContext( buildProperties() );
			( (SessionFactory) context.lookup(boundName) ).close();
			//context.unbind(boundName);
		}
		catch (Exception e) {
			log.warn("exception while stopping service", e);
		}