May 23, 2019
Hot Topics:

Embedding Apache Pluto

  • November 11, 2005
  • By David DeWolf
  • Send Email »
  • More Articles »

Embedding 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

Implementing the PortletContainerService involved implementing an instance of javax.portlet.PortalContext, and org.apache.pluto.service.PortalCallbackService. Implementing the PortalContext is rather straightforward. It simply requires the implementation of several methods used to retrieve general environment information such as custom portal properties and supported portlet modes and window states. The PortalCallbackService provides a mechanism for the portlet container to interact with the Portal. The container utilizes this service to set a portlet title, manipulate portal and request properties, and generate URLs that can be translated by the embedding application.

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 =
PortletContainer container = factory.createContainer(
   "My Container Name", impl
// Step 3) Initialize the Container with the embedding
//         application's ServletContext

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.

Service Method Description
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.
doRenderResults 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.

About the Author

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 author@daviddewolf.com.

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date