org.figure8.join.core.setup
Class HibernateConfigurator

java.lang.Object
  extended by org.figure8.join.core.setup.HibernateConfigurator

public class HibernateConfigurator
extends java.lang.Object

Helper object for configuring Hibernate and its SessionFactory

Version:
$Revision: 1.2 $
Author:
Laurent Broudoux

Field Summary
protected static java.lang.String HBN_PROPERTIES_PREFIX
          Prefix of application properties related to hibernate.
static java.lang.String HBN_SETUP_PROPERTY
          Name of application property telling if Hibernate has been setup
protected static org.apache.commons.logging.Log log
          Get a commons logger.
 
Constructor Summary
HibernateConfigurator()
          Creates a new instance of HibernateConfigurator
 
Method Summary
 void configureDatabase(DatabaseDetails details, boolean embedded)
          Configure Hibernate according to the given database details
 void configureDatasource(java.lang.String datasourceName, java.lang.String dialect)
          Configure Hibernate according to the given datasource JNDI name.
protected  void configureHibernate(java.util.Properties properties)
          Do the real job by filling application with Hibernate properties and creating the database schema if needed.
 ApplicationConfig getApplicationConfig()
           
 java.util.Properties getHibernateProperties()
          Extract hibernate related properties from ApplicationConfig.
 void setApplicationConfig(ApplicationConfig config)
           
 
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.


HBN_PROPERTIES_PREFIX

protected static final java.lang.String HBN_PROPERTIES_PREFIX
Prefix of application properties related to hibernate.

See Also:
Constant Field Values

HBN_SETUP_PROPERTY

public static final java.lang.String HBN_SETUP_PROPERTY
Name of application property telling if Hibernate has been setup

See Also:
Constant Field Values
Constructor Detail

HibernateConfigurator

public HibernateConfigurator()
Creates a new instance of HibernateConfigurator

Method Detail

setApplicationConfig

public void setApplicationConfig(ApplicationConfig config)
Parameters:
config - ApplicationConfig instance

getApplicationConfig

public ApplicationConfig getApplicationConfig()
Returns:
The ApplicationConfig instance used.

getHibernateProperties

public java.util.Properties getHibernateProperties()
Extract hibernate related properties from ApplicationConfig.

Returns:
A set of hibernate properties already present into ApplicationConfig

configureDatabase

public void configureDatabase(DatabaseDetails details,
                              boolean embedded)
                       throws BootstrapException
Configure Hibernate according to the given database details

Parameters:
details - Wrapper object for database connection details
embedded - Boolean telling if database to use is embedded (HSQLDB)
Throws:
BootstrapException - if application config cannot be updated

configureDatasource

public void configureDatasource(java.lang.String datasourceName,
                                java.lang.String dialect)
                         throws BootstrapException
Configure Hibernate according to the given datasource JNDI name.

Parameters:
datasourceName - JNDI name of the datasource to use for connections
dialect - SQL dialect implementation of the database behind datasource
Throws:
BootstrapException - if application config cannot be updated

configureHibernate

protected void configureHibernate(java.util.Properties properties)
                           throws BootstrapException
Do the real job by filling application with Hibernate properties and creating the database schema if needed.

Parameters:
properties - Hibernate specific properties (starting with "hibernate.")
Throws:
BootstrapException - if configuration backup or schema update fails


Copyright © 2005-2008 Join. All Rights Reserved.