|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectatg.servlet.GenericServletService
public class GenericServletService
Servlet implementation with support for self-configuration, naming resolution, performance profiling and logging.
Derived class should override the following methods:
The servlet 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 servlets name context.
The following example serves to demonstrate configuration of a generic servlet service:
<servlet> <servlet-name>MyServletService</servlet-name> <servlet-class>com.acme.servlet.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 servlets may use the lookup method to lookup objects in the servlets name context. The objects name context is accessable via the context property.
The servlet 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 servlet collects performance metrics about the handleService method.
Field Summary | |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string |
Constructor Summary | |
---|---|
GenericServletService()
Constructs an instanceof GenericServletService |
Method Summary | |
---|---|
void |
destroy()
Called by the web container to indicate to a servlet that it is being taken out of service |
javax.naming.Context |
getContext()
Returns property Context |
java.lang.String |
getName()
Returns property Name |
javax.servlet.ServletConfig |
getServletConfig()
Returns property ServletConfig |
javax.servlet.ServletContext |
getServletContext()
Returns property ServletContext |
java.lang.String |
getServletInfo()
Access servlet info |
void |
handleService(javax.servlet.ServletRequest pServletRequest,
javax.servlet.ServletResponse pServletResponse)
Called by the servlet to indicate that a servlet should handle a request/response. |
void |
init(javax.servlet.ServletConfig pServletConfig)
Called by the web container to indicate to a servlet 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 |
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 |
void |
service(javax.servlet.ServletRequest pServletRequest,
javax.servlet.ServletResponse pServletResponse)
Called by the web container to indicate that a servlet 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 |
startService(javax.servlet.ServletConfig pServletConfig)
Called by the servlet after it has been initialzed. |
void |
stopService()
Called by the servlet service after it has been destroyed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
Constructor Detail |
---|
public GenericServletService()
Method Detail |
---|
public javax.servlet.ServletConfig getServletConfig()
getServletConfig
in interface javax.servlet.Servlet
public java.lang.String getName()
public javax.servlet.ServletContext getServletContext()
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 java.lang.String getServletInfo()
getServletInfo
in interface javax.servlet.Servlet
public void startService(javax.servlet.ServletConfig pServletConfig) throws javax.servlet.ServletException
pServletConfig
- servlet configuration information.
ServletsException
- if an exception occurs when starting
this servlet.
javax.servlet.ServletException
public void init(javax.servlet.ServletConfig pServletConfig) throws javax.servlet.ServletException
init
in interface javax.servlet.Servlet
pServletConfig
- servlet configuration information.
javax.servlet.ServletException
- if an exception occurs when initializing
this servlet.public void handleService(javax.servlet.ServletRequest pServletRequest, javax.servlet.ServletResponse pServletResponse) throws java.io.IOException, javax.servlet.ServletException
pServletRequest
- the servlet requestpServletResponse
- the servlet response
java.io.IOException
- when an i/o error occurs
javax.servlet.ServletException
- when an error occurs when processing
this servletpublic void service(javax.servlet.ServletRequest pServletRequest, javax.servlet.ServletResponse pServletResponse) throws java.io.IOException, javax.servlet.ServletException
service
in interface javax.servlet.Servlet
pServletRequest
- the servlet requestpServletResponse
- the servlet response
java.io.IOException
- when an i/o error occurs
javax.servlet.ServletException
- when an error occurs when processing
this servletpublic void stopService()
public void destroy()
destroy
in interface javax.servlet.Servlet
public java.lang.Object lookup(java.lang.String pName) throws javax.naming.NamingException
pName
- the name of the object
javax.naming.NamingException
- if an error occurspublic 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)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |