org.apache.jetspeed.portlet
Interface PortletContext


Deprecated. since 6.0. Support of the IBM portlet API may be removed in a future release of WebSphere Portal. Use of the Java Portlet API (javax.portlet) is recommended instead.

public interface PortletContext

The PortletContext interface defines a portlet's view of the web application within which each portlet is running. The PortletContext also allows a portlet to access resources available to it. Using the context, a portlet can access the portlet log, and obtain URL references to resources.

The scope of a portlet context is an entire web application (abstract porlet application) as for the correcponding servlet context. There is one portlet context per weba application per JVM.

Since:
4.1

Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Deprecated. Returns the attribute value with the given name, or null if no such attribute exists.
 java.util.Enumeration getAttributeNames()
          Deprecated. Returns an enumeration of the attribute names that this portlet context is aware of.
 java.lang.String getContainerInfo()
          Deprecated. Returns the name and version of the portlet container which the portlet is running in.
 java.lang.String getInitParameter(java.lang.String name)
          Deprecated. Returns the value of the context-wide initialization parameter with the given name, or null if the parameter does not exist.
 java.util.Enumeration getInitParameterNames()
          Deprecated. Returns the names of this contexts initialization parameters as an enumeration, or an empty enumeration if this context has no initialization parameters.
 PortletLog getLog()
          Deprecated. Returns the portlet log which allows the portlet to write debug, informational, warning, or error messages to a log.
 int getMajorVersion()
          Deprecated. Returns the major version of the Portlet API that this portlet container supports.
 int getMinorVersion()
          Deprecated. Returns the minor version of the Portlet API that this portlet container supports.
 java.io.InputStream getResourceAsStream(java.lang.String path)
          Deprecated. Returns the resource located at the given path as an InputStream object.
 java.io.InputStream getResourceAsStream(java.lang.String path, Client client, java.util.Locale locale)
          Deprecated. Returns the resource located at the given path as an InputStream object.
 PortletService getService(java.lang.Class service)
          Deprecated. This function looks up a portlet service with the given classname.
 java.lang.String getText(java.lang.String bundle, java.lang.String key, java.util.Locale locale)
          Deprecated. Returns the localized text resource with the given key and using the given locale.
 void include(java.lang.String path, PortletRequest request, PortletResponse response)
          Deprecated. Allows the portlet to delegate the rendering to another resource as specified by the given path.
 void removeAttribute(java.lang.String name)
          Deprecated. Removes the attribute with the given name.
 void send(java.lang.String portletName, DefaultPortletMessage message)
          Deprecated. Sends the given message to all portlets on the same page that have the given name regardless of the portlet application.
 void send(java.lang.String portletName, PortletMessage message)
          Deprecated. Sends the given message to all portlets in the same portlet application on the same page that have the given name.
 void send(java.lang.String portletName, PortletMessage message, PortletRequest request)
          Deprecated. since Version 1.1
 void setAttribute(java.lang.String name, java.lang.Object value)
          Deprecated. Associates an attribute with the given name and value with this context.
 

Method Detail

getInitParameter

java.lang.String getInitParameter(java.lang.String name)
Deprecated. 
Returns the value of the context-wide initialization parameter with the given name, or null if the parameter does not exist.

This method returns the same value as ServletContext#getInitParameter for a servlet in the same web application.

Parameters:
name - the parameter name
Returns:
the parameter value,
or null if it does not exist

getInitParameterNames

java.util.Enumeration getInitParameterNames()
Deprecated. 
Returns the names of this contexts initialization parameters as an enumeration, or an empty enumeration if this context has no initialization parameters.

This method returns the same values as ServletContext#getInitParameterNames for a servlet in the same web application.

Returns:
an enumeration of parameter names

setAttribute

void setAttribute(java.lang.String name,
                  java.lang.Object value)
Deprecated. 
Associates an attribute with the given name and value with this context.

