public class GenericPortletService
extends org.apache.jetspeed.portlet.Portlet
implements org.apache.jetspeed.portlet.PortletPageListener, org.apache.jetspeed.portlet.event.ActionListener
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 servlet init parameters. specified in a web application deployment descriptor. Named init parameters are treated as properties of the servlet. Parameters prefixed with cxt: are looked up using the portlets name context.
The following example serves to demonstrate configuration of a generic servlet service:
<servlet> <servlet-name>MyPortletService</servlet-name> <servlet-class>com.acme.portlet.MyServletService</servlet-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> </servlet>
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 |
actionPerformed(org.apache.jetspeed.portlet.event.ActionEvent pActionEvent)
Called by the portlet container to service an action
|
void |
beginPage(org.apache.jetspeed.portlet.PortletRequest pPortletRequest,
org.apache.jetspeed.portlet.PortletResponse pPortletResponse)
Called by the portlet container to indicate that a portlet should
service a request/response for the begining of a page
|
void |
destroy(org.apache.jetspeed.portlet.PortletConfig pPortletConfig)
Called by the portlet container to indicate to a portlet that
it is being taken out of service
|
void |
destroyConcrete(org.apache.jetspeed.portlet.PortletSettings pSettings)
Called by the portlet container to indicate to a portlet that
it is being taken out of service
|
void |
endPage(org.apache.jetspeed.portlet.PortletRequest pPortletRequest,
org.apache.jetspeed.portlet.PortletResponse pPortletResponse)
Called by the portlet container to indicate that a portlet should
service a request/response for the end of a page
|
javax.naming.Context |
getContext()
Returns property Context
|
long |
getLastModified(org.apache.jetspeed.portlet.PortletRequest pPortletRequest)
Returns the time the time of the response object was last modified.
|
java.lang.String |
getName()
Returns property Name
|
org.apache.jetspeed.portlet.PortletConfig |
getPortletConfig()
Returns property PortletConfig
|
org.apache.jetspeed.portlet.PortletContext |
getPortletContext()
Returns property PortletContext
|
void |
handleActionPerformed(org.apache.jetspeed.portlet.event.ActionEvent pActionEvent)
Called by the portlet service to service an action
|
void |
handleBeginPage(org.apache.jetspeed.portlet.PortletRequest pPortletRequest,
org.apache.jetspeed.portlet.PortletResponse pPortletResponse)
Called by the portlet container to indicate that a portlet should
handle a request/response for the page.
|
void |
handleEndPage(org.apache.jetspeed.portlet.PortletRequest pPortletRequest,
org.apache.jetspeed.portlet.PortletResponse pPortletResponse)
Called by the portlet container to indicate that a portlet should
handle a request/response for the page.
|
void |
handleLogin(org.apache.jetspeed.portlet.PortletRequest pPortletRequest)
Called by the portlet service to indicate to a portlet that
a session is being created
|
void |
handleLogout(org.apache.jetspeed.portlet.PortletSession pPortletSession)
Called by the portlet service to indicate to a portlet that
a session is being destroyed
|
void |
handleService(org.apache.jetspeed.portlet.PortletRequest pPortletRequest,
org.apache.jetspeed.portlet.PortletResponse pPortletResponse)
Called by the portlet container to indicate that a portlet should
handle a request/response.
|
void |
init(org.apache.jetspeed.portlet.PortletConfig pPortletConfig)
Called by the portlet container to indicate to a portlet that
it is being placed into service.
|
void |
initConcrete(org.apache.jetspeed.portlet.PortletSettings pPortletSettings)
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 |
login(org.apache.jetspeed.portlet.PortletRequest pPortletRequest)
Called by the portlet container to indicate to a portlet that
a session is being created
|
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 |
logout(org.apache.jetspeed.portlet.PortletSession pPortletSession)
Called by the portlet container to indicate to a portlet that
a session is being destroyed
|
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
|
void |
service(org.apache.jetspeed.portlet.PortletRequest pPortletRequest,
org.apache.jetspeed.portlet.PortletResponse pPortletResponse)
Called by the portlet container to indicate that a portlet should
service a request/response
|
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 |
startConcreteService(org.apache.jetspeed.portlet.PortletSettings pPortletSettings)
Called by the concrete portlet after it has been initialzed.
|
void |
startService(org.apache.jetspeed.portlet.PortletConfig pServletConfig)
Called by the portlet after it has been initialzed.
|
void |
stopConcreteService(org.apache.jetspeed.portlet.PortletSettings pPortletSettings)
Called by the portlet service after it has been destroyed.
|
void |
stopService(org.apache.jetspeed.portlet.PortletConfig pPortletConfig)
Called by the portlet service after it has been destroyed.
|
destroy, doDelete, doGet, doOptions, doPost, doPut, doTrace, getInitParameter, getInitParameterNames, getLastModified, getPortletSettings, getServletConfig, getServletContext, getServletInfo, init, init, service
public GenericPortletService()
public org.apache.jetspeed.portlet.PortletConfig getPortletConfig()
getPortletConfig
in class org.apache.jetspeed.portlet.Portlet
public java.lang.String getName()
public javax.naming.Context getContext()
public org.apache.jetspeed.portlet.PortletContext getPortletContext()
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(org.apache.jetspeed.portlet.PortletConfig pServletConfig) throws org.apache.jetspeed.portlet.UnavailableException
pPortletConfig
- portlet configuration information.org.apache.jetspeed.portlet.UnavailableException
- if an exception occurs when starting
this servlet.public void startConcreteService(org.apache.jetspeed.portlet.PortletSettings pPortletSettings) throws org.apache.jetspeed.portlet.UnavailableException
pPortletSettings
- concrete portlet configuration information.org.apache.jetspeed.portlet.UnavailableException
- if an exception occurs when starting
this servlet.public void init(org.apache.jetspeed.portlet.PortletConfig pPortletConfig) throws org.apache.jetspeed.portlet.UnavailableException
init
in class org.apache.jetspeed.portlet.Portlet
pPortletConfig
- portlet configuration information.org.apache.jetspeed.portlet.UnavailableException
- if an exception occurs when initializing
this servlet.public void initConcrete(org.apache.jetspeed.portlet.PortletSettings pPortletSettings) throws org.apache.jetspeed.portlet.UnavailableException
initConcrete
in class org.apache.jetspeed.portlet.Portlet
pPortletSettings
- concreate portlet configuration information.org.apache.jetspeed.portlet.UnavailableException
- if an exception occurs when initializing
this servlet.public void handleActionPerformed(org.apache.jetspeed.portlet.event.ActionEvent pActionEvent)
pActionEvent
- the action eventpublic void actionPerformed(org.apache.jetspeed.portlet.event.ActionEvent pActionEvent)
actionPerformed
in interface org.apache.jetspeed.portlet.event.ActionListener
pActionEvent
- the action eventpublic void handleService(org.apache.jetspeed.portlet.PortletRequest pPortletRequest, org.apache.jetspeed.portlet.PortletResponse pPortletResponse) throws java.io.IOException, org.apache.jetspeed.portlet.PortletException
pPortletRequest
- the portlet requestpPortletResponse
- the portlet responsejava.io.IOException
- when an i/o error occursorg.apache.jetspeed.portlet.PortletException
- when an error occurs when processing
this portletpublic void service(org.apache.jetspeed.portlet.PortletRequest pPortletRequest, org.apache.jetspeed.portlet.PortletResponse pPortletResponse) throws java.io.IOException, org.apache.jetspeed.portlet.PortletException
service
in class org.apache.jetspeed.portlet.Portlet
pPortletRequest
- the portlet requestpPortletResponse
- the portlet responsejava.io.IOException
- when an i/o error occursorg.apache.jetspeed.portlet.PortletException
- when an error occurs when processing
this portletpublic void stopService(org.apache.jetspeed.portlet.PortletConfig pPortletConfig)
public void stopConcreteService(org.apache.jetspeed.portlet.PortletSettings pPortletSettings)
public void destroy(org.apache.jetspeed.portlet.PortletConfig pPortletConfig)
destroy
in class org.apache.jetspeed.portlet.Portlet
public void destroyConcrete(org.apache.jetspeed.portlet.PortletSettings pSettings)
destroyConcrete
in class org.apache.jetspeed.portlet.Portlet
public void handleBeginPage(org.apache.jetspeed.portlet.PortletRequest pPortletRequest, org.apache.jetspeed.portlet.PortletResponse pPortletResponse) throws java.io.IOException, org.apache.jetspeed.portlet.PortletException
pPortletRequest
- the portlet requestpPortletResponse
- the portlet responsejava.io.IOException
- when an i/o error occursorg.apache.jetspeed.portlet.PortletException
- when an error occurs when processing
this portletpublic void handleEndPage(org.apache.jetspeed.portlet.PortletRequest pPortletRequest, org.apache.jetspeed.portlet.PortletResponse pPortletResponse) throws java.io.IOException, org.apache.jetspeed.portlet.PortletException
pPortletRequest
- the portlet requestpPortletResponse
- the portlet responsejava.io.IOException
- when an i/o error occursorg.apache.jetspeed.portlet.PortletException
- when an error occurs when processing
this portletpublic void beginPage(org.apache.jetspeed.portlet.PortletRequest pPortletRequest, org.apache.jetspeed.portlet.PortletResponse pPortletResponse) throws java.io.IOException, org.apache.jetspeed.portlet.PortletException
beginPage
in interface org.apache.jetspeed.portlet.PortletPageListener
pPortletRequest
- the portlet requestpPortletResponse
- the portlet responsejava.io.IOException
- when an i/o error occursorg.apache.jetspeed.portlet.PortletException
- when an error occurs when processing
this portletpublic void endPage(org.apache.jetspeed.portlet.PortletRequest pPortletRequest, org.apache.jetspeed.portlet.PortletResponse pPortletResponse) throws java.io.IOException, org.apache.jetspeed.portlet.PortletException
endPage
in interface org.apache.jetspeed.portlet.PortletPageListener
pPortletRequest
- the portlet requestpPortletResponse
- the portlet responsejava.io.IOException
- when an i/o error occursorg.apache.jetspeed.portlet.PortletException
- when an error occurs when processing
this portletpublic void handleLogin(org.apache.jetspeed.portlet.PortletRequest pPortletRequest) throws org.apache.jetspeed.portlet.PortletException
pPortletRequest
- the portlet requestorg.apache.jetspeed.portlet.PortletException
public void handleLogout(org.apache.jetspeed.portlet.PortletSession pPortletSession) throws org.apache.jetspeed.portlet.PortletException
pPortletSession
- the portlet sessionorg.apache.jetspeed.portlet.PortletException
public void login(org.apache.jetspeed.portlet.PortletRequest pPortletRequest) throws org.apache.jetspeed.portlet.PortletException
login
in interface org.apache.jetspeed.portlet.PortletSessionListener
login
in class org.apache.jetspeed.portlet.Portlet
pPortletRequest
- the portlet requestorg.apache.jetspeed.portlet.PortletException
public void logout(org.apache.jetspeed.portlet.PortletSession pPortletSession) throws org.apache.jetspeed.portlet.PortletException
logout
in interface org.apache.jetspeed.portlet.PortletSessionListener
logout
in class org.apache.jetspeed.portlet.Portlet
pPortletSession
- the portlet sessionorg.apache.jetspeed.portlet.PortletException
public long getLastModified(org.apache.jetspeed.portlet.PortletRequest pPortletRequest)
getLastModified
in class org.apache.jetspeed.portlet.Portlet
pPortletRequest
- the portlet requestpublic 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)
log
in class javax.servlet.GenericServlet
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)