This is the text of the deleted answer:
Technically, both service and controller layer can be made generic. What I allready saw is are generic abstract services or controllers for the common logic implemented by specialized classes.
You should be aware of a caveat for controllers : if you use a @RequestMapping
annotation in base class for a given URL, the method called will be that of the base class even if you override it in subclass. And Spring won't allow you to repeat the same @RequestMapping
in the subclass.
Of course, you can allways use such a construct :
@RequestMapping( ... )
public ModelAndView something(params ...) {
// pre operations
ModelAndView mv = doSomething(params ...);
// post operations
return mv;
}
because the doSomething
method will be that from subclass if it has been overriden.
Edit:
Of course the abstract controller can only implement the most basic operations that you will find in all your concrete classes, basically list, view, create, edit and delete. But I could use it for different classes implemententing the same interface.
Unfortunately, when a question gets deleted, the answerers lose access to their posts. So posting on meta requesting for your work is appropriate, in my opinion.