org.synyx.hades.dao.orm
Class GenericDaoFactoryBean<T extends GenericDao<?,?>>

java.lang.Object
  extended by org.synyx.hades.dao.orm.GenericDaoFactory
      extended by org.synyx.hades.dao.orm.GenericDaoFactoryBean<T>
Type Parameters:
T - the type of the DAO
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.InitializingBean

public class GenericDaoFactoryBean<T extends GenericDao<?,?>>
extends GenericDaoFactory
implements org.springframework.beans.factory.FactoryBean<T>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanFactoryAware

Special GenericDaoFactory adapter for Springs FactoryBean interface to allow easy setup of DAO factories via Spring configuration.

Author:
Oliver Gierke, Eberhard Wolff

Field Summary
static java.lang.String DEFAULT_TRANSACTION_MANAGER
           
 
Constructor Summary
GenericDaoFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
static
<T extends GenericDao<?,?>>
GenericDaoFactoryBean<T>
create(java.lang.Class<T> daoInterface, javax.persistence.EntityManager em)
          Creates a new GenericDaoFactoryBean.
 T getObject()
           
 java.lang.Class<? extends T> getObjectType()
           
 boolean isSingleton()
           
protected  void prepare(org.springframework.aop.framework.ProxyFactory factory)
          Callback method to prepare the given ProxyFactory to e.g. add further interceptors.
 void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
           
 void setCustomDaoImplementation(java.lang.Object customDaoImplementation)
          Setter to inject a custom DAO implementation.
 void setDaoInterface(java.lang.Class<T> daoInterface)
          Setter to inject the dao interface to implement.
 void setTransactionManager(java.lang.String transactionManager)
          Setter to configure which transaction manager to be used.
 
Methods inherited from class org.synyx.hades.dao.orm.GenericDaoFactory
create, getDao, getDao, getDaoClass, getEntityManager, setEntityManager, setQueryLookupStrategy, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TRANSACTION_MANAGER

public static final java.lang.String DEFAULT_TRANSACTION_MANAGER
See Also:
Constant Field Values
Constructor Detail

GenericDaoFactoryBean

public GenericDaoFactoryBean()
Method Detail

create

public static <T extends GenericDao<?,?>> GenericDaoFactoryBean<T> create(java.lang.Class<T> daoInterface,
                                                                          javax.persistence.EntityManager em)
Creates a new GenericDaoFactoryBean.

Type Parameters:
T -
Parameters:
daoInterface -
em -
Returns:

setDaoInterface

public void setDaoInterface(java.lang.Class<T> daoInterface)
Setter to inject the dao interface to implement. Defaults to GenericDao.

Parameters:
daoInterface - the daoInterface to set

setTransactionManager

public void setTransactionManager(java.lang.String transactionManager)
Setter to configure which transaction manager to be used. We have to use the bean name explicitly as otherwise the qualifier of the Transactional annotation is used. By explicitly defining the transaction manager bean name we favour let this one be the default one chosen.

Parameters:
transactionManager -

setCustomDaoImplementation

public void setCustomDaoImplementation(java.lang.Object customDaoImplementation)
Setter to inject a custom DAO implementation. This class needs

Parameters:
customDaoImplementation - the customDaoImplementation to set

getObject

public T getObject()
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<T extends GenericDao<?,?>>

getObjectType

public java.lang.Class<? extends T> getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<T extends GenericDao<?,?>>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<T extends GenericDao<?,?>>

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
                    throws org.springframework.beans.BeansException
Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Throws:
org.springframework.beans.BeansException

prepare

protected void prepare(org.springframework.aop.framework.ProxyFactory factory)
Description copied from class: GenericDaoFactory
Callback method to prepare the given ProxyFactory to e.g. add further interceptors. The QueryExecuterMethodInterceptor will be added after this method was called, so all interceptors or advisors added in this method will kick in before it.

Overrides:
prepare in class GenericDaoFactory
See Also:
prepare(ProxyFactory)


Copyright © 2009-2010 Synyx GmbH & Co. KG. All Rights Reserved.