net.sf.jportlet.impl
Class PortletContextImpl

java.lang.Object
  |
  +--net.sf.jportlet.impl.PortletContextImpl
All Implemented Interfaces:
PortletContext, javax.servlet.ServletContext

public class PortletContextImpl
extends java.lang.Object
implements PortletContext

Implementation of net.fs.jportlet.portlet.PortletContext

Author:
Herve Tchepannou

Constructor Summary
PortletContextImpl(net.sf.jportlet.portlet.application.PortletProxy proxy, net.sf.jportlet.portlet.application.PortletApplication application, javax.servlet.ServletContext servletContext)
           
 
Method Summary
 net.sf.jportlet.portlet.application.PortletApplication getApplication()
           
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration getAttributeNames()
           
 javax.servlet.ServletContext getContext(java.lang.String name)
          Not supported function.
 java.lang.String getInitParameter(java.lang.String name)
           
 java.util.Enumeration getInitParameterNames()
           
 net.sf.jportlet.portlet.PortletLog getLog()
          Returns the portlet log which allows the portlet to write debug, informational, warning, or error messages to a log
 int getMajorVersion()
           
 java.lang.String getMimeType(java.lang.String file)
           
 int getMinorVersion()
           
 javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)
          Not supported function.
 java.lang.String getRealPath(java.lang.String path)
           
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
          Not supported function.
 java.net.URL getResource(java.lang.String path)
           
 java.io.InputStream getResourceAsStream(java.lang.String path)
           
 java.io.InputStream getResourceAsStream(java.lang.String path, net.sf.jportlet.portlet.Client client)
          Returns the resource located at the given path (inside the portlet context) as an InputStream for a given client device , or null if the resource not found.
 java.io.InputStream getResourceAsStream(java.lang.String path, net.sf.jportlet.portlet.Client client, java.util.Locale locale)
          Returns the resource located at the given path (inside the portlet context) as an java.io.InputStream for a given client device and Locale, or null if the resource not found.
 java.lang.String getResourcePath(java.lang.String path, net.sf.jportlet.portlet.Client client)
          Return the path of a resource for a given client device , or null if the resource not found.
 java.lang.String getResourcePath(java.lang.String path, net.sf.jportlet.portlet.Client client, java.util.Locale locale)
          Return the path of a resource for a given client device and Locale, or null if the resource not found.
 java.util.Set getResourcePaths(java.lang.String path)
           
 java.lang.String getServerInfo()
           
 net.sf.jportlet.service.PortletService getService(java.lang.String name)
          This function looks up a portlet service with the given classname.
 javax.servlet.Servlet getServlet(java.lang.String arg0)
           
 javax.servlet.ServletContext getServletContext()
           
 java.lang.String getServletContextName()
           
 java.util.Enumeration getServletNames()
           
 java.util.Enumeration getServlets()
           
 java.lang.String getText(java.lang.String key, java.util.Locale locale)
          Returns the localized text resource with the given key and using the given locale.
 void include(java.lang.String path, net.sf.jportlet.portlet.PortletRequest request, net.sf.jportlet.portlet.PortletResponse response)
          Allows the portlet to render a resource as specified by the given path (inside the portlet context).
 void log(java.lang.Exception cause, java.lang.String message)
           
 void log(java.lang.String message)
           
 void log(java.lang.String message, java.lang.Throwable cause)
           
 void removeAttribute(java.lang.String name)
           
 void send(java.lang.String portletName, java.lang.Object message, net.sf.jportlet.portlet.PortletRequest request, net.sf.jportlet.portlet.PortletResponse response)
          Send a message to a portlet.
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortletContextImpl

public PortletContextImpl(net.sf.jportlet.portlet.application.PortletProxy proxy,
                          net.sf.jportlet.portlet.application.PortletApplication application,
                          javax.servlet.ServletContext servletContext)
Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface PortletContext
See Also:
ServletContext.getAttribute(java.lang.String)

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface PortletContext
See Also:
ServletContext.getAttributeNames()

getContext

public javax.servlet.ServletContext getContext(java.lang.String name)
Not supported function. This method throws a RuntimeException

Specified by:
getContext in interface javax.servlet.ServletContext
Throws:
java.lang.RuntimeException
See Also:
ServletContext.getContext(java.lang.String)

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Specified by:
getInitParameter in interface PortletContext
See Also:
ServletContext.getInitParameter(java.lang.String)

getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Specified by:
getInitParameterNames in interface PortletContext
See Also:
ServletContext.getInitParameterNames()

getLog

public net.sf.jportlet.portlet.PortletLog getLog()
Description copied from interface: PortletContext
Returns the portlet log which allows the portlet to write debug, informational, warning, or error messages to a log

Specified by:
getLog in interface PortletContext
See Also:
PortletContext.getLog()

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface javax.servlet.ServletContext
See Also:
ServletContext.getMajorVersion()

getMimeType

