ch.elca.el4j.services.persistence.hibernate.dao
Class HibernateSessionFactoryInjectorBeanPostProcessor

java.lang.Object
  extended by ch.elca.el4j.services.persistence.hibernate.dao.HibernateSessionFactoryInjectorBeanPostProcessor
All Implemented Interfaces:
BeanPostProcessor, ApplicationContextAware, Ordered, PriorityOrdered

public class HibernateSessionFactoryInjectorBeanPostProcessor
extends Object
implements BeanPostProcessor, PriorityOrdered, ApplicationContextAware

Inject the session factory in GenericDaos (or other daos) if needed. It gets the sessionFactory from the spring context by using the default name SESSION_FACTORY_BEAN_DEFAULT_NAME or via its setter method.

Author:
Philipp Oser (POS)
File-location:
HibernateSessionFactoryInjectorBeanPostProcessor
Last check-in date:
2009-08-04 14:35:53 +0200 (Di, 04. Aug 2009) by swismer for revision 3875

Field Summary
protected  SessionFactory m_sessionFactory
           
static String SESSION_FACTORY_BEAN_DEFAULT_NAME
          The default name for the property of the session factory.
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
HibernateSessionFactoryInjectorBeanPostProcessor()
           
 
Method Summary
 int getOrder()
          
 SessionFactory getSessionFactory()
          Gets the session factory (from spring context if needed).
protected  void initDao(GenericDao<?> dao)
          Try to init the sessionFactory of the bean.
 Object postProcessAfterInitialization(Object bean, String beanName)
          
 Object postProcessBeforeInitialization(Object bean, String beanName)
          Initiates the real work.
 void setApplicationContext(ApplicationContext applicationContext)
          
 void setOrder(int order)
           
 void setSessionFactory(SessionFactory factory)
          You can either set the session factory explicitly or have the factory load the session factory implicitly (by name).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_FACTORY_BEAN_DEFAULT_NAME

public static final String SESSION_FACTORY_BEAN_DEFAULT_NAME
The default name for the property of the session factory.

See Also:
Constant Field Values

m_sessionFactory

protected SessionFactory m_sessionFactory
Constructor Detail

HibernateSessionFactoryInjectorBeanPostProcessor

public HibernateSessionFactoryInjectorBeanPostProcessor()
Method Detail

postProcessBeforeInitialization

public Object postProcessBeforeInitialization(Object bean,
                                              String beanName)
                                       throws BeansException
Initiates the real work.

Specified by:
postProcessBeforeInitialization in interface BeanPostProcessor
Throws:
BeansException

postProcessAfterInitialization

public Object postProcessAfterInitialization(Object bean,
                                             String beanName)
                                      throws BeansException

Specified by:
postProcessAfterInitialization in interface BeanPostProcessor
Throws:
BeansException

initDao

protected void initDao(GenericDao<?> dao)
Try to init the sessionFactory of the bean.

Parameters:
dao -

getSessionFactory

public SessionFactory getSessionFactory()
Gets the session factory (from spring context if needed).

Returns:

setSessionFactory

public void setSessionFactory(SessionFactory factory)
You can either set the session factory explicitly or have the factory load the session factory implicitly (by name).

Parameters:
factory -

setOrder

public void setOrder(int order)

getOrder

public int getOrder()

Specified by:
getOrder in interface Ordered

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException

Specified by:
setApplicationContext in interface ApplicationContextAware
Throws:
BeansException


Copyright © 2005-2011 ELCA. All Rights Reserved.