History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: APF-775
Type: New Feature New Feature
Status: Open Open
Priority: Minor Minor
Assignee: Matt Raible
Reporter: Leo Duarte
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
AppFuse

GenericController/GenericFormController and @GenericApplicationStack-like annotation

Created: 25/May/07 01:06 PM   Updated: 25/May/07 01:22 PM
Component/s: Web - Spring
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. Zip Archive generic_stack_initial_impl.zip (4 kb)
2. Zip Archive generic_stack_initial_impl_1.zip (4 kb)



 Description  « Hide
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.

 All   Comments   Change History   FishEye      Sort Order: