Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Web - Spring
-
Labels:None
Description
Would it make sense to create Generic Controllers? I played around w/ the concept and came up w/ an
initial set of GenericController/GenericFormController. Any thoughts? Would this be of any use?
Attached:
GenericFormController.java
GenericController.java
I also played around w/ being able to add a model class w/o having to configure/add beans to the
respective applicationContext files when using the generic stack (DAO/Manager/Controller).
I created a BeanFactoryPostProcessor that retrieves the sessionFactory bean from the beanFactory.
At that point I iterate through the sessionFactory.getAllClassMetadata() keyset and use Class.forName(key)
to check for the @GenericApplicationStack annotation on all entities mapped in the sessionFactory.
If the class is annotated w/ @GenericApplicationStack I build, register, and programatically wire the set of beans
(GenericDAO,GenericManager, GenericCotroller, and GenericController) and add them to the beanFactory.
Lastly I grab the urlMapping bean and add the controller mappings.
Attached:
GenericApplicationStack.java
GenericApplicationStackAnnotationBeanFactoryPostProcessor.java
From a user point of view they would basically have to do the following to use the functionality:
1. Create model class, hibernate mapping/annotations, and annotate the model class:
@GenericApplicationStack
public class User {
.......
}
2. Add the BeanFactoryPostProcessor to their dispatcher-servlet.xml file:
<bean class="GenericApplicationStackAnnotationBeanFactoryPostProcessor">
<property name="sessionFactoryName" value="sessionFactory"/>
<property name="genericDAOClass" value="GenericDAOHibernateImpl"/>
<property name="genericManagerClass" value="GenericManagerImpl"/>
<property name="genericControllerClass" value="GenericController"/>
<property name="generiFormControllerClass" value="GenericFormController"/>
</bean>
3. Create the corresponding jsp files.
AppFuse - Dev Mailing List Reference:
http://www.nabble.com/GenericController-GenericFormController-and-@GenericApplicationStack-annotation-t3673545s2369.html