Normal portlet development
The portlet class acted as a controller, responsible for data validation, dispatching request to appropriate JSPs, preparing data for the JSP pages and encapsulating call to business services.
When more and more features we start adding to a portlet, the portlet class becomes heavier with extra responsibilities, resulting in unfocused and unmanageable code.
This issue related to a heavy code in controller class which is addressed by splitting the request processing responsibilities into more focused components or classes, which we can achieve by using a portlet framework. Portlet frameworks make use of best design practices and patterns to simplify portlet application development, respectively.
For Portlet framework we can select any MVC framework like Liferay MVCPortlet(JSR2.0), JSF 2.0 (JSR 314) , Spring 3.1 and etc.. Here we are going to use Spring 3.1 Portlet framework.
Spring Portlet MVC for developing portlets is driven by the fact that it is the only framework which is designed group-up to develop portlets.
Dependency Injection (DI)
Dependency Injection (DI) is at the core of Spring framework and It is used, to create and inject object dependencies. When using Dependency Injection, dependencies are specified in an external configuration file (like an XML file) or within the source code (using annotations) and these dependencies are injected into the dependent objects by an IoC container.
An IoC (Inversion of Control) container is responsible for creating and managinging application objects, and injecting dependencies based on the configuration information. This relieves developers of the responsibility to manage application objects and inject dependencies; therefore, inverting the control of managing application objects and injecting dependencies.
Spring framework consists of an IoC container which is responsible for reading configuration information from an application context XML file, creating and managing application objects and injecting dependencies.