This method has the same effect as ServletContext#setAttribute for a servlet in the same web application.

Parameters:
name - the attribute name
value - the attribute value

getAttribute

java.lang.Object getAttribute(java.lang.String name)
Deprecated. 
Returns the attribute value with the given name, or null if no such attribute exists.

This method returns the same value as ServletContext#getAttribute for a servlet in the same web application.

Parameters:
name - the attribute name
Returns:
the attribute value

getAttributeNames

java.util.Enumeration getAttributeNames()
Deprecated. 
Returns an enumeration of the attribute names that this portlet context is aware of.

This method returns the same values as ServletContext#getAttributeNames for a servlet in the same web application.

Returns:
an enumeration of attribute names

removeAttribute

void removeAttribute(java.lang.String name)
Deprecated. 
Removes the attribute with the given name.

This method has the same effect as ServletContext#removeAttribute for a servlet in the same web application.

Parameters:
name - the name of attribute to be removed

include

void include(java.lang.String path,
             PortletRequest request,
             PortletResponse response)
             throws PortletException,
                    java.io.IOException
Deprecated. 
Allows the portlet to delegate the rendering to another resource as specified by the given path. The path has to be relative and will be resolved by this method, so that the portlet's resources are accessed.

To access protected resources the path has to be prefixed with /WEB-INF/ (e.g. /WEB-INF/myportlet/myportlet.jsp). Otherwise, the direct path is used. (e.g. /myportlet/myportlet.jsp).

This method is enabled for multi-language and multi-device support. For example, a jsp file "/myportlet/mytemplate.jsp" will be searched for in the following order, when accessing via HTML-Browser:

  1. /myportlet/html/en_US/mytemplate.jsp
  2. /myportlet/html/en/mytemplate.jsp
  3. /myportlet/html/mytemplate.jsp
  4. /myportlet/mytemplate.jsp

Parameters:
path - the path of the delegate resource
request - the portlet request
response - the portlet response
Throws:
PortletException - if the delegated resource has trouble fulfilling the rendering request
java.io.IOException - if the streaming causes an I/O problem

getResourceAsStream

java.io.InputStream getResourceAsStream(java.lang.String path)
Deprecated. 
Returns the resource located at the given path as an InputStream object.

The data in the InputStream can be of any type or length. The method returns null if no resource exists at the given path.

To access protected resources the path has to be prefixed with /WEB-INF/ (e.g. /WEB-INF/myportlet/myportlet.jsp). Otherwise, the direct path is used. (e.g. /myportlet/myportlet.jsp).

Parameters:
path - the path to the resource
Returns:
the input stream

getResourceAsStream

java.io.InputStream getResourceAsStream(java.lang.String path,
                                        Client client,
                                        java.util.Locale locale)
Deprecated. 
Returns the resource located at the given path as an InputStream object.

The data in the InputStream can be of any type or length. The method returns null if no resource exists at the given path.

To access protected resources the path has to be prefixed with /WEB-INF/ (e.g. /WEB-INF/myportlet/myportlet.jsp). Otherwise, the direct path is used. (e.g. /myportlet/myportlet.jsp).

This method is enabled for multi-language and multi-device support. For example, a jsp file "/myportlet/mytemplate.jsp" will be searched for in the following order, when accessing via HTML-Browser:

  1. /myportlet/html/en_US/mytemplate.jsp
  2. /myportlet/html/en/mytemplate.jsp
  3. /myportlet/html/mytemplate.jsp
  4. /myportlet/mytemplate.jsp

Parameters:
path - the path to the resource
client - the client
locale - the locale
Returns:
the input stream

getText

java.lang.String getText(java.lang.String bundle,
                         java.lang.String key,
                         java.util.Locale locale)
Deprecated. 
Returns the localized text resource with the given key and using the given locale.

To use this feature, the portlet application's CLASSPATH has to contain a resource bundle with the same name (including the package) as the portlet.

