ZetaGrid v1.9

zeta
Class ZetaServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--zeta.ZetaServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ZetaServlet
extends javax.servlet.http.HttpServlet

Creates an HTTP servlet that dispatches HTTP GET and HTTP POST requests on the ZetaGrid site to specified handlers.

See Also:
Serialized Form

Field Summary
private  ConnectionDriver connectionDriver
           
private  java.io.Writer errorLog
           
private  java.lang.String errorLogFilename
           
private  java.util.List getHandlers
          Map to handle HTTP GET requests.
private  int id
          ID for logging.
private  java.text.SimpleDateFormat logFormat
           
private static int MAX_BACKUP_INDEX
           
private static long MAX_LOG_FILESIZE
           
private  boolean normalLogging
           
private  int numberOfStatisticHandlers
          Number of handlers which handle HTTP GET requests for statistics.
private  java.util.Hashtable parameters
           
private  int poolsize
           
private  java.util.List postHandlers
          Map to handle HTTP POST requests.
private  int serverId
          ID of the server.
private  java.io.Writer stdLog
           
private  java.lang.String stdLogFilename
           
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Constructor Summary
ZetaServlet()
          Initialize lists to handle HTTP GET and HTTP POST requests.
 
Method Summary
 void addStatisticHandler(java.lang.String name, java.lang.String parameter, java.util.List statisticHandlers)
          Adds a statistic handler.
 void destroy()
          Destroy the resources that are held for the life of the servlet.
protected  void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Called by the server to allow this servlet to handle a GET request.
protected  void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Called by the server to allow this servlet to handle a POST request.
private  java.lang.Object findHandler(java.util.List handlers, java.lang.String name)
          Searches the handler by the specified name.
 java.sql.Connection getConnection()
          Returns a connection to the back-end database.
 java.lang.String getHandlerAddress(java.lang.Class handler)
          Searches the handler address by the specified class of this GET handler.
 java.lang.String getInitParameter(java.lang.String name)
           
 int getInitParameter(java.lang.String name, int defaultValue)
           
 java.util.Enumeration getInitParameterNames()
           
private  java.lang.Object getInstance(java.lang.Class handlerClass)
          Builds a new instance of the specified handler class
 int getNumberOfStatisticHandlers()
          Returns the number of defined statistic handlers.
 int getServerId()
          Returns the ID of the server.
 AbstractHandler getStatisticHandler(java.lang.Class handler)
          Searches the handler object by the specified class of this statistic handler.
 java.lang.Class getStatisticHandlerClass(int i)
          Returns the i-th defined statistic handler.
 java.lang.String getStatisticHandlerName(java.lang.Class handler)
          Searches the handler name by the specified class of this statistic handler.
 boolean hasSeparateFiles()
           
 void init()
          Initialize the resources that are held for the life of the servlet.
private  void initLogFile()
           
 void log(java.lang.String msg)
           
 void log(java.lang.Throwable t)
           
private  void rollOver(java.lang.String filename, int maxBackupIndex)
          Implements the usual roll over behaviour of log files.
 void setServerId(int serverId)
          Sets the ID of the server.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getServletConfig, getServletContext, getServletInfo, getServletName, init, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameters

private java.util.Hashtable parameters

getHandlers

private java.util.List getHandlers
Map to handle HTTP GET requests.


postHandlers

private java.util.List postHandlers
Map to handle HTTP POST requests.


numberOfStatisticHandlers

private int numberOfStatisticHandlers
Number of handlers which handle HTTP GET requests for statistics.


serverId

private int serverId
ID of the server.


id

private int id
ID for logging.


poolsize

private int poolsize

connectionDriver

private ConnectionDriver connectionDriver

stdLogFilename

private java.lang.String stdLogFilename

stdLog

private java.io.Writer stdLog

errorLogFilename

private java.lang.String errorLogFilename

errorLog

private java.io.Writer errorLog

logFormat

private java.text.SimpleDateFormat logFormat

normalLogging

private boolean normalLogging

MAX_LOG_FILESIZE

private static final long MAX_LOG_FILESIZE
See Also:
Constant Field Values

MAX_BACKUP_INDEX

private static final int MAX_BACKUP_INDEX
See Also:
Constant Field Values
Constructor Detail

ZetaServlet

public ZetaServlet()
Initialize lists to handle HTTP GET and HTTP POST requests.

Method Detail

getInitParameter

public java.lang.String getInitParameter(java.lang.String name)
Specified by:
getInitParameter in interface javax.servlet.ServletConfig
Overrides:
getInitParameter in class javax.servlet.GenericServlet

getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Specified by:
getInitParameterNames in interface javax.servlet.ServletConfig
Overrides:
getInitParameterNames in class javax.servlet.GenericServlet

getInitParameter

public int getInitParameter(java.lang.String name,
                            int defaultValue)

hasSeparateFiles

public boolean hasSeparateFiles()

init

public void init()
          throws javax.servlet.ServletException
Initialize the resources that are held for the life of the servlet. Setup the database connection driver and the configured handlers for HTTP GET and HTTP POST requests.

Overrides:
init in class javax.servlet.GenericServlet
javax.servlet.ServletException

destroy

public void destroy()
Destroy the resources that are held for the life of the servlet.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

getConnection

public java.sql.Connection getConnection()
                                  throws javax.servlet.ServletException
Returns a connection to the back-end database. This connection must be closed.

Returns:
a connection to the back-end database.
javax.servlet.ServletException

getServerId

public int getServerId()
Returns the ID of the server.

Returns:
the ID of the server.

setServerId

public void setServerId(int serverId)
Sets the ID of the server.


getNumberOfStatisticHandlers

public int getNumberOfStatisticHandlers()
Returns the number of defined statistic handlers.

Returns:
the number of defined statistic handlers.

getStatisticHandlerClass

public java.lang.Class getStatisticHandlerClass(int i)
Returns the i-th defined statistic handler.

Parameters:
i - index
Returns:
the i-th defined statistic handler.

getStatisticHandlerName

public java.lang.String getStatisticHandlerName(java.lang.Class handler)
Searches the handler name by the specified class of this statistic handler.

Parameters:
handler - class of a statistic handler
Returns:
name of the handler; null if no handler is found.

getStatisticHandler

public AbstractHandler getStatisticHandler(java.lang.Class handler)
Searches the handler object by the specified class of this statistic handler.

Parameters:
handler - class of a statistic handler
Returns:
object of the handler; null if no handler is found.

getHandlerAddress

public java.lang.String getHandlerAddress(java.lang.Class handler)
Searches the handler address by the specified class of this GET handler.

Parameters:
handler - class of a statistic handler
Returns:
HTTP address of the handler; null if no handler is found.

doGet

protected void doGet(javax.servlet.http.HttpServletRequest req,
                     javax.servlet.http.HttpServletResponse resp)
              throws javax.servlet.ServletException,
                     java.io.IOException
Called by the server to allow this servlet to handle a GET request.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
req - contains the request the client has made of the servlet.
resp - contains the response the servlet sends to the client.
Throws:
java.io.IOException - if an I/O error occurs when the servlet handles the GET request.
javax.servlet.ServletException - if the request for the GET could not be handled.
See Also:
HttpServlet.doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

doPost

protected void doPost(javax.servlet.http.HttpServletRequest req,
                      javax.servlet.http.HttpServletResponse resp)
               throws javax.servlet.ServletException,
                      java.io.IOException
Called by the server to allow this servlet to handle a POST request.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
req - contains the request the client has made of the servlet.
resp - contains the response the servlet sends to the client.
Throws:
java.io.IOException - if an I/O error occurs when the servlet handles the POST request.
javax.servlet.ServletException - if the request for the POST could not be handled.
See Also:
HttpServlet.doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

addStatisticHandler

public void addStatisticHandler(java.lang.String name,
                                java.lang.String parameter,
                                java.util.List statisticHandlers)
                         throws java.lang.Exception
Adds a statistic handler.

java.lang.Exception

log

public void log(java.lang.String msg)
Overrides:
log in class javax.servlet.GenericServlet

log

public void log(java.lang.Throwable t)

initLogFile

private void initLogFile()

rollOver

private void rollOver(java.lang.String filename,
                      int maxBackupIndex)
Implements the usual roll over behaviour of log files.


findHandler

private java.lang.Object findHandler(java.util.List handlers,
                                     java.lang.String name)
Searches the handler by the specified name.

Parameters:
handlers - container with the handler
name - name of the handler which is searched
Returns:
instance of the handler which name starts with the specified name; null if no handler is found.

getInstance

private java.lang.Object getInstance(java.lang.Class handlerClass)
                              throws java.lang.Exception,
                                     java.lang.Error
Builds a new instance of the specified handler class

Parameters:
handlerClass - class of the handler
java.lang.Exception
java.lang.Error

ZetaGrid v1.9

For further technical papers, see ZetaGrid Technical Documentation.
 
Copyright © 2001,2002 Sebastian Wedeniwski. All Rights Reserved.