public java.lang.String getMimeType(java.lang.String file)
Specified by:
getMimeType in interface javax.servlet.ServletContext
See Also:
ServletContext.getMimeType(java.lang.String)

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface javax.servlet.ServletContext
See Also:
ServletContext.getMinorVersion()

getNamedDispatcher

public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)
Not supported function. This method throws a RuntimeException

Specified by:
getNamedDispatcher in interface javax.servlet.ServletContext
Throws:
java.lang.RuntimeException
See Also:
ServletContext.getNamedDispatcher(java.lang.String)

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Specified by:
getRealPath in interface javax.servlet.ServletContext
See Also:
ServletContext.getRealPath(java.lang.String)

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
Not supported function. This method throws a RuntimeException

Specified by:
getRequestDispatcher in interface javax.servlet.ServletContext
Throws:
java.lang.RuntimeException
See Also:
ServletContext.getRequestDispatcher(java.lang.String)

getResource

public java.net.URL getResource(java.lang.String path)
                         throws java.net.MalformedURLException
Specified by:
getResource in interface javax.servlet.ServletContext
java.net.MalformedURLException
See Also:
ServletContext.getResource(java.lang.String)

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Specified by:
getResourceAsStream in interface javax.servlet.ServletContext
See Also:
ServletContext.getResourceAsStream(java.lang.String)

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path,
                                               net.sf.jportlet.portlet.Client client)
Description copied from interface: PortletContext
Returns the resource located at the given path (inside the portlet context) as an InputStream for a given client device , or null if the resource not found. The resource are always searched first from the portlet classpath, and if not found, it will be searched from the portlet web module.

For example, if a web-browser request to the portlet com.foo.MyPortlet named myportlet the resource /template.vm, This function will search the following files until it found it:

  1. com/foo/html/myportlet/mytemplate.vm [classpath]
  2. com/foo/myportlet/mytemplate.vm [classpath]
  3. /PORTLET-INF/myportlet/html/mytemplate.vm [web-module]
  4. /PORTLET-INF/myportlet/mytemplate.vm [web-module]

Specified by:
getResourceAsStream in interface PortletContext
Parameters:
path - Path of the requested resource
client - Information about the client device
Returns:
InputStream
See Also:
PortletContext.getResourceAsStream(java.lang.String, net.sf.jportlet.portlet.Client)

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path,
                                               net.sf.jportlet.portlet.Client client,
                                               java.util.Locale locale)
Description copied from interface: PortletContext
Returns the resource located at the given path (inside the portlet context) as an java.io.InputStream for a given client device and Locale, or null if the resource not found. The resource are always searched first from the portlet classpath, and if not found, it will be searched from the portlet web module.

For example, if a web-browser from US request to the portlet com.foo.MyPortlet named myportlet the resource /template.vm, This function will search the following files until it found it:

  1. com/foo/html/mytemplate_en_US.vm [classpath]
  2. com/foo/html/mytemplate_en.vm [classpath]
  3. com/foo/html/mytemplate.vm [classpath]
  4. com/foo/mytemplate.vm [classpath]
  5. /PORTLET-INF/myportlet/html/mytemplate_en_US.vm [web-module]
  6. /PORTLET-INF/myportlet/html/mytemplate_en.vm [web-module]
  7. /PORTLET-INF/myportlet/html/mytemplate.vm [web-module]
  8. /PORTLET-INF/myportlet/mytemplate.vm [web-module]

Specified by:
getResourceAsStream in interface PortletContext
Parameters:
path - resource path
client - client
locale - locale
Returns:
InputStream
See Also:
PortletContext.getResourceAsStream(java.lang.String, net.sf.jportlet.portlet.Client, java.util.Locale)

getResourcePaths

public java.util.Set getResourcePaths(java.lang.String path)
Specified by:
getResourcePaths in interface javax.servlet.ServletContext
See Also:
ServletContext.getResourcePaths(java.lang.String)

getServerInfo

public java.lang.String getServerInfo()
Specified by:
getServerInfo in interface javax.servlet.ServletContext
See Also:
ServletContext.getServerInfo()

getService

public net.sf.jportlet.service.PortletService getService(java.lang.String name)
                                                  throws PortletServiceUnavailableException,
                                                         PortletServiceNotFoundException
Description copied from interface: PortletContext
This function looks up a portlet service with the given classname.

Specified by:
getService in interface PortletContext
Parameters:
name - name of the service
Returns:
PortletService
Throws:
PortletServiceNotFoundException - if the service not found
PortletServiceUnavailableException - if an exception has occurrred that interferes with the portlet service's normal initialization
See Also:
PortletContext.getService(java.lang.String)

getServlet

public javax.servlet.Servlet getServlet(java.lang.String arg0)
                                 throws javax.servlet.ServletException
Specified by:
getServlet in interface javax.servlet.ServletContext
javax.servlet.ServletException
See Also:
ServletContext.getServlet(java.lang.String)

getServletContextName

