org.figure8.join.core.persistence
Class ConfigurableHibernateSessionFactoryBean

java.lang.Object
  extended by org.springframework.orm.hibernate.LocalSessionFactoryBean
      extended by org.figure8.join.core.persistence.ConfigurableHibernateSessionFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

public class ConfigurableHibernateSessionFactoryBean
extends org.springframework.orm.hibernate.LocalSessionFactoryBean

This is an extension of Spring LocalSessionFactoryBean that can be further configured using extra properties provided by a HibernateConfigurator instance. The creation of the Hibernate session factory can be also conditioned by the fact that we are on an asynchronous side of the Join application.

Version:
$Revision: 1.3 $
Author:
Laurent Broudoux

Field Summary
protected static org.apache.commons.logging.Log log
          Get a commons logger.
 
Fields inherited from class org.springframework.orm.hibernate.LocalSessionFactoryBean
logger
 
Constructor Summary
ConfigurableHibernateSessionFactoryBean()
          Creates a new instance of ConfigurableHibernateSessionFactoryBean
 
Method Summary
 void afterPropertiesSet()
          Initialize the SessionFactory for the given or the default location.
protected  net.sf.hibernate.cfg.Configuration newConfiguration()
          Custom initialization of the Configuration instance used for SessionFactory creation.
protected  void postProcessConfiguration(net.sf.hibernate.cfg.Configuration config)
          To be implemented by subclasses that want to to perform custom post-processing of the Configuration object after this FactoryBean performed its default initialization.
 void setCheckForAsync(boolean checkForAsync)
           
 void setHibernateConfigurator(HibernateConfigurator configurator)
           
 void setMappingResources(java.util.List resources)
           
 void setReplaceHomeInUrl(boolean replaceHomeInUrl)
           
 void setUseHbnConfigurator(boolean useHbnConfigurator)
           
 
Methods inherited from class org.springframework.orm.hibernate.LocalSessionFactoryBean
createDatabaseSchema, destroy, dropDatabaseSchema, executeSchemaScript, getConfigTimeDataSource, getConfigTimeLobHandler, getConfigTimeTransactionManager, getConfiguration, getObject, getObjectType, isSingleton, newSessionFactory, setConfigLocation, setDataSource, setEntityInterceptor, setHibernateProperties, setJtaTransactionManager, setLobHandler, setMappingDirectoryLocations, setMappingJarLocations, setMappingLocations, setMappingResources, setNamingStrategy, setSchemaUpdate, setUseTransactionAwareDataSource, updateDatabaseSchema
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Get a commons logger.

Constructor Detail

ConfigurableHibernateSessionFactoryBean

public ConfigurableHibernateSessionFactoryBean()
Creates a new instance of ConfigurableHibernateSessionFactoryBean

Method Detail

setCheckForAsync

public void setCheckForAsync(boolean checkForAsync)
Parameters:
checkForAsync - Flag telling if we should start only if on asychronous side of application

setUseHbnConfigurator

public void setUseHbnConfigurator(boolean useHbnConfigurator)
Parameters:
useHbnConfigurator - Flag telling if properties from Spring should be overriden by HibernateConfigurator

setReplaceHomeInUrl

public void setReplaceHomeInUrl(boolean replaceHomeInUrl)
Parameters:
replaceHomeInUrl - Flag telling if property representing Url should be checked

setMappingResources

public void setMappingResources(java.util.List resources)
Parameters:
resources - List of Hibernate mapping resources

setHibernateConfigurator

public void setHibernateConfigurator(HibernateConfigurator configurator)
Parameters:
configurator - Helper for configuring session factory

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.IllegalArgumentException,
                               net.sf.hibernate.HibernateException,
                               java.io.IOException
Initialize the SessionFactory for the given or the default location. This is only done if : checkForAynch is false or checkForAsync is true and we are on an asynchronous side of the application.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class org.springframework.orm.hibernate.LocalSessionFactoryBean
Throws:
java.lang.IllegalArgumentException - in case of illegal property values
net.sf.hibernate.HibernateException - in case of Hibernate initialization errors
java.io.IOException - ...

newConfiguration

protected net.sf.hibernate.cfg.Configuration newConfiguration()
                                                       throws net.sf.hibernate.HibernateException
Custom initialization of the Configuration instance used for SessionFactory creation.

Overrides:
newConfiguration in class org.springframework.orm.hibernate.LocalSessionFactoryBean
Returns:
A newly created Hibernate configuration
Throws:
net.sf.hibernate.HibernateException

postProcessConfiguration

protected void postProcessConfiguration(net.sf.hibernate.cfg.Configuration config)
                                 throws net.sf.hibernate.HibernateException
To be implemented by subclasses that want to to perform custom post-processing of the Configuration object after this FactoryBean performed its default initialization.

Overrides:
postProcessConfiguration in class org.springframework.orm.hibernate.LocalSessionFactoryBean
Parameters:
config - the current Configuration object
Throws:
net.sf.hibernate.HibernateException - in case of Hibernate initialization errors


Copyright © 2005-2008 Join. All Rights Reserved.