|By Deepak Gothe, December 14, 2006; updated February 2008|
This article describes the Portlet Container 1.0.2 software that ships with the Java Application Platform SDK Update 4, including the deployment and undeployment of portlets using the Portlet Container. This article applies to both Portlet Container 1.0 (FCS - final release) and Portlet Container 1.0.2.
The Java Portlet Specification ( JSR 168) is a standard for developing portal components with the Java programming language. The Portlet Container 1.0.2 software that is part of Java Application Platform SDK Update 4 not only implements the Java Portlet Specification, but also provides a portlet driver, a lightweight portlet rendering environment. This driver simulates some capabilities of a typical portal product (like the Sun Java System Portal Server). This Portlet Container 1.0.2 software also provides an extension to the standard Java Portlet allowing Inter Portlet Communication, a Portlet Specification 2.0 feature ( JSR 286).
In the future, the Portlet Container will provide Portlet 2.0 implementation when available.
This article provides an introduction to the Portlet Container in Java Application Platform SDK Update 4. First, you get an overview of the basic architecture (Note: This architecture may change in future updates of Portlet Container), and then you see how to deploy a portlet.
Figure 1 depicts the basic architecture. The Portlet Driver processes the client request, retrieves the portlets to be displayed, and then calls the portlet container to retrieve each portlet's content. The Portlet Driver accesses the Portlet Container with the Container API. The Portlet Container is composed of two major components: a portlet container component and a portlet application engine component. The portlet container component is only responsible for gathering preference and data from the portal and handling caching. The remainder of the work of providing an execution environment is delegated to the portlet application engine component. Finally, the portlet application engine component calls all portlets via the Portlet API.
The Portlet Driver is a simple environment to develop and test a portlet since there is no SPI to run the Portlet Container. The Portlet Driver retrieves the portlet markup fragments by delegating portlet execution to the Portlet Container via the container interface. It also provides the implementation for the PreferenceManager, CacheManager, PortalDataContext, and PortletEventDataContext interfaces defined by the Portlet Container.
The container interface defines the rules of interaction between the Portlet Driver and the Portlet Container.
The Portlet Container implements the container interface. It is responsible for creating the execution environment for the portlets. However as mentioned above, the Portlet Container component will only do the work of caching content and assembling preferences and portal information. Once it collects the information, it will delegate the request to the portlet application engine for further processing via the Request Dispatcher mechanism. Following is a list of interfaces defined by the Portlet Container component.
The preference manager is responsible for gathering preference information from the driver.
The cache manager is responsible for caching view content in the normal state.
The portal data context is responsible for gathering information such as title of the portlet window, locale, user information, and content type from the driver.
The portlet event data context is responsible for gathering the data related to the Portlet Events. The information includes the list of portlets that participate in eventing and also the list of events for the portlet.
The portlet application engine is the component that creates an execution environment for the portlets. It is composed of the portlet application engine servlet, the lifecycle manager, and the request response factory. These pieces create an environment where portlets are executed.
The portlet application engine servlet is the entry point into the portlet application engine. It receives requests for portlet processing from the portlet container via the Request Dispatcher. Upon receiving the request, it asks the lifecycle manager for an instance of the portlet and asks the request response factory to manufacture request and response, and finally it executes the portlet. Once the execution is complete, it returns the results back to the portlet container.
Lifecycle manager handles the creation, initialization, and destruction of portlets.
The request response factory is responsible for creating ActionRequest, ActionResponse, RenderRequest, RenderResponse, EventRequest, and EventResponse objects. In order to optimize, it may maintain a pool of reusable request and response objects.
The Portlet Container supports eventing between portlets. Events may be passed between portlets that are in the same or different web applications. It uses event generation and notification to convey the information/data among portlets. Check docs for more details on Inter Portlet Communication.
When a portlet web application is deployed, the Portlet Deployment performs three tasks:
The Portlet Container is bundled in Java Application Platform SDK Update 4. During the installation of the Java Application Platform SDK Update 4 software, select Portlet Container. After the installation is complete, simply start the Application Server and access the Portlet Container.
It has two tabs, Portlets and Admin. The Portlets tab shows the portlet. In the Admin tab, one can deploy or undeploy the portlet application.
On the Admin tab (under Deploy Portlet), enter the path name of the portlet and select deploy. The portlet will be deployed, and a portlet window with a thick width will be created.
Click on the Portlets tab to see the portlet content in the portlet window. The Portlet Window provides window decorations that support Portlet modes, VIEW, EDIT, and HELP and Window States, MAXIMIZE and MINIMIZE.
There are three ways to deploy the portlet.
After the portlet is deployed successfully, a portlet window with a thick width will be created. Click on the Portlets tab to see the portlet content in the portlet window. The Portlet Window provides window decorations that support Portlet modes, VIEW, EDIT, and HELP and Window States, MAXIMIZE and MINIMIZE.
On the Admin tab (under Undeploy Portlet), select a portlet to undeploy (you can select multiple). After a successful undeployment, all the portlet windows associated with the portlet will be removed, and the portlet web application will be undeployed from the application server.
There are three ways to undeploy portlets.
After a successful undeployment, all the portlet windows associated with the portlet will be removed, and the portlet web application will be undeployed from the application server.
Multiple portlet windows can be created based on the same portlet. On the Admin tab (under Create Portlet Window), select a base portlet, and enter the name of the portlet window and the title for the portlet window. The portlet window created will have a thin width. Click on the Portlets tab to see the portlet content in the portlet window.
FORM-based authentication is used to authenticate the user. The default user supported is the AppServer admin user.
Portlet Preferences are stored per user and per portlet window.
This article has described the Portlet Container 1.0.2 software that ships with the Java Application Platform SDK Update 4, including the deployment and undeployment of portlets using the Portlet Container.