| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object HttpServlet com.ibm.wps.pe.pc.legacy.cache.CacheablePortlet org.apache.jetspeed.portlet.Portlet
public abstract class Portlet
The abstract Portlet is used by the portlet container to invoke the portlet. Every portlet has to implement this abstract class, either by deriving directly from it, or by using one of the abstract portlet implementations.
A portlet is a small Java program that runs within a portlet container. Portlets receive and respond to requests from the portlet container. There is ever only one portlet object instance per portlet configuration in the web deployment descriptor. There may be many PortletSettings objects parametersing the same portlet object according to the Flyweight pattern, provided on a per-request basis. A concrete parameterization of a portlet object is referred to as a concrete portlet. The settings of concrete portlets may change at any time caused by administrators modifying portlet settings, e.g. using the config mode of a portlet.
Additionally, user can have personal views of concrete portlets. Therefore, the transient portlet session and persistent concrete portlet data carries vital information for the portlet to create a personalized user experience. A concrete portlet in conjunction with portlet data creates a concrete portlet instance. This is similar to why a servlet may not store things depending on requests or sessions in instance variables. As a consequence, the portlet should not attempt to store any data that depends on portlet settings, portlet data or the portlet session or any other user-related information as instance or class variables. The general programming rules for servlets also apply to portlets - instance variables should only used when the intent is to share them between all the parallel threads that concurrently execute a portlet, and portlet code should avoid synchronization unless absolutely required.
As part of running within the portlet container each portlet has a life-cycle. The corresponding methods are called in the following sequence:
The concrete portlet instance is created and destroyed with the login() and logout() methods, respectively. If a portlet provides personalized views these methods should be implemented.
The portlet container loads and instantiates the portlet class. This can happen during startup of the portal server or later, but no later then when the first request to the portlet has to be serviced. Also, if a portlet is taken out of service temporarily, for example while administrating it, the portlet container may finish the life-cycle before taking the portlet out of service. When the administration is done, the portlet will be newly initialized.
Note on serialization: The Portlet class and all subclasses are not serializable. The Portlet class indirectly extends the javax.servlet.http.HttpServlet class and therefore inherits the Serializable interface from this class. All portlets therefore implement the Serializable interface, but nevertheless they must not be serialized. Attempting to serialize or deserialize a portlet will result in an UnsupportedOperationException.
Serialization cannot be supported because the lifecycle of a portlet is managed by the portal. A portlet that is deserialized again is not under the control of the portal and therefore its runtime properties are in an undefined state, so it is not possible to access the portlet.
Nested Class Summary | |
---|---|
static class | Portlet.Mode
Deprecated. The Mode class is a finite enumeration of the possible modes that a portlet can assume. |
static class | Portlet.ModeModifier
Deprecated. The ModeModifier class is a finite enumeration of the possible modifications a portlet can apply on modes. |
Constructor Summary | |
---|---|
Portlet()
Deprecated. |
Method Summary | |
---|---|
void | destroy()
Deprecated. |
abstract void | destroy(PortletConfig config)
Deprecated. Called by the portlet container to indicate to this portlet that it is taken out of service. |
abstract void | destroyConcrete(PortletSettings settings)
Deprecated. Called by the portlet container to indicate that the concrete portlet is taken out of service. |
protected void | doGet(HttpServletRequest req,
HttpServletResponse resp)
Deprecated. |
protected void | doPost(HttpServletRequest req,
HttpServletResponse resp)
Deprecated. |
protected void | doPut(HttpServletRequest req,
HttpServletResponse resp)
Deprecated. |
java.lang.String | getId(javax.servlet.http.HttpServletRequest request)
Deprecated. This method is used by the WebSphere Dynacache to generate a cache ID. |
java.lang.String | getInitParameter(java.lang.String name)
Deprecated. |
java.util.Enumeration | getInitParameterNames()
Deprecated. |
abstract long | getLastModified(PortletRequest request)
Deprecated. Returns the time the response of the Portlet
object was last modified,
in milliseconds since midnight January 1, 1970 GMT.
|
abstract PortletConfig | getPortletConfig()
Deprecated. Returns the PortletConfig object of the portlet |
protected PortletSettings | getPortletSettings()
Deprecated. since 5.1, use PortletRequest.getPortletSettings instead. A single instance of a portlet may reference multiple concrete portlets; without a reference to a portlet request, it is not always possible to determine the correct concrete portlet |
ServletContext | getServletContext()
Deprecated. |
java.lang.String | getServletInfo()
Deprecated. |
abstract void | init(PortletConfig config)
Deprecated. Called by the portlet container to indicate to this portlet that it is put into service. |
abstract void | initConcrete(PortletSettings settings)
Deprecated. Called by the portlet container to indicate that the concrete portlet is put into service. |
abstract void | login(PortletRequest request)
Deprecated. Called by the portlet container before the service() method of this portlet is invoked for the first time in the context of a new user session. |
abstract void | logout(PortletSession session)
Deprecated. Called by the portlet container when a user session terminates (by user logout or timeout) for which the login() method has been called before. |
abstract void | service(PortletRequest request,
PortletResponse response)
Deprecated. Called by the portlet container to ask this portlet to generate its markup using the given request/response pair. |
Methods inherited from class com.ibm.wps.pe.pc.legacy.cache.CacheablePortlet |
---|
getSharingPolicy |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Portlet()
Method Detail |
---|
public abstract void init(PortletConfig config) throws UnavailableException
The portlet container calls the init() method for the whole life-cycle of the portlet. The init() method must complete successfully before concrete portlets are created through the initConcrete() method.
The portlet container cannot place the portlet into service if the init() method
public abstract void destroy(PortletConfig config)
After the portlet container calls this method, it will not call the service() method or any listener methods 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).
public abstract void initConcrete(PortletSettings settings) throws UnavailableException
The portlet container calls the initConcrete() method before the service() method or any listener method is invoked for the portlet. The initConcrete() method must complete successfully before concrete portlet instances can be created through the login() method.
The portlet container cannot place the portlet into service if the initConcrete() method fails.
public abstract void destroyConcrete(PortletSettings settings)
This method gives the portlet an opportunity to clean up any resources that are being held (for example, memory, file handles, threads).
public abstract void service(PortletRequest request, PortletResponse response) throws PortletException, java.io.IOException
public abstract long getLastModified(PortletRequest request)
Portlet
object was last modified,
in milliseconds since midnight January 1, 1970 GMT.
If the time is unknown, this method returns a negative
number (the default).
Portlets that can quickly determine their last modification time should override this method. This makes browser and proxy caches work more effectively, reducing the load on server and network resources.
long
integer specifying
the time the response of the Portlet
object was last modified, in milliseconds
since midnight, January 1, 1970 GMT, or
-1 if the time is not knownpublic abstract PortletConfig getPortletConfig()
public abstract void login(PortletRequest request) throws PortletException
This method can be implemented by the portlet to initialize a personalized user experience. In addition to initializing the session this method allows the portlet to initialize the concrete portlet instance, for example, to store attributes in the session.
public abstract void logout(PortletSession session) throws PortletException
This method gives the concrete portlet instance an opportunity to clean up any resources (for example, memory, file handles, threads), before it is removed.
protected PortletSettings getPortletSettings()
public final java.lang.String getInitParameter(java.lang.String name)
public final java.util.Enumeration getInitParameterNames()
public ServletContext getServletContext()
public java.lang.String getServletInfo()
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
public void destroy()
public java.lang.String getId(javax.servlet.http.HttpServletRequest request)
| |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |