org.apache.cocoon.portlet
Class CocoonPortlet

java.lang.Object
  extended by javax.portlet.GenericPortlet
      extended by org.apache.cocoon.portlet.CocoonPortlet
All Implemented Interfaces:
javax.portlet.Portlet, javax.portlet.PortletConfig

public class CocoonPortlet
extends javax.portlet.GenericPortlet

This is the entry point for Cocoon execution as an JSR-168 Portlet.

Version:
CVS $Id: CocoonPortlet.html 1304258 2012-03-23 10:09:27Z ilgrosso $

Field Summary
protected static boolean ALLOW_RELOAD
          Default value for allowReload parameter (false)
protected  boolean allowReload
          Allow reloading of cocoon by specifying the cocoon-reload=true parameter with a request
protected  DefaultContext appContext
          Avalon application context
protected  ClassLoader classLoader
          The classloader that will be set as the context classloader if init-classloader is true
protected  Cocoon cocoon
          The Cocoon instance
static String CONTEXT_PORTLET_CONFIG
          Application Context Key for the portlet configuration
protected  long creationTime
          The time the cocoon instance was created
protected  int defaultSessionScope
          Default scope for the session attributes, either PortletSession.PORTLET_SCOPE or PortletSession.APPLICATION_SCOPE.
protected  Exception exception
          Holds exception happened during initialization (if any)
protected  String forceLoadParameter
           
protected  String forceSystemProperty
           
protected  boolean hiddenShowTime
          If true, processing time will be added as an HTML comment
protected  boolean initClassLoader
           
protected  javax.portlet.PortletContext portletContext
           
