Embedding Apache Pluto
There are two approaches that can be taken to embed Pluto within an application. The first approach, directly embedding Pluto, provides the most flexibility, but also requires the embedding application to implement the PortletContainerServices. The second approach, utilizing the Pluto Portal Driver, allows users to take advantage of existing service implementations.
Directly Embedding Pluto
To directly embed Pluto, the embedding application must provide an implementation of the PortletContainerService, manage the Container Lifecycle, and properly invoke the container.
Providing a PortletContainerService Implementation
Managing the Container Lifecycle
Managing the container lifecycle is as simple as instantiating the container, initializing the container, holding an instance of the container for later invocation, and destroying the container upon application shutdown. The initialization of the container is exemplified in the following code:
// // Step 1) Create an instance of the PortletContainerService // PortletContainerServices impl = . . . // // Step 2) Request a new container from the container factory // PortletContainerFactory factory = PortletContainerFactory.getInstance(); PortletContainer container = factory.createContainer( "My Container Name", impl ); // // Step 3) Initialize the Container with the embedding // application's ServletContext // container.init(ctx);
Shutting down the container involves simply invoking the container's destroy() method during shutdown.
Invoking the Container
For the container to service a request, the embedding application must invoke its service methods by providing a PortletWindow implementation and the current servlet request and response. The PortletWindow defines the servlet context and portlet name of the portlet being requested. The following table details the available service methods and their functions.
|doLoad||Results in the specified portlet being loaded by the container. This call is not required and results in no content being written to the response.|
|doAction||Results in a portlet's invocation through a call to processAction. The result of this invocation is a redirect to a render request.|
|doRender||Results in a portlet's invocation through a call to render. The result of this invocation is markup written to the servlet response.|
Embedding Pluto with the Pluto Portal Driver
The Pluto Portal Driver implements the PortletContainerServices and several utilities that can be useful in embedding the Pluto container. Embedders not requiring custom implementations of complex items, such as the URL generators, may find these implementations sufficient within their applications.
The Pluto Portal Driver provides a set of Tag Libraries that can be utilized to embed portlets directly within JSP pages and a controller servlet that can be utilized to capture action requests and forward them to the container. These implementations can be leveraged to eliminate the majority of work required in embedding the container.
Apache Pluto provides a lightweight container environment for leveraging the Portlet Specification within Web and portal applications. The Pluto container can be embedded within a Web application to support external integration with third parties or within a portal to provide standard portlet application support. Whatever the reason, Apache Pluto can be easily embedded either by direct invocation or utilizing the Pluto Portal Driver.
David DeWolf has been developing Web applications, portals, and portlet applications for six years. He is a member of the Apache Portals Project Management Committee and an active commiter to Apache Pluto, the reference implementation of the Portlet Specification. David currently works at Digital Focus, which provides software development, agile coaching, and IT consulting services to Fortune 1000 and medium-sized businesses. Contact David at email@example.com.
Page 2 of 2