com.webhydra.slug
Class Slug

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.webhydra.slug.Slug
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class Slug
extends javax.servlet.http.HttpServlet

Sluggish processes interface servlet. Process requests for SuggishProcess(es)' ProcessStatus The following calling convention utilizes Serlet's Path Info and Request's parameters:
/<ACTION>[/<TRANSLATOR>]/?[rn=<RUNNER>&]pid=<PID>[;&url=<URL>]

Example URL:
http://my.server.com/myapp/slug/status/xsd/?rn=unlimited&pid=1140468189:1&url=/myapp/done?pid=1140468189:1

Version:
1.0
Author:
rossen
See Also:
ISlugRunner.add(SluggishProcess,String), SluggishProcess, ISlugConfigParser, PropertiesConfigParser, Serialized Form

Field Summary
static java.lang.String DIST_VERSION
          CVS version of the distribution.
static java.lang.String NAME
          Name of the servlet
static java.lang.String PARAM_NAME_CONFIG
          Name of the configuration file name parameter.
static java.lang.String PARAM_NAME_PARSER
          Name of the configuration parser class name parameter.
static java.lang.String PARAM_PID
          Mandatory request parameter with PID value
static java.lang.String PARAM_REFIRECT_URL
          Parameter for redirection
static java.lang.String PARAM_RUNNER_NAME
          Optinal runner name parameter.
static java.lang.String PATH_CANCEL
          Path Info constant for the process cancelation
static java.lang.String PATH_CONSUME
          Path Info constant for the process consompsion
static java.lang.String PATH_STATUS
          Path Info constant for the status processor
 
Constructor Summary
Slug()
           
 
Method Summary
 void destroy()
          Overrides the default implelentation.
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles the HTTP GET method.
protected  void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles the HTTP POST method.
 java.lang.String getServletInfo()
          Returns a short description of the servlet.
protected  com.webhydra.slug.SlugConfig getSlugConfig()
          Provides convinient acess to the cfg property.
 void init()
          Overrides the default implementation from javax.servlet.GenericServlet
protected  void processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Processes requests for both HTTP GET and POST methods.
protected  void reportStatus(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ProcessStatus ps, IProcessStatusTranslator translator)
          Report process' status
protected  void setBody(javax.servlet.http.HttpServletResponse response, java.lang.String body, java.lang.String contentType)
          Prints provided body to the browser.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIST_VERSION

public static final java.lang.String DIST_VERSION
CVS version of the distribution.

See Also:
Constant Field Values

NAME

public static final java.lang.String NAME
Name of the servlet

See Also:
Constant Field Values

PARAM_NAME_CONFIG

public static final java.lang.String PARAM_NAME_CONFIG
Name of the configuration file name parameter. This paramater points to a file that will be used as input for the ISlugConfigParser implementation.

See Also:
Constant Field Values

PARAM_NAME_PARSER

public static final java.lang.String PARAM_NAME_PARSER
Name of the configuration parser class name parameter. This parameter defines the class name of a ISlugConfigParser implementation.

See Also:
Constant Field Values

PATH_STATUS

public static final java.lang.String PATH_STATUS
Path Info constant for the status processor

See Also:
Constant Field Values

PATH_CONSUME

public static final java.lang.String PATH_CONSUME
Path Info constant for the process consompsion

See Also:
Constant Field Values

PATH_CANCEL

public static final java.lang.String PATH_CANCEL
Path Info constant for the process cancelation

See Also:
Constant Field Values

PARAM_PID

public static final java.lang.String PARAM_PID
Mandatory request parameter with PID value

See Also:
Constant Field Values

PARAM_RUNNER_NAME

public static final java.lang.String PARAM_RUNNER_NAME
Optinal runner name parameter. If missed default runner will be used.

See Also:
Constant Field Values

PARAM_REFIRECT_URL

public static final java.lang.String PARAM_REFIRECT_URL
Parameter for redirection

See Also:
Constant Field Values
Constructor Detail

Slug

public Slug()
Method Detail

getServletInfo

public java.lang.String getServletInfo()
Returns a short description of the servlet.

Specified by:
getServletInfo in interface javax.servlet.Servlet
Overrides:
getServletInfo in class javax.servlet.GenericServlet
Returns:
version info about the serlvet.

processRequest

protected void processRequest(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
                       throws javax.servlet.ServletException,
                              java.io.IOException
Processes requests for both HTTP GET and POST methods.
Resulting Status codes:
501
Provided runner or translator cannot be found or requested action is not supported
404
When PID is missing or is empty.
410
When PID can not be found and no redirect URL is provided
302
When requested process is completed or canceled and redirection URL is provided

Parameters:
request - servlet request
response - servlet response
Throws:
javax.servlet.ServletException
java.io.IOException

setBody

protected void setBody(javax.servlet.http.HttpServletResponse response,
                       java.lang.String body,
                       java.lang.String contentType)
                throws java.io.IOException
Prints provided body to the browser.

Parameters:
response - current HTTP response.
body - HTML page to send to the browser.
contentType - response content type.
Throws:
java.io.IOException

reportStatus

protected void reportStatus(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            ProcessStatus ps,
                            IProcessStatusTranslator translator)
                     throws javax.servlet.ServletException,
                            java.io.IOException
Report process' status

Parameters:
request - servlet request
response - servlet response
ps - status of current process
translator - ProcessStarusTranslator instance.
Throws:
javax.servlet.ServletException
java.io.IOException

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Handles the HTTP GET method.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - servlet request
response - servlet response
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

protected void doPost(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response)
               throws javax.servlet.ServletException,
                      java.io.IOException
Handles the HTTP POST method.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - servlet request
response - servlet response
Throws:
javax.servlet.ServletException
java.io.IOException

init

public void init()
          throws javax.servlet.ServletException
Overrides the default implementation from javax.servlet.GenericServlet

Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException - when important parameters are missing.

getSlugConfig

protected com.webhydra.slug.SlugConfig getSlugConfig()
Provides convinient acess to the cfg property.

Returns:
current SlugConfig in use.

destroy

public void destroy()
Overrides the default implelentation. Clean and releases all ISlugRunners and releases all IProcessStatusTranslators.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet
See Also:
ISlugService.release(), ISlugService.release(), ISlugService.release()