|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gisgraphy.dao.spring.HibernateExtensionPostProcessor
public class HibernateExtensionPostProcessor
Adds Hibernate persistent class definitions to an existing Spring Session Factory bean, possibly defined within a separate Spring configuration file in a seprate jar file. By using this extension factory developers can add persistent classes to an AppFuse application without modifying any of the existing AppFuse Spring configuration or jar distribution files.
As an example consider the following Spring bean configuration:
<bean class="com.gisgraphy.dao.spring.HibernateExtensionPostProcessor"> <property name="mappingResources"> <list> <value>com/gisgraphy/model/Foo.hbm.xml</value> </list> </property> <property name="annotatedClasses"> <list> <value>com.gisgraphy.model.Bar</value> </list> </property> </bean>
The snippet will add two persistent classes to an existing Session Factory bean called "sessionFactory". Note that the extension can handle both annotated classes and the more traditional .hbm.xml files. Assuming that these persistent classes are packaged in a jar called extension.jar which contains the Spring configuration file applicationContext-dao.xml at the root level, then the standard AppFuse configuration will automatically pick up the new Spring configuration file and the new persistent classes will be added to the list already defined for the session factory bean configured within the standard appfuse-hibernate.jar file. And all this without needing to touch the original AppFuse configuration files!
Constructor Summary | |
---|---|
HibernateExtensionPostProcessor()
|
Method Summary | |
---|---|
void |
postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory configurableListableBeanFactory)
Adds the annotated classes and the mapping resources to the existing Session Factory configuration. |
void |
setAnnotatedClasses(java.util.List annotatedClasses)
The list of annotated classes to add to the session factory. |
void |
setConfigLocations(java.util.List configLocations)
The list of configuration locations (i.e. classpath:hibernate.cfg.xml) to add to the session factory |
void |
setHibernateProperties(java.util.Properties hibernateProperties)
Hibernate properties to add to the session factory. |
void |
setMappingResources(java.util.List mappingResources)
Set the list of mapping resources (.hbm.xml files) to be added to the session factory. |
void |
setSessionFactoryBeanName(java.lang.String sessionFactoryBeanName)
Set the name of the SessionFactory bean. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HibernateExtensionPostProcessor()
Method Detail |
---|
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory configurableListableBeanFactory)
postProcessBeanFactory
in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
configurableListableBeanFactory
- the good ol' bean factorypublic void setSessionFactoryBeanName(java.lang.String sessionFactoryBeanName)
sessionFactoryBeanName
- The name of the session factory bean.public void setMappingResources(java.util.List mappingResources)
mappingResources
- The list of mapping resources.public void setAnnotatedClasses(java.util.List annotatedClasses)
annotatedClasses
- The list of annotated classes that need to be added.public void setConfigLocations(java.util.List configLocations)
configLocations
- The list of configuration locations that need to be added.public void setHibernateProperties(java.util.Properties hibernateProperties)
hibernateProperties
- The list of additional properties.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |