com.interface21.web.servlet
Class HttpServletBean

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.interface21.web.servlet.HttpServletBean
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
FrameworkServlet, ResourceServlet

public class HttpServletBean
extends javax.servlet.http.HttpServlet

Simple extension of javax.servlet.http.HttpServlet that treats its config parameters as bean properties. A very handy superclass for any type of servlet. Type conversion is automatic. It is also possible for subclasses to specify required properties. This servlet leaves request handling to subclasses, inheriting the default behaviour of HttpServlet.

This servlet superclass has no dependency on the application context. However, it does use Java 1.4 logging emulation, which must have been configured by another component.

Version:
$Revision: 1.2 $
Author:
Rod Johnson
See Also:
Serialized Form

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
HttpServletBean()
          Construct a new HttpServletBean
 
Method Summary
protected  void addRequiredProperty(java.lang.String property)
          Subclasses can invoke this method to specify that this property (which must match a JavaBean property they expose) is mandatory, and must be supplied as a config parameter.
protected  java.lang.String getIdentifier()
          Return the name of this servlet: handy to include in log messages.
 void init()
          Map config parameters onto bean properties of this servlet, and invoke subclass initialization.
protected  void initServletBean()
          Subclasses may override this to perform custom initialization.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

HttpServletBean

public HttpServletBean()
Construct a new HttpServletBean
Method Detail

addRequiredProperty

protected final void addRequiredProperty(java.lang.String property)
Subclasses can invoke this method to specify that this property (which must match a JavaBean property they expose) is mandatory, and must be supplied as a config parameter.
Parameters:
property - name of the required property

init

public final void init()
                throws javax.servlet.ServletException
Map config parameters onto bean properties of this servlet, and invoke subclass initialization.
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException - if bean properties are invalid (or required properties are missing), or if subclass initialization fails.

initServletBean

protected void initServletBean()
                        throws javax.servlet.ServletException
Subclasses may override this to perform custom initialization. All bean properties of this servlet will have been set before this method is invoked. This default implementation does nothing.
Throws:
javax.servlet.ServletException - if subclass initialization fails

getIdentifier

protected java.lang.String getIdentifier()
Return the name of this servlet: handy to include in log messages. Subclasses may override it if necessary to include additional information. Use like this: Category.getInstance(getClass()).debug(getIdentifier() + "body of message");
Returns:
the name of this servlet


Rod Johnson and Spring contributors 2001-2003.