Sun Java Solaris Communities My SDN Account Join SDN
 
Article

Open-Source Portal Initiative at Sun, Part 3: Portlet Container

 
By Deepak Gothe and Marina Sum, March 22, 2007  

The article Introducing Java Portlet Specifications: JSR 168 and JSR 286 describes portlets as Web-based components that enable integration between applications and portals and thus delivery of applications on portals. The heart of a portal is a portlet container, and as a servlet container is to servlets, so a portlet container is to portlets. Portlet containers execute portlets and manage their life cycle.

Java Portlet Specification 1.0, Java Specification Request (JSR) 168, establishes a standard API for creating portlets. An early draft of Java Portlet Specification 2.0 (JSR 286) is now in review.

Portlet Container 1.0 is Sun's implementation of JSR 168 Portlet Container for open source and has been available since December 2006. It is also part of Sun Java System Portal Server 6.x and 7.x, which moved to an open-source model in August 2006. In addition, as part of Java Application Platform SDK Update 2 and Update 3 Preview, Portlet Container 1.0 is integrated with Sun Java System Application Server Platform Edition (PE) 9.x.

Portlet Container 1.0 was developed for the Enterprise-Class Portlet Container Open Source Project (henceforth, Portlet Container Project), an offspring of the parent Portal Open Source Project.

This article, the third in a series, describes the Portlet Container Project's goals, contribution guidelines, and future directions. Also summarized are the capabilities, design, and distribution of Portlet Container 1.0. Further, this article explains how to install and deploy Portlet Container 1.0 so as to test portlets.

See the other parts of this series:

Contents
 
Goals
Design, Capabilities, and Binary
Installation
Portlet Deployment and Undeployment
NetBeans Portal Pack Project
Participation and Contribution Guidelines
Future Directions
References
 
Goals

The Portlet Container Project aims to achieve the following:

  • Expose the portlet container's mature and proven enterprise-class capabilities to the community and evolve it there through contributions from developers, users, partners, and like-minded individuals.

  • Accelerate the delivery cycle of bug fixes.

  • Foster the ubiquity of portal technology and provide a portlet container as a runtime component that is consumable, embeddable, and integratable in numerous environments, such as portal servers and development tools.
Design, Capabilities, and Binary

Recall that, in late 2006, the Portlet Container Project shipped Portlet Container 1.0, which includes a portlet driver. That driver is a lightweight—that is, without the overhead of an entire portal server—execution environment for deploying and testing portlets on top of the portlet container. In particular, the portlet driver is ideal for debugging, testing, and simulating portlets and serves as a stellar example of how you can integrate the portlet container into a portal.

In terms of workflow, 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 container contains two major components:

  • The container itself, which collects preferences and other data from the portal and handles caching

  • The portlet application engine, which calls the portlets through the Portlet API

For details on the portlet container's design, see the related document.

The key capabilities of Portlet Container 1.0 are threefold:

  • Support for parallel render requests

  • An extension to the standard Java portlet to enable interportlet communications

  • Integratability with systems for identity management, behavior tracking, logging, and user profiles

A binary of Portlet Container 1.0 is available from the Java EE Downloads site and from the Portlet Container Project download site.

Installation

This section describes how to install Portlet Container 1.0.

Currently, Portlet Container 1.0 supports automated installations on GlassFish versions 1 and 2 and Tomcat 5.5. This section describes how to install Portlet Container 1.0 on GlasshFish from the related GUI or on the command line. For details on how to install on Tomcat, see the related documentation.

Note: Type all the commands on one line even though some of them wrap to the next line because of page width constraints.

  1. Download the Portlet Container 1.0 binary.

  2. Install GlassFish.

  3. Install Portlet Container 1.0 from the GUI or from the command line.

    • From the GUI:

      a. Type:

      % java -jar portlet-container-configurator.jar

      Note: If you installed GlassFish as root on UNIX, execute the command lines as root.

      The installer is displayed. See Figure 1.

      Figure 1: Installer for Configuring Portlet Container 1.0
       
      b. Choose GlassFish from the Select Container drop-down menu and fill in the text fields with the appropriate information. Click OK.

    • From the command line:

      Type:

      % java -jar portlet-container-configurator.jar GlassFish-install-dir GlassFish-domain-dir

      where GlassFish-install-dir is the location in which you installed GlassFish and GlassFish-domain-dir is GlassFish's domain directory.

      For example:

      • On Windows, type:

        java -jar portlet-container-configurator.jar c:\glassfish c:\glassfish\domains\domain1

      • On UNIX, type:

        java -jar portlet-container-configurator.jar /usr/local/glassfish /usr/local/glassfish/domains/domain1

Afterward, do the following:

  1. Restart the Web container.

  2. Deploy and test the portlets: Go to http://hostname:portnumber/portletdriver, for example, http://localhost:8080/portletdriver.

    The Portlet Container Driver page is displayed along with two tabs at the top (see Figure 2):

    • Portlets, which you click to display portlets

    • Admin, which you click to deploy or undeploy the portlet application (see Figure 3)

      Figure 2: Portlet Container Driver Page
       
      Figure 3: Screen for Deploying Or Undeploying Portlets
       
Portlet Deployment and Undeployment

This section explains how to deploy a portlet, how to undeploy it, and how to create multiple windows for portlets.

Deploying Portlets
You can deploy portlets in one of three ways:

  • From the GUI — On the Portlet Container Driver page, click the Admin tab. Under Deploy a Portlet, in the Select Portal War File text field, type the path name of the portlet in and click Deploy.

  • On the command line — Type:

    % cd GlassFish-install-dir/domains/domain1/portlet-container/bin

    % ant deploy-portlet -Dportlet-war=portlet-WAR-filename.war

    Example: % ant deploy-portlet -Dportlet-war=HelloWorldPortlet.war

  • With autodeploy — Copy the portlet's Web archive (WAR) file to the GlassFish-install-dir/domains/domain1/portlet-container/autodeploy directory. After deploying the application, Portlet Container 1.0 creates a file named portlet-WAR-filename.deployed in that directory.

Afterward, Portlet Container 1.0 creates a portlet window with a thick width. Click the Portlets tab to display the portlet content in the window. Figure 4 is an example.

Figure 4: Example of Portlet Window
 

The window contains icons that support the portlet modes (View, Edit, and Help) and the window states (Maximize and Minimize).

Undeploying Portlets
You can undeploy portlets in one of three ways:

  • From the GUI — On the Portlet Container Driver page, click the Admin tab, select one or more portlets from the scrolling list under Undeploy Portlets, and click Undeploy.

  • On the command line — Type:

    % cd GlassFish-install-dir/domains/domain1/portlet-container/bin

    % ant undeploy-portlet -Dportlet-war=portlet-WAR-filename

    Example: % ant undeploy-portlet -Dportlet-war=HelloWorldPortlet

  • With autodeploy — Delete the portlet's WAR file from the GlassFish-install-dir/domains/domain1/portlet-container/autodeploy directory. After undeploying the application, Portlet Container 1.0 deletes the file portlet-WAR-filename.deployed from that directory.

Afterward, Portlet Container 1.0 deletes all the windows associated with the portlets and undeploys the portlet application from the application server, such as GlassFish.

Creating Multiple Portlet Windows
You can customize portlet preferences for portlet windows. Similarly, users can also personalize their window preferences. The default user supported is admin, the GlassFish administrator. Log in by clicking Sign In at the top.

To create a window for a portlet and set the related preferences:

  1. Click the Admin tab.

  2. Under Create a Portlet Window, select a portlet from the Select Base Portlet scrolling list and type the appropriate information in the Portlet Window Name and Portlet Title text fields.

    Afterward, Portlet Container 1.0 creates a portlet window with a thin width. Click the Portlets tab to display the portlet content in the window.

Repeat steps 1 and 2 for additional windows.

NetBeans Portal Pack Project

As a plug-in for the NetBeans IDE, the NetBeans Portal Pack Project supports the entire cycle of developing portlets in the NetBeans IDE. Thanks to the plug-in's capability of automatically generating code and deployment descriptors, you can efficiently develop, package, deploy, and test portlets in the NetBeans IDE. In addition, the plug-in is tightly integrated with Portlet Container 1.0 and Sun Java System Portal Server 7.x.

Do download and install the plug-in and try it out! As further reference, the article Developing Portlets with the NetBeans Portlet Plugin describes how to configure Portlet Container 1.0 in the Netbeans IDE and then build, deploy, and test a simple portlet on the configured container.

Participation and Contribution Guidelines

If you're new to the portal world, visit the Portlet Container Project site often to gain insight into how portal technology works behind the scenes. Portal developers are welcome to participate in the Portlet Container Project. You can do so in either of two ways:

  • Contribute to the ongoing development of the project, for example, in the upcoming JSR 286 implementation or in the areas of new capabilities, enhancements, or bug fixes. Concurrently, take advantage of the lightweight, user-friendly Portlet Container 1.0 runtime in developing portals.

    Contributors to the Portlet Container Project assume either of these two roles:

    • Developer — Developers serve as gatekeepers to the project, ensuring that only high-quality, stable changes are committed.

    • Observer — Observers contribute code by submitting it to the developers.

    The Portlet Container Project guidelines recommend that those interested in contributing start with the observer role. The process of then becoming a developer is simple: Act like one. If observers repeatedly demonstrate that they can function as developers, they can be nominated by a developer and voted in by other developers. For details, see the guidelines.

    Before contributors can have code accepted into the project, they must sign and return a contributor agreement. In brief, the agreement is their consent to share the rights to the code they contribute. Contributors should carefully read the details of the agreement.

  • Adopt Portlet Container 1.0, which is readily embeddable and consumable, in your enterprise portal or tool projects.
Future Directions

When the Java Portlet Specification 2.0 becomes available, the Portlet Container Project will undertake an implementation that adheres to that specification's standards. The first draft of JSR 286 includes the following capabilities:

  • Events — Enable portlets to communicate with each other through sending and receiving events.

  • Shared render parameters — Enable portlets to specify which render parameters they can share with other portlets.

  • Resource serving — Enables portlets to serve resources within the portlet context.

  • Portlet filter — Enables portlets to, on the fly, transform the content of portlet requests and responses.
References
Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.
The Portal Post
 
Download SDK

Deepak Gothe Deepak Gothe, a member of the Sun Java System Portal Server development team, joined Sun's India Engineering Center in Bangalore in September 2004. He is the technical lead for the Portlet Container and JavaServer Faces technology-based Portlet Bridge projects. Deepak blogs on a variety of topics.
 
Marina SumMarina Sum is a staff writer for Sun Developer Network. She has been writing for Sun since 1989, mostly in the technical arena. Marina blogs on Sun products, technologies, events, and publications.