protected  String portletContextPath
          This is the path to the portlet context (or the result of calling getRealPath('/') on the PortletContext.
protected  String portletContextURL
          This is the url to the portlet context directory
protected static String PROCESSED_BY
           
protected  RequestFactory requestFactory
          The RequestFactory is responsible for wrapping multipart-encoded forms and for handing the file payload of incoming requests
protected  String servletPath
          Value to be used as servletPath in the request.
protected  boolean showTime
          Allow adding processing time to the response
protected  boolean storeSessionPath
          Store pathInfo in session
 
Constructor Summary
CocoonPortlet()
           
 
Method Summary
protected  void addClassLoaderDirectory(String dir)
          Adds a directory to the classloader.
protected  void addClassLoaderURL(URL URL)
          Adds an URL to the classloader.
 void destroy()
          Dispose Cocoon when portlet is destroyed
protected  String getClassPath()
          This builds the important ClassPath used by this Portlet.
protected  Environment getEnvironment(String servletPath, String pathInfo, String uri, javax.portlet.ActionRequest req, javax.portlet.ActionResponse res)
          Create the environment for the request
protected  Environment getEnvironment(String servletPath, String pathInfo, String uri, javax.portlet.RenderRequest req, javax.portlet.RenderResponse res)
          Create the environment for the request
protected  String getExtraClassPath()
          Retreives the "extra-classpath" attribute, that needs to be added to the class path.
 String getInitParameter(String name)
          Get an initialisation parameter.
protected  String getInitParameter(String name, String defaultValue)
          Convenience method to access portlet parameters
protected  boolean getInitParameterAsBoolean(String name, boolean defaultValue)
          Convenience method to access boolean portlet parameters
protected  int getInitParameterAsInteger(String name, int defaultValue)
           
protected  Logger getLogger()
           
protected  LoggerManager getLoggerManager()
           
protected  ComponentManager getParentComponentManager()
          Instatiates the parent component manager, as specified in the parent-component-manager init parameter.
 void init(javax.portlet.PortletConfig conf)
          Initialize this CocoonPortlet instance.
protected  void initLogger()
          Set up the log level and path.
protected  void manageException(javax.portlet.ActionRequest req, javax.portlet.ActionResponse res, Environment env, String uri, String title, String message, String description, Exception e)
           
protected  void manageException(javax.portlet.RenderRequest req, javax.portlet.RenderResponse res, Environment env, String uri, String title, String message, String description, Exception e)
           
 void processAction(javax.portlet.ActionRequest req, javax.portlet.ActionResponse res)
          Process the specified ActionRequest producing output on the specified ActionResponse.
 void render(javax.portlet.RenderRequest req, javax.portlet.RenderResponse res)
          Process the specified RenderRequest producing output on the specified RenderResponse.
protected  void updateEnvironment()
          Method to update the environment before Cocoon instances are created.
 
Methods inherited from class javax.portlet.GenericPortlet
doDispatch, doEdit, doHelp, doView, getInitParameterNames, getPortletConfig, getPortletContext, getPortletName, getResourceBundle, getTitle, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_PORTLET_CONFIG

public static final String CONTEXT_PORTLET_CONFIG
Application Context Key for the portlet configuration

Since:
2.1.3
See Also:
Constant Field Values

PROCESSED_BY

protected static final String PROCESSED_BY

creationTime

protected long creationTime
The time the cocoon instance was created


cocoon

protected Cocoon cocoon
The Cocoon instance


exception

protected Exception exception
Holds exception happened during initialization (if any)


appContext

protected DefaultContext appContext
Avalon application context


ALLOW_RELOAD

protected static final boolean ALLOW_RELOAD
Default value for allowReload parameter (false)

See Also:
Constant Field Values

allowReload

protected boolean allowReload
Allow reloading of cocoon by specifying the cocoon-reload=true parameter with a request


showTime

protected boolean showTime
Allow adding processing time to the response


hiddenShowTime

protected boolean hiddenShowTime
If true, processing time will be added as an HTML comment


portletContext

protected javax.portlet.PortletContext portletContext

classLoader

protected ClassLoader classLoader
The classloader that will be set as the context classloader if init-classloader is true


initClassLoader

protected boolean initClassLoader

forceLoadParameter

protected String forceLoadParameter

forceSystemProperty

protected String forceSystemProperty

portletContextPath

protected String portletContextPath
This is the path to the portlet context (or the result of calling getRealPath('/') on the PortletContext. Note, that this can be null.


portletContextURL

protected String portletContextURL
This is the url to the portlet context directory


requestFactory

protected RequestFactory requestFactory
The RequestFactory is responsible for wrapping multipart-encoded forms and for handing the file payload of incoming requests


servletPath

protected String servletPath
Value to be used as servletPath in the request. Provided via configuration parameter, if missing, defaults to the '/portlets/' + portletName.


defaultSessionScope

protected int defaultSessionScope
Default scope for the session attributes, either PortletSession.PORTLET_SCOPE or PortletSession.APPLICATION_SCOPE. This corresponds to default-session-scope parameter, with default value portlet.

See Also:
PortletSession

storeSessionPath

protected boolean storeSessionPath
Store pathInfo in session

Constructor Detail

CocoonPortlet

public CocoonPortlet()
Method Detail

init

public void init(javax.portlet.PortletConfig conf)
          throws javax.portlet.PortletException
Initialize this CocoonPortlet instance.

Uses the following parameters: portlet-logger enable-uploads autosave-uploads overwrite-uploads upload-max-size show-time container-encoding form-encoding manage-exceptions servlet-path

Specified by:
init in interface javax.portlet.Portlet
Overrides:
init in class javax.portlet.GenericPortlet
Parameters:
conf - The PortletConfig object from the portlet container.
Throws:
javax.portlet.PortletException

destroy

public void destroy()
Dispose Cocoon when portlet is destroyed

Specified by:
destroy in interface javax.portlet.Portlet
Overrides:
destroy in class javax.portlet.GenericPortlet

addClassLoaderURL

protected void addClassLoaderURL(URL URL)
Adds an URL to the classloader. Does nothing here, but can be overriden.


addClassLoaderDirectory

protected void addClassLoaderDirectory(String dir)
Adds a directory to the classloader. Does nothing here, but can be overriden.


getClassPath

protected String getClassPath()
                       throws javax.portlet.PortletException
This builds the important ClassPath used by this Portlet. It does so in a Portlet Engine neutral way. It uses the PortletContext's getRealPath method to get the Portlet identified classes and lib directories. It iterates in alphabetical order through every file in the lib directory and adds it to the classpath. Also, we add the files to the ClassLoader for the Cocoon system. In order to protect ourselves from skitzofrantic classloaders, we need to work with a known one. We need to get this to work properly when Cocoon is in a war.

Throws:
javax.portlet.PortletException

getExtraClassPath

protected String getExtraClassPath()
                            throws javax.portlet.PortletException
Retreives the "extra-classpath" attribute, that needs to be added to the class path.

Throws:
javax.portlet.PortletException

initLogger

protected void initLogger()
Set up the log level and path. The default log level is Priority.ERROR, although it can be overwritten by the parameter "log-level". The log system goes to both a file and the Portlet container's log system. Only messages that are Priority.ERROR and above go to the portlet context. The log messages can be as restrictive (Priority.FATAL_ERROR and above) or as liberal (Priority.DEBUG and above) as you want that get routed to the file.


processAction

public void processAction(javax.portlet.ActionRequest req,
                          javax.portlet.ActionResponse res)
                   throws javax.portlet.PortletException,
                          IOException
Process the specified ActionRequest producing output on the specified ActionResponse.

Specified by:
processAction in interface javax.portlet.Portlet
Overrides:
processAction in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

render

public void render(javax.portlet.RenderRequest req,
                   javax.portlet.RenderResponse res)
            throws javax.portlet.PortletException,
                   IOException
Process the specified RenderRequest producing output on the specified RenderResponse.

Specified by:
render in interface javax.portlet.Portlet
Overrides:
render in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

manageException

protected void manageException(javax.portlet.ActionRequest req,
                               javax.portlet.ActionResponse res,
                               Environment env,
                               String uri,
                               String title,
                               String message,
                               String description,
                               Exception e)
                        throws javax.portlet.PortletException
Throws:
javax.portlet.PortletException

manageException

protected void manageException(javax.portlet.RenderRequest req,
                               javax.portlet.RenderResponse res,
                               Environment env,
                               String uri,
                               String title,
                               String message,
                               String description,
                               Exception e)
                        throws IOException,
                               javax.portlet.PortletException
Throws:
IOException
javax.portlet.PortletException

getEnvironment

protected Environment getEnvironment(String servletPath,
                                     String pathInfo,
                                     String uri,
                                     javax.portlet.ActionRequest req,
                                     javax.portlet.ActionResponse res)
                              throws Exception
Create the environment for the request

Throws:
Exception

getEnvironment

protected Environment getEnvironment(String servletPath,
                                     String pathInfo,
                                     String uri,
                                     javax.portlet.RenderRequest req,
                                     javax.portlet.RenderResponse res)
                              throws Exception
Create the environment for the request

Throws:
Exception

getParentComponentManager

protected ComponentManager getParentComponentManager()
Instatiates the parent component manager, as specified in the parent-component-manager init parameter. If none is specified, the method returns null.

Returns:
the parent component manager, or null.

updateEnvironment

protected void updateEnvironment()
                          throws javax.portlet.PortletException
Method to update the environment before Cocoon instances are created. This is also useful if you wish to customize any of the 'protected' variables from this class before a Cocoon instance is built in a derivative of this class (eg. Cocoon Context).

Throws:
javax.portlet.PortletException

getInitParameter

public String getInitParameter(String name)
Get an initialisation parameter. The value is trimmed, and null is returned if the trimmed value is empty.

Specified by:
getInitParameter in interface javax.portlet.PortletConfig
Overrides:
getInitParameter in class javax.portlet.GenericPortlet

getInitParameter

protected String getInitParameter(String name,
                                  String defaultValue)
Convenience method to access portlet parameters


getInitParameterAsBoolean

protected boolean getInitParameterAsBoolean(String name,
                                            boolean defaultValue)
Convenience method to access boolean portlet parameters


getInitParameterAsInteger

protected int getInitParameterAsInteger(String name,
                                        int defaultValue)

getLogger

protected Logger getLogger()

getLoggerManager

protected LoggerManager getLoggerManager()


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.