Parameters:
bundle - the name of the resource bundle
key - the text key
locale - the locale to observe
Returns:
the localized text resource

send

void send(java.lang.String portletName,
          PortletMessage message,
          PortletRequest request)
          throws AccessDeniedException
Deprecated. since Version 1.1

Sends the given message to all portlets in the same portlet application on the same page that have the given name. If the portlet name is null the message is broadcast to all portlets in the same portlet application. If more than one instance of the portlet with the given name exists on the current page, the message is sent to every single instance of that portlet. If the source portlet has the same name as the target portlet(s), the message will not be sent to avoid possible cyclic calls.

The portlet(s) with the given name will only receive the message event if it has/they have implemented the appropriate listener.

This function may only be used during event processing, in any other case the method throws an AccessDeniedException.

Parameters:
portletName - the name of the portlet(s) that this
message - the message to be sent
request - the portlet request
Throws:
AccessDeniedException - if the portlet tries to access this function outside of the event processing

send

void send(java.lang.String portletName,
          PortletMessage message)
          throws AccessDeniedException
Deprecated. 
Sends the given message to all portlets in the same portlet application on the same page that have the given name. If the portlet name is null the message is broadcast to all portlets in the same portlet application. If more than one instance of the portlet with the given name exists on the current page, the message is sent to every single instance of that portlet. If the source portlet has the same name as the target portlet(s), the message will not be sent to avoid possible cyclic calls.

The portlet(s) with the given name will only receive the message event if it has/they have implemented the appropriate listener.

This function may only be used during event processing, in any other case the method throws an AccessDeniedException.

Parameters:
portletName - the name of the portlet(s) that this
message - the message to be sent
Throws:
AccessDeniedException - if the portlet tries to access this function outside of the event processing

send

void send(java.lang.String portletName,
          DefaultPortletMessage message)
          throws AccessDeniedException
Deprecated. 
Sends the given message to all portlets on the same page that have the given name regardless of the portlet application. If the portlet name is null the message is broadcast to all portlets on the same page across all portlet application. If more than one instance of the portlet with the given name exists on the current page, the message is sent to every single instance of that portlet. If the source portlet has the same name as the target portlet(s), the message will not be sent to avoid possible cyclic calls.

The portlet(s) with the given name will only receive the message event if it has/they have implemented the appropriate listener.

This function may only be used during event processing, in any other case the method throws an AccessDeniedException.

Parameters:
portletName - the name of the portlet(s) that this
message - the message to be sent
Throws:
AccessDeniedException - if the portlet tries to access this function outside of the event processing

getService

PortletService getService(java.lang.Class service)
                          throws PortletServiceUnavailableException,
                                 PortletServiceNotFoundException
Deprecated. 
This function looks up a portlet service with the given classname.

Using this method a portlet is able to get additional functionality like a service to get external content over a firewall or to include a servlet.

Parameters:
service - the classname of the service to load
Returns:
the portlet service
Throws:
PortletServiceUnavailableException - if an exception has occurrred that interferes with the portlet service's normal initialization
PortletServiceNotFoundException - if the PortletService is not found

getMajorVersion

int getMajorVersion()
Deprecated. 
Returns the major version of the Portlet API that this portlet container supports.

Returns:
the major version
See Also:
getMinorVersion()

getMinorVersion

int getMinorVersion()
Deprecated. 
Returns the minor version of the Portlet API that this portlet container supports.

Returns:
the minor version
See Also:
getMajorVersion()

getContainerInfo

java.lang.String getContainerInfo()
Deprecated. 
Returns the name and version of the portlet container which the portlet is running in.

The form of the returned string is servername/versionnumber. For the IBM Portal Server this method may return the string IBM WebSphere Portal Server/4.1.

Returns:
the string containing at least name and version number

getLog

PortletLog getLog()
Deprecated. 
Returns the portlet log which allows the portlet to write debug, informational, warning, or error messages to a log.

Returns:
the portlet log