org.iges.anagram
Class AnagramServlet

java.lang.Object
  |
  +--HttpServlet
        |
        +--org.iges.anagram.AnagramServlet
All Implemented Interfaces:
Module

public class AnagramServlet
extends HttpServlet
implements Module

The servlet component of the Anagram framework.

This module implements the HTTP servlet interface, and thus handles all communication with the servlet container.

See Also:
Serialized Form

Field Summary
protected  ErrorService dodsErrorHandler
           
protected  java.util.Set dodsErrorServices
           
protected  java.util.List filters
           
protected  Log log
           
protected  java.lang.String moduleName
           
protected  Server server
           
protected  ErrorService webErrorHandler
           
 
Constructor Summary
AnagramServlet()
           
 
Method Summary
 void configure(Setting setting)
          Configures the module according to the settings provided.
protected  void createFilters()
          Called by init(Server, Module).
protected  boolean debug()
          Same as in AbstractModule.
 void destroy()
          Called when the server is shutting down
 void doGet(HttpServletRequest request, HttpServletResponse response)
          Handles all incoming requests by doing the following: A non-exclusive lock on the server is obtained. A ClientRequest object is obtained from the Mapper module The request is logged and a timer is started. The request is passed to the head of the chain of Filters If an error occurs, the request is passed to the appropriate error handler. The total elapsed time is logged, the output stream is closed, and the server lock is released.
 void doPost(HttpServletRequest request, HttpServletResponse response)
          Handles POST requests.
protected  ErrorService findErrorHandler(ClientRequest request)
          Returns an error service which uses the appropriate format based on the type of request.
 java.lang.String getModuleID()
          Returns an ID for this module.
 java.lang.String getModuleName()
          Same as in AbstractModule.
 void init(Server server, Module parent)
          Initializes the module.
 void init(ServletConfig config)
          Called when the servlet is first loaded.
protected  boolean verbose()
          Same as in AbstractModule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

moduleName

protected java.lang.String moduleName

server

protected Server server

log

protected Log log

dodsErrorServices

protected java.util.Set dodsErrorServices

dodsErrorHandler

protected ErrorService dodsErrorHandler

webErrorHandler

protected ErrorService webErrorHandler

filters

protected java.util.List filters
Constructor Detail

AnagramServlet

public AnagramServlet()
Method Detail

getModuleID

public java.lang.String getModuleID()
Description copied from interface: Module
Returns an ID for this module. This ID should be a legal XML tag name. It has two uses: as a tag name in the server's configuration file, and as the final element of the complete module name.

Specified by:
getModuleID in interface Module

init

public void init(Server server,
                 Module parent)
Description copied from interface: Module
Initializes the module.

This method should copy the server and parent references provided to internal fields, so that the module has access to the rest of the module hierarchy, and then call the init() method of any sub-modules. It can also be used to perform any one-time initialization that requires access to other modules.

This method will only be called once, immediately after the module is created, and before it is configured for the first time. Thus it does not need to be thread-safe.

Specified by:
init in interface Module

createFilters

protected void createFilters()
Called by init(Server, Module). Sets up filter chain.


configure

public void configure(Setting setting)
               throws ConfigException
Description copied from interface: Module
Configures the module according to the settings provided.

This method is guaranteed to be called at least once before any requests are sent to the module. The server supports dynamic reconfiguration, and thus this method may be called any number of times during the life of the module. However, it is guaranteed that this method will never be called while a servlet request is being processed. Thus it does not need to be thread-safe.

If this module contains other modules, it is responsible for configuring them using the appropriate sub-settings. Each module should receive the sub-setting that matches its module ID, so that the XML tags in the configuration file match up with the module names in the log file.

Specified by:
configure in interface Module
Throws:
ConfigException - If the module is unable to operate using the settings provided. This will halt the server's operation, and thus should only be thrown if there is no reasonable default that can be used in place of a missing or invalid setting.

getModuleName

public java.lang.String getModuleName()
Same as in AbstractModule. We can't use AbstractModule because we have to inherit from HttpServlet.

Specified by:
getModuleName in interface Module

debug

protected boolean debug()
Same as in AbstractModule. We can't use AbstractModule because we have to inherit from HttpServlet.


verbose

protected boolean verbose()
Same as in AbstractModule. We can't use AbstractModule because we have to inherit from HttpServlet.


init

public void init(ServletConfig config)
          throws ServletException
Called when the servlet is first loaded. Creates a Server object registered with this servlet.

ServletException

destroy

public void destroy()
Called when the server is shutting down


doPost

public void doPost(HttpServletRequest request,
                   HttpServletResponse response)
Handles POST requests. This method simply passes the POST request to doGet().


doGet

public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
Handles all incoming requests by doing the following:
  • A non-exclusive lock on the server is obtained.
  • A ClientRequest object is obtained from the Mapper module
  • The request is logged and a timer is started.
  • The request is passed to the head of the chain of Filters
  • If an error occurs, the request is passed to the appropriate error handler.
  • The total elapsed time is logged, the output stream is closed, and the server lock is released.

  • findErrorHandler

    protected ErrorService findErrorHandler(ClientRequest request)
    Returns an error service which uses the appropriate format based on the type of request.