atg.servlet
Class GenericServletService

java.lang.Object
  extended by atg.servlet.GenericServletService
All Implemented Interfaces:
javax.servlet.Servlet
Direct Known Subclasses:
MappedJumpServlet

public class GenericServletService
extends java.lang.Object
implements javax.servlet.Servlet

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

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

GenericServletService

public GenericServletService()
Constructs an instanceof GenericServletService

Method Detail

getServletConfig

public javax.servlet.ServletConfig getServletConfig()
Returns property ServletConfig

Specified by:
getServletConfig in interface javax.servlet.Servlet

getName

public java.lang.String getName()
Returns property Name


getServletContext

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


getContext

public javax.naming.Context getContext()
Returns property Context


setLoggingInfo

public void setLoggingInfo(boolean pLoggingInfo)
Sets property LoggingInfo


isLoggingInfo

public boolean isLoggingInfo()
Returns property LoggingInfo


setLoggingWarning

public void setLoggingWarning(boolean pLoggingWarning)
Sets property LoggingWarning


isLoggingWarning

public boolean isLoggingWarning()
Returns property LoggingWarning


setLoggingError

public void setLoggingError(boolean pLoggingError)
Sets property LoggingError


isLoggingError

public boolean isLoggingError()
Returns property LoggingError


setLoggingDebug

public void setLoggingDebug(boolean pLoggingDebug)
Sets property LoggingDebug


isLoggingDebug

public boolean isLoggingDebug()
Returns property LoggingDebug


getServletInfo

public java.lang.String getServletInfo()
Access servlet info

Specified by:
getServletInfo in interface javax.servlet.Servlet

startService

public void startService(javax.servlet.ServletConfig pServletConfig)
                  throws javax.servlet.ServletException
Called by the servlet after it has been initialzed. Derived classes should overrise this method to initialize the service.

Parameters:
pServletConfig - servlet configuration information.
Throws:
ServletsException - if an exception occurs when starting this servlet.
javax.servlet.ServletException

init

public void init(javax.servlet.ServletConfig pServletConfig)
          throws javax.servlet.ServletException
Called by the web container to indicate to a servlet that it is being placed into service.

Specified by:
init in interface javax.servlet.Servlet
Parameters:
pServletConfig - servlet configuration information.
Throws:
javax.servlet.ServletException - if an exception occurs when initializing this servlet.

handleService

public void handleService(javax.servlet.ServletRequest pServletRequest,
                          javax.servlet.ServletResponse pServletResponse)
                   throws java.io.IOException,
                          javax.servlet.ServletException
Called by the servlet to indicate that a servlet should handle a request/response. Derived classes should override this method to handle the servicing of a request

Parameters:
pServletRequest - the servlet request
pServletResponse - the servlet response
Throws:
java.io.IOException - when an i/o error occurs
javax.servlet.ServletException - when an error occurs when processing this servlet

service

public void service(javax.servlet.ServletRequest pServletRequest,
                    javax.servlet.ServletResponse pServletResponse)
             throws java.io.IOException,
                    javax.servlet.ServletException
Called by the web container to indicate that a servlet should service a request/response

Specified by:
service in interface javax.servlet.Servlet
Parameters:
pServletRequest - the servlet request
pServletResponse - the servlet response
Throws:
java.io.IOException - when an i/o error occurs
javax.servlet.ServletException - when an error occurs when processing this servlet

stopService

public void stopService()
Called by the servlet service after it has been destroyed. Derived classes should override this method to perform any cleanup.


destroy

public void destroy()
Called by the web container to indicate to a servlet that it is being taken out of service

Specified by:
destroy in interface javax.servlet.Servlet

lookup

public java.lang.Object lookup(java.lang.String pName)
                        throws javax.naming.NamingException
Retreives the named object

Parameters:
pName - the name of the object
Returns:
the named object
Throws:
javax.naming.NamingException - if an error occurs

logInfo

public void logInfo(java.lang.String pMessage)
Logs an info event with the specified message


logInfo

public void logInfo(java.lang.Throwable pThrowable)
Logs an info event with the specified Throwable


logInfo

public void logInfo(java.lang.String pMessage,
                    java.lang.Throwable pThrowable)
Logs an info event with the specified message and Throwable


logWarning

public void logWarning(java.lang.String pMessage)
Logs an warning event with the specified message


logWarning

public void logWarning(java.lang.Throwable pThrowable)
Logs an warning event with the specified Throwable


logWarning

public void logWarning(java.lang.String pMessage,
                       java.lang.Throwable pThrowable)
Logs an warning event with the specified message and Throwable


logError

public void logError(java.lang.String pMessage)
Logs an error event with the specified message


logError

public void logError(java.lang.Throwable pThrowable)
Logs an error event with the specified Throwable


logError

public void logError(java.lang.String pMessage,
                     java.lang.Throwable pThrowable)
Logs an error event with the specified message and Throwable


logDebug

public void logDebug(java.lang.String pMessage)
Logs an debug event with the specified message


logDebug

public void logDebug(java.lang.Throwable pThrowable)
Logs an debug event with the specified Throwable


logDebug

public void logDebug(java.lang.String pMessage,
                     java.lang.Throwable pThrowable)
Logs an debug event with the specified message and Throwable