public class GenericPortletService
extends java.lang.Object
implements javax.portlet.Portlet
Portlet implementation with support for self-configuration, naming resolution, performance profiling and logging.
Derived class should override the following methods:
The portlet may be configured from portlet init parameters. specified in a web application deployment descriptor. Named init parameters are treated as properties of the portlet. Parameters prefixed with cxt: are looked up using the portlets name context.
The following example serves to demonstrate configuration of a generic portlet service:
<portlet> <portlet-name>MyPortletService</portlet-name> <portlet-class>com.acme.portlet.MyPortletService</portlet-class> <init-param> <param-name>loggingDebug</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>loggingWarning</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>loggingError</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>loggingInfo</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>MyString</param-name> <param-value>foobar</param-value> </init-param> <param-name>Object</param-name> <param-value>ctx:dynamo:/com/Acme/MyFooObject</param-value> </init-param> </portlet>
Derived portlets may use the lookup method to lookup objects in the portlets name context. The objects name context is accessable via the context property.
The portlet may log information using the logging facilities provided. Support for info, warning, error and debug levels are provided by the service.
If a performance monitor is enabled the portlet collects performance metrics about the handleService method.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
Constructor and Description |
---|
GenericPortletService()
Constructs an instanceof GenericPortletService
|
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Called by the portlet container to indicate to a portlet that
it is being taken out of service
|
javax.naming.Context |
getContext()
Returns property Context
|
java.lang.String |
getName()
Returns property Name
|
javax.portlet.PortletConfig |
getPortletConfig()
Returns property PortletConfig
|
javax.portlet.PortletContext |
getPortletContext()
Returns property PortletContext
|
void |
handleProcessAction(javax.portlet.ActionRequest pActionRequest,
javax.portlet.ActionResponse pActionResponse)
Called by the portlet service to process an action request
|
void |
handleRender(javax.portlet.RenderRequest pRenderRequest,
javax.portlet.RenderResponse pRenderResponse)
Called by the portlet service to indicate that a portlet should
handle a render request.
|
void |
init(javax.portlet.PortletConfig pPortletConfig)
Called by the portlet container to indicate to a portlet that
it is being placed into service.
|
boolean |
isLoggingDebug()
Returns property LoggingDebug
|
boolean |
isLoggingError()
Returns property LoggingError
|
boolean |
isLoggingInfo()
Returns property LoggingInfo
|
boolean |
isLoggingWarning()
Returns property LoggingWarning
|
void |
log(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an event with the specified message and Throwable
|
void |
logDebug(java.lang.String pMessage)
Logs an debug event with the specified message
|
void |
logDebug(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an debug event with the specified message and Throwable
|
void |
logDebug(java.lang.Throwable pThrowable)
Logs an debug event with the specified Throwable
|
void |
logError(java.lang.String pMessage)
Logs an error event with the specified message
|
void |
logError(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an error event with the specified message and Throwable
|
void |
logError(java.lang.Throwable pThrowable)
Logs an error event with the specified Throwable
|
void |
logInfo(java.lang.String pMessage)
Logs an info event with the specified message
|
void |
logInfo(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an info event with the specified message and Throwable
|
void |
logInfo(java.lang.Throwable pThrowable)
Logs an info event with the specified Throwable
|
void |
logWarning(java.lang.String pMessage)
Logs an warning event with the specified message
|
void |
logWarning(java.lang.String pMessage,
java.lang.Throwable pThrowable)
Logs an warning event with the specified message and Throwable
|
void |
logWarning(java.lang.Throwable pThrowable)
Logs an warning event with the specified Throwable
|
java.lang.Object |
lookup(java.lang.String pName)
Retreives the named object
|
protected void |
postHandleProcessAction(javax.portlet.ActionRequest pActionRequest,
javax.portlet.ActionResponse pActionResponse)
Called by the portlet service after processing an action request.
|
protected void |
postHandleRender(javax.portlet.RenderRequest pRenderRequest,
javax.portlet.RenderResponse pRenderResponse)
Called by the portlet service after servicing the render request.
|
protected void |
preHandleProcessAction(javax.portlet.ActionRequest pActionRequest,
javax.portlet.ActionResponse pActionResponse)
Called by the portlet service before processing an action request
|
protected void |
preHandleRender(javax.portlet.RenderRequest pRenderRequest,
javax.portlet.RenderResponse pRenderResponse)
Called by the portlet service before servicing the render request.
|
void |
processAction(javax.portlet.ActionRequest pActionRequest,
javax.portlet.ActionResponse pActionResponse)
Called by the portlet container to allow the portlet to process an action
request.
|
void |
render(javax.portlet.RenderRequest pRenderRequest,
javax.portlet.RenderResponse pRenderResponse)
Called by the portlet container to allow the portlet to generate the
content of the response based on its current state.
|
void |
setLoggingDebug(boolean pLoggingDebug)
Sets property LoggingDebug
|
void |
setLoggingError(boolean pLoggingError)
Sets property LoggingError
|
void |
setLoggingInfo(boolean pLoggingInfo)
Sets property LoggingInfo
|
void |
setLoggingWarning(boolean pLoggingWarning)
Sets property LoggingWarning
|
void |
startService(javax.portlet.PortletConfig pPortletConfig)
Called by the portlet service after it has been initialzed.
|
void |
stopService()
Called by the portlet service after it has been destroyed.
|
public GenericPortletService()
public javax.portlet.PortletConfig getPortletConfig()
public java.lang.String getName()
public javax.portlet.PortletContext getPortletContext()
public javax.naming.Context getContext()
public void setLoggingInfo(boolean pLoggingInfo)
public boolean isLoggingInfo()
public void setLoggingWarning(boolean pLoggingWarning)
public boolean isLoggingWarning()
public void setLoggingError(boolean pLoggingError)
public boolean isLoggingError()
public void setLoggingDebug(boolean pLoggingDebug)
public boolean isLoggingDebug()
public void startService(javax.portlet.PortletConfig pPortletConfig) throws javax.portlet.UnavailableException, javax.portlet.PortletException
pPortletConfig
- portlet configuration information.javax.portlet.PortletException
- if an exception has occurred that interferes with
the portlet's normal operation.javax.portlet.UnavailableException
- if the portlet cannot perform the
initialization at this time.public void init(javax.portlet.PortletConfig pPortletConfig) throws javax.portlet.PortletException
init
in interface javax.portlet.Portlet
pPortletConfig
- portlet configuration information.javax.portlet.PortletException
- if an exception has occurred that interferes with
the portlet's normal operation.javax.portlet.UnavailableException
- if the portlet cannot perform the
initialization at this time.protected void preHandleProcessAction(javax.portlet.ActionRequest pActionRequest, javax.portlet.ActionResponse pActionResponse) throws javax.portlet.PortletException, java.io.IOException
pActionRequest
- the action requestpActionResponse
- the action responsejavax.portlet.PortletException
- if the portlet has problems fulfilling the
requestjavax.portlet.UnavailableException
- if the portlet is unavailable to process
the action at this timejavax.portlet.PortletSecurityException
- if the portlet cannot fullfill this
request because of security reasonsjava.io.IOException
- if the streaming causes an I/O problempublic void handleProcessAction(javax.portlet.ActionRequest pActionRequest, javax.portlet.ActionResponse pActionResponse) throws javax.portlet.PortletException, java.io.IOException
pActionRequest
- the action requestpActionResponse
- the action responsejavax.portlet.PortletException
- if the portlet has problems fulfilling the
requestjavax.portlet.UnavailableException
- if the portlet is unavailable to process
the action at this timejavax.portlet.PortletSecurityException
- if the portlet cannot fullfill this
request because of security reasonsjava.io.IOException
- if the streaming causes an I/O problemprotected void postHandleProcessAction(javax.portlet.ActionRequest pActionRequest, javax.portlet.ActionResponse pActionResponse) throws javax.portlet.PortletException, java.io.IOException
pActionRequest
- the action requestpActionResponse
- the action responsejavax.portlet.PortletException
- if the portlet has problems fulfilling the
requestjavax.portlet.UnavailableException
- if the portlet is unavailable to process
the action at this timejavax.portlet.PortletSecurityException
- if the portlet cannot fullfill this
request because of security reasonsjava.io.IOException
- if the streaming causes an I/O problempublic void processAction(javax.portlet.ActionRequest pActionRequest, javax.portlet.ActionResponse pActionResponse) throws javax.portlet.PortletException, java.io.IOException
processAction
in interface javax.portlet.Portlet
pActionRequest
- the action requestpActionResponse
- the action responsejavax.portlet.PortletException
- if the portlet has problems fulfilling the
requestjavax.portlet.UnavailableException
- if the portlet is unavailable to process
the action at this timejavax.portlet.PortletSecurityException
- if the portlet cannot fullfill this
request because of security reasonsjava.io.IOException
- if the streaming causes an I/O problemprotected void preHandleRender(javax.portlet.RenderRequest pRenderRequest, javax.portlet.RenderResponse pRenderResponse) throws javax.portlet.PortletException, java.io.IOException
pRenderRequest
- the render requestpRenderResponse
- the render responsejavax.portlet.PortletException
- if the portlet has problems fulfilling the
rendering requestjavax.portlet.UnavailableException
- if the portlet is unavailable to perform
render at this timejavax.portlet.PortletSecurityException
- if the portlet cannot fullfill this
request because of security reasonsjava.io.IOException
- if the streaming causes an I/O problempublic void handleRender(javax.portlet.RenderRequest pRenderRequest, javax.portlet.RenderResponse pRenderResponse) throws javax.portlet.PortletException, java.io.IOException
pRenderRequest
- the render requestpRenderResponse
- the render responsejavax.portlet.PortletException
- if the portlet has problems fulfilling the
rendering requestjavax.portlet.UnavailableException
- if the portlet is unavailable to perform
render at this timejavax.portlet.PortletSecurityException
- if the portlet cannot fullfill this
request because of security reasonsjava.io.IOException
- if the streaming causes an I/O problemprotected void postHandleRender(javax.portlet.RenderRequest pRenderRequest, javax.portlet.RenderResponse pRenderResponse) throws javax.portlet.PortletException, java.io.IOException
pRenderRequest
- the render requestpRenderResponse
- the render responsejavax.portlet.PortletException
- if the portlet has problems fulfilling the
rendering requestjavax.portlet.UnavailableException
- if the portlet is unavailable to perform
render at this timejavax.portlet.PortletSecurityException
- if the portlet cannot fullfill this
request because of security reasonsjava.io.IOException
- if the streaming causes an I/O problempublic void render(javax.portlet.RenderRequest pRenderRequest, javax.portlet.RenderResponse pRenderResponse) throws javax.portlet.PortletException, java.io.IOException
render
in interface javax.portlet.Portlet
pRenderRequest
- the render requestpRenderResponse
- the render responsejavax.portlet.PortletException
- if the portlet has problems fulfilling the
rendering requestjavax.portlet.UnavailableException
- if the portlet is unavailable to perform
render at this timejavax.portlet.PortletSecurityException
- if the portlet cannot fullfill this
request because of security reasonsjava.io.IOException
- if the streaming causes an I/O problempublic void stopService()
public void destroy()
destroy
in interface javax.portlet.Portlet
public java.lang.Object lookup(java.lang.String pName) throws javax.naming.NamingException
pName
- the name of the objectjavax.naming.NamingException
- if an error occurspublic void log(java.lang.String pMessage, java.lang.Throwable pThrowable)
public void logInfo(java.lang.String pMessage)
public void logInfo(java.lang.Throwable pThrowable)
public void logInfo(java.lang.String pMessage, java.lang.Throwable pThrowable)
public void logWarning(java.lang.String pMessage)
public void logWarning(java.lang.Throwable pThrowable)
public void logWarning(java.lang.String pMessage, java.lang.Throwable pThrowable)
public void logError(java.lang.String pMessage)
public void logError(java.lang.Throwable pThrowable)
public void logError(java.lang.String pMessage, java.lang.Throwable pThrowable)
public void logDebug(java.lang.String pMessage)
public void logDebug(java.lang.Throwable pThrowable)
public void logDebug(java.lang.String pMessage, java.lang.Throwable pThrowable)