ch.elca.el4j.services.persistence.jpa.dao
Class JpaEntityManagerFactoryInjectorBeanPostProcessor

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

public class JpaEntityManagerFactoryInjectorBeanPostProcessor
extends Object
implements BeanPostProcessor, PriorityOrdered, ApplicationContextAware

Inject the entity manager factory in GenericDaos (or other daos) if needed. It gets the entityManagerFactory from the spring context by using the default name ENTITY_MANAGER_FACTORY_BEAN_DEFAULT_NAME or via its setter method.

Author:
Simon Stelling (SST)
File-location:
JpaEntityManagerFactoryInjectorBeanPostProcessor
Last check-in date:
2010-12-21 11:08:04 +0100 (Di, 21. Dez 2010) by swismer for revision 4253

Field Summary
static String ENTITY_MANAGER_FACTORY_BEAN_DEFAULT_NAME
          The default name for the property of the session factory.
protected  javax.persistence.EntityManagerFactory m_entityManagerFactory
           
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
JpaEntityManagerFactoryInjectorBeanPostProcessor()
           
 
Method Summary
 javax.persistence.EntityManagerFactory getEntityManagerFactory()
          Gets the session factory (from spring context if needed).
 int getOrder()
          
protected  void initDao(ConvenienceGenericJpaDao<?,?> 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 setEntityManagerFactory(javax.persistence.EntityManagerFactory factory)
          You can either set the session factory explicitly or have the factory load the session factory implicitly (by name).
 void setOrder(int order)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENTITY_MANAGER_FACTORY_BEAN_DEFAULT_NAME

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

See Also:
Constant Field Values

m_entityManagerFactory

protected javax.persistence.EntityManagerFactory m_entityManagerFactory
Constructor Detail

JpaEntityManagerFactoryInjectorBeanPostProcessor

public JpaEntityManagerFactoryInjectorBeanPostProcessor()
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(ConvenienceGenericJpaDao<?,?> dao)
Try to init the sessionFactory of the bean.

Parameters:
dao -

getEntityManagerFactory

public javax.persistence.EntityManagerFactory getEntityManagerFactory()
Gets the session factory (from spring context if needed).

Returns:

setEntityManagerFactory

public void setEntityManagerFactory(javax.persistence.EntityManagerFactory 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.