Jared Richardson spoke at a Richmond Java Users Group meeting I attended last week; his topic was about investing in yourself and your career - what he called career 2.0. At one point during the presentation, he noted that “if you can’t draw something, you don’t understand it”, which motivated me to finish a blog post I started a while back about Spring Portlet MVC.
I gave a presentation at CapTech’s Feed Your Brain series about using Spring Portlet MVC’s annotation-driven development style, and I wanted to diagram how the lifecycle works under the covers.
The following diagram never made it into the presentation so I wanted to post it here.
Sorry if the graphic doesn’t blow you away; I have an older version of OmniGraffle - but want to get one of these.
So, in short the graphic depicts:
- like most implementations of the Front Controller pattern, the DispatcherPortlet sits in front of all PortletRequests
- if a DefaultAnnotationHandlerMapping is set as the default HandlerMapping implementation in your Portlet’s Spring application context, the DispatcherPortlet will use it to find a @Controller
- the DefaultAnnotationHandlerMapping itself searches your application context for the best matching class annotated as a @Controller
- the DefaultAnnotationHandlerMapping then passes control back to the DispatcherServlet, which then needs a AnnotationMethodHandlerAdapter to determine which method to call on your controller
- the AnnotationMethodHandlerAdapter then checks for methods annotated with @RequestMapping and, again, finds the “best match” method to handle the PortletRequest
- the request is served, and control is passed back to the DispatcherPortlet - voila!
Hope this is helpful to those looking to use Spring Portlet MVC’s nifty annotation model.