org.apache.jetspeed.portal
Interface Portlet

All Known Implementing Classes:
AbstractPortlet

public interface Portlet

The Portlet interface is used by the portlet container to invoke the portlet. Every portlet has to derive directly or indirectly from this interface.

A portlet is a small Java program that runs withing a portal server. Portlets receive and respond to requests from the portal container. As part of running within the portal server each portal has a life-cycle. The corresponding methods are called in the following sequence:

  1. The portlet is constructed, then initialized with the init() method.
  2. Any calls from the portal server to service() method are handled.
  3. The portlet is taken out of service, then destroyed with the destroy() method, then garbage collected and finalized.

In addition to the life-cycle methods, this interface provides the getPortletConfig() method which allows the portlet can use to get any startup information, and the getServletInfo() method which allows the portlet to return basic information about itself, such as author, version, and copyright.

See Also:
PortletConfig

Method Summary
 void destroy()
          Called by the portlet container to indicate to this portlet that it is being taken out of service.
 PortletConfig getPortletConfig()
          Returns the configuration of this portlet.
 java.lang.String getPortletInfo()
          Returns information about the servlet, such as author, version, and copyright.
 void init(PortletConfig aConfig)
          Called by the portlet container to indicate to this portlet that it is being placed into service.
 void service(PortletRequest aRequest, PortletResponse aResponse)
          The service method is called by the framework to ask this portlet to render its content using the given context.
 

Method Detail

getPortletInfo

public java.lang.String getPortletInfo()
Returns information about the servlet, such as author, version, and copyright.

The string that this method returns should be plain text and not markup of any kind (such as HTML, XML, etc.).

Returns:
the portlet information

getPortletConfig

public PortletConfig getPortletConfig()
Returns the configuration of this portlet.
Returns:
the configuration

init

public void init(PortletConfig aConfig)
          throws PortletException
Called by the portlet container to indicate to this portlet that it is being placed into service.

The portlet container calls the init() method exactly once after instantiating the portlet. The init() method must complete successfully before the servlet can receive any requests.

The portlet container cannot place the portlet into service if the init() method

  1. Throws a PortletException
  2. Does not return within a time period defined by the portal server
Parameters:
aConfig - the portlet configuration containing the portlet's configuration and initialization parameters
Throws:
PortletException - if an exception has occurrred that interferes with the portlet's normal initialization
See Also:
PortletConfig.getPortletContext()

destroy

public void destroy()
Called by the portlet container to indicate to this portlet that it is being taken out of service. This method is only called once all threads within the portlet's service()method have exited or after a timeout period has passed. After the portlet container calls this method, it will not call the service() method again on this portlet.

This method gives the portlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the portlet's current state in memory.


service

public void service(PortletRequest aRequest,
                    PortletResponse aResponse)
             throws PortletException,
                    java.io.IOException
The service method is called by the framework to ask this portlet to render its content using the given context.

The context is the portlet's view of the framework. All that is required to perform the rendering of the content is accessible through the context.

Please note that every portlet gets passed a different context.

Parameters:
aRequest - the request
aResponse - the respnse
Throws:
PortletException - if the portlet has trouble fulfilling the service request
java.io.IOException - if the streaming causes an I/O problem