public java.lang.String getServletContextName()
Specified by:
getServletContextName in interface javax.servlet.ServletContext
See Also:
ServletContext.getServletContextName()

getServletNames

public java.util.Enumeration getServletNames()
Specified by:
getServletNames in interface javax.servlet.ServletContext
See Also:
ServletContext.getServletNames()

getServlets

public java.util.Enumeration getServlets()
Specified by:
getServlets in interface javax.servlet.ServletContext
See Also:
ServletContext.getServlets()

getText

public java.lang.String getText(java.lang.String key,
                                java.util.Locale locale)
Description copied from interface: PortletContext
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

Specified by:
getText in interface PortletContext
Parameters:
key - key of the text
locale - target locale
Returns:
String
See Also:
PortletContext.getText(java.lang.String, java.util.Locale)

include

public void include(java.lang.String path,
                    net.sf.jportlet.portlet.PortletRequest request,
                    net.sf.jportlet.portlet.PortletResponse response)
             throws PortletException,
                    java.io.IOException
Description copied from interface: PortletContext
Allows the portlet to render a resource as specified by the given path (inside the portlet context). This function is doing a kind of Server Side Include

For example, For the portlet com.foo.MyPortlet named myportlet, a file /template.vm will be searched for in the following order, when accessing via HTML-Browser:

  1. com/foo/html/mytemplate_en_US.vm [classpath]
  2. com/foo/html/mytemplate_en.vm [classpath]
  3. com/foo/html/mytemplate.vm [classpath]
  4. com/foo/mytemplate.vm [classpath]
  5. /PORTLET-INF/myportlet/html/en/US/mytemplate.vm [web-module]
  6. /PORTLET-INF/myportlet/html/en/mytemplate.vm [web-module]
  7. /PORTLET-INF/myportlet/html/mytemplate.vm [web-module]
  8. /PORTLET-INF/myportlet/mytemplate.vm [web-module]

Specified by:
include in interface PortletContext
Parameters:
path - path of the file to include
request - request of the portlet
response - response of the portlet
Throws:
PortletException - if any other error
java.io.IOException - if any IO error
See Also:
PortletContext.include(java.lang.String, net.sf.jportlet.portlet.PortletRequest, net.sf.jportlet.portlet.PortletResponse)

log

public void log(java.lang.Exception cause,
                java.lang.String message)
Specified by:
log in interface javax.servlet.ServletContext
See Also:
ServletContext.log(java.lang.Exception, java.lang.String)

log

public void log(java.lang.String message)
Specified by:
log in interface javax.servlet.ServletContext
See Also:
ServletContext.log(java.lang.String)

log

public void log(java.lang.String message,
                java.lang.Throwable cause)
Specified by:
log in interface javax.servlet.ServletContext
See Also:
ServletContext.log(java.lang.String, java.lang.Throwable)

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface PortletContext
See Also:
ServletContext.removeAttribute(java.lang.String)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Specified by:
setAttribute in interface PortletContext
See Also:
ServletContext.setAttribute(java.lang.String, java.lang.Object)

send

public void send(java.lang.String portletName,
                 java.lang.Object message,
                 net.sf.jportlet.portlet.PortletRequest request,
                 net.sf.jportlet.portlet.PortletResponse response)
          throws PortletException
Description copied from interface: PortletContext
Send a message to a portlet. If the portletName not specified, this method will broadcast the message to all portlets

Specified by:
send in interface PortletContext
Parameters:
portletName - name of the portlet
message - message to send
request -
response -
Throws:
PortletException
See Also:
PortletContext.send(String, Object, PortletRequest, PortletResponse)

getApplication

public net.sf.jportlet.portlet.application.PortletApplication getApplication()

getServletContext

public javax.servlet.ServletContext getServletContext()
Returns:
ServletContext

getResourcePath

public java.lang.String getResourcePath(java.lang.String path,
                                        net.sf.jportlet.portlet.Client client,
                                        java.util.Locale locale)
Description copied from interface: PortletContext
Return the path of a resource for a given client device and Locale, or null if the resource not found. See #getResourcePath() to understand how the container find the requested resource

Specified by:
getResourcePath in interface PortletContext
Parameters:
path - resource path
client - client
locale - locale
Returns:
See Also:
PortletContext.getResourcePath(java.lang.String, net.sf.jportlet.portlet.Client, java.util.Locale)

getResourcePath

public java.lang.String getResourcePath(java.lang.String path,
                                        net.sf.jportlet.portlet.Client client)
Description copied from interface: PortletContext
Return the path of a resource for a given client device , or null if the resource not found. See #getResourcePath() to understand how the container find the requested resource

Specified by:
getResourcePath in interface PortletContext
Parameters:
path - resource path
client - client
Returns:
String
See Also:
PortletContext.getResourcePath(java.lang.String, net.sf.jportlet.portlet.Client)


Copyright © 2002 Herve Tchepannou. All Rights Reserved.