001: /**
002: * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
003: * Use is subject to license terms.
004: */package __PACKAGE__;
005:
006: import java.io.IOException;
007:
008: import javax.portlet.Portlet;
009: import javax.portlet.PortletConfig;
010: import javax.portlet.PortletException;
011: import javax.portlet.PortletRequest;
012: import javax.portlet.ActionRequest;
013: import javax.portlet.ActionResponse;
014: import javax.portlet.RenderRequest;
015: import javax.portlet.RenderResponse;
016:
017: /**
018: * The <CODE>Portlet</CODE> interface is used by the portlet container to
019: * invoke the portlets. Every portlet has to implement this interface,
020: * either by directly implementing it, or by using an existing class
021: * implementing the Portlet interface.
022: * <P>
023: * A portlet is a Java technology based web component, managed by a portlet container, that
024: * processes requests and generates dynamic content. Portlets are used by portals as
025: * pluggable user interface components that provide a presentation layer to Information
026: * Systems.
027: * <p>
028: * The content generated by a portlet is called a fragment. A fragment is a piece of
029: * markup (e.g. HTML, XHTML, WML) adhering to certain rules and can be aggregated
030: * with other fragments to form a complete document. The content of a portlet is normally
031: * aggregated with the content of other portlets to form the portal page. The lifecycle of a
032: * portlet is managed by the portlet container.
033: * <P>
034: * The portlet container instanciates portlets, manages their lifecycle
035: * and invoking them to process requests. The lifecycle consists of:
036: * <ul>
037: * <li>initializing the portlet using using the <code>init</code> method
038: * <li>request processsing
039: * <li>taking the portlet out of service using the <code>destroy</code> method
040: * </ul>
041: * <p>
042: * Request processing is divided into two types:
043: * <ul>
044: * <li>action requests handled through the <code>processAction</code> method,
045: * to perform actions targeted to the portlet
046: * <li>render requests handled through the <code>render</code> method,
047: * to perform the render operation
048: * </ul>
049: */
050: public class __NAME__ implements Portlet {
051:
052: public __NAME__() {
053: }
054:
055: /**
056: * Calle_d by the portlet container to indicate to a portlet that the
057: * portlet is being placed into service.
058: *
059: * <p>The portlet container calls the <code>init</code>
060: * method exactly once after instantiating the portlet.
061: * The <code>init</code> method must complete successfully
062: * before the portlet can receive any requests.
063: *
064: * <p>The portlet container cannot place the portlet into service
065: * if the <code>init</code> method
066: * <ol>
067: * <li>Throws a <code>PortletException</code>
068: * <li>Does not return within a time period defined by the portlet container.
069: * </ol>
070: *
071: *
072: * @param config a <code>PortletConfig</code> object
073: * containing the portlet's
074: * configuration and initialization parameters
075: *
076: * @exception PortletException if an exception has occurred that
077: * interferes with the portlet's normal
078: * operation.
079: * @exception UnavailableException if the portlet is unavailable to perform init
080: *
081: *
082: */
083:
084: public void init(PortletConfig config) throws PortletException {
085: }
086:
087: /**
088: * Notifies this portlet that a client request is triggered by an action URL to
089: * this portlet.
090: * <p>
091: * Typically, in response to an action request, a portlet updates state
092: * based on the information sent in the action request parameters.
093: * In an action the portlet may:
094: * <ul>
095: * <il>issue a redirect
096: * <il>change its window state
097: * <il>change its portlet mode
098: * <il>change its persistent state
099: * <il>set render parameters
100: * </ul>
101: * <p>
102: * This method is only called if the portlet has created
103: * an action URL with <code>RenderResponse.createActionURL()</code>.
104: * <p>
105: * A client request triggered by an action URL translates into one
106: * action request and many render requests, one per portlet in the portal page.
107: * The action processing must be finished before the render requests
108: * can be issued.
109: *
110: * @param request
111: * the portlet request
112: * @param actionResponse
113: * the action response
114: * @exception PortletException
115: * if the portlet has problems fulfilling the
116: * request
117: * @exception UnavailableException
118: * if the portlet is unavailable to perform processAction
119: * @exception PortletSecurityException
120: * if the portlet cannot fullfill this request because of security reasons
121: * @exception IOException
122: * if the streaming causes an I/O problem
123: */
124: public void processAction(ActionRequest request,
125: ActionResponse actionResponse) throws PortletException,
126: java.io.IOException {
127: }
128:
129: /**
130: * Notifies this portlet to generate its markup using the
131: * given request/response pair. Depending
132: * on the the current state and the requesting client device,
133: * the markup might differ.
134: * <p>
135: * The state of a portlet may include, but is not restricted to:
136: * <ul>
137: * <il>the window state
138: * <il>the portlet portlet mode
139: * <il>render parameter
140: * <il>request attributes
141: * <il>preference data
142: * <il>session data
143: * </ul>
144: *
145: * @param request
146: * the portlet request
147: * @param response
148: * the render response
149: *
150: * @exception PortletException
151: * if the portlet has problems fulfilling the
152: * rendering request
153: * @exception UnavailableException
154: * if the portlet is unavailable to perform render
155: * @exception PortletSecurityException
156: * if the portlet cannot fullfill this request because of security reasons
157: * @exception IOException
158: * if the streaming causes an I/O problem
159: */
160:
161: public void render(RenderRequest request, RenderResponse response)
162: throws PortletException, java.io.IOException {
163: }
164:
165: /**
166: *
167: * Called by the portlet container to indicate to a portlet that the
168: * portlet is being taken out of service.
169: * <p>
170: * Before the portlet container calls the destroy method, it should
171: * allow any threads that are currently processing requests within
172: * the portlet object to complete execution. To avoid
173: * waiting forever, the portlet container can optionally wait for
174: * a predefined time before destroying the portlet object.
175: *
176: * <p>This method enables the portlet to do the following:
177: * <ul>
178: * <li>clean up any resources that it holds (for example, memory,
179: * file handles, threads)
180: * <li>make sure that any persistent state is
181: * synchronized with the portlet current state in memory.
182: * </ul>
183: */
184:
185: public void destroy() {
186: }
187: }
|