org.apache.lenya.cms.scheduler
Class LoadQuartzServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.lenya.cms.scheduler.LoadQuartzServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class LoadQuartzServlet
extends javax.servlet.http.HttpServlet

A simple servlet that starts an instance of a Quartz scheduler.

See Also:
Serialized Form

Field Summary
protected static java.lang.String ADD
           
static java.lang.String CONFIGURATION_ELEMENT
           
protected static java.lang.String DELETE
           
protected static java.lang.String DOCUMENT_DELETED
           
protected static java.lang.String MODIFY
           
static java.lang.String PARAMETER_ACTION
           
static java.lang.String PARAMETER_DOCUMENT_URL
           
static java.lang.String PARAMETER_PUBLICATION_ID
           
static java.lang.String PREFIX
           
static java.lang.String SERVLET_URL
           
 
Constructor Summary
LoadQuartzServlet()
           
 
Method Summary
 void deleteDocumentJobs(Document document)
          Deletes
 void destroy()
          Shuts down the scheduler.
static void destroyScheduler()
          Shuts down the scheduler.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles a GET request.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Handles a POST request.
static java.lang.String getDeleteDocumentRequestURI(java.lang.String port, java.lang.String servletContextPath, Document document)
          Generates the request URI needed to delete the jobs for a certain document.
protected  java.lang.String getJobId(NamespaceMap schedulerParameters)
          Extracts the job ID from the scheduler parameters.
static SchedulerWrapper getScheduler()
          Returns the scheduler wrapper.
static NamespaceMap getSchedulerParameters(javax.servlet.http.HttpServletRequest request)
          Extracts the scheduler parameters from a request.
static LoadQuartzServlet getServlet(java.lang.String contextPath)
          Returns the servlet for a certain canonical servlet context path.
 java.io.File getServletContextDirectory()
          Returns the servlet context path.
protected  void handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles a servlet request.
 void init(javax.servlet.ServletConfig config)
          Initializes the servlet.
protected  void logSessionAttributes(javax.servlet.http.HttpServletRequest request)
          Logs the session attributes of a request.
 void process()
          Process.
 void restoreJobs()
          Restores the jobs.
static void ShutdownHook()
          This method sets a ShutdownHook to the system This traps the CTRL+C or kill signal and shutdows Correctly the system.
 
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, 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

PREFIX

public static final java.lang.String PREFIX
See Also:
Constant Field Values

PARAMETER_ACTION

public static final java.lang.String PARAMETER_ACTION
See Also:
Constant Field Values

PARAMETER_PUBLICATION_ID

public static final java.lang.String PARAMETER_PUBLICATION_ID
See Also:
Constant Field Values

PARAMETER_DOCUMENT_URL

public static final java.lang.String PARAMETER_DOCUMENT_URL
See Also:
Constant Field Values

CONFIGURATION_ELEMENT

public static final java.lang.String CONFIGURATION_ELEMENT
See Also:
Constant Field Values

ADD

protected static final java.lang.String ADD
See Also:
Constant Field Values

MODIFY

protected static final java.lang.String MODIFY
See Also:
Constant Field Values

DELETE

protected static final java.lang.String DELETE
See Also:
Constant Field Values

DOCUMENT_DELETED

protected static final java.lang.String DOCUMENT_DELETED
See Also:
Constant Field Values

SERVLET_URL

public static final java.lang.String SERVLET_URL
See Also:
Constant Field Values
Constructor Detail

LoadQuartzServlet

public LoadQuartzServlet()
Method Detail

getScheduler

public static SchedulerWrapper getScheduler()
Returns the scheduler wrapper.

Returns:
A scheduler wrapper.

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initializes the servlet.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - The servlet configuration.
Throws:
javax.servlet.ServletException - when something went wrong.

process

public void process()
             throws javax.servlet.ServletException,
                    org.quartz.SchedulerException
Process.

Throws:
javax.servlet.ServletException - when an error occurs.
org.quartz.SchedulerException - when an error occurs.

destroy

public void destroy()
Shuts down the scheduler.

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

destroyScheduler

public static void destroyScheduler()
Shuts down the scheduler.


ShutdownHook

public static void ShutdownHook()
                         throws java.lang.Exception
This method sets a ShutdownHook to the system This traps the CTRL+C or kill signal and shutdows Correctly the system.

Throws:
java.lang.Exception - when something went wrong.

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException,
                  javax.servlet.ServletException
Handles a GET request.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - The request.
response - The response.
Throws:
java.io.IOException - when an error occured.
javax.servlet.ServletException - when an error occured.

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse resp)
            throws javax.servlet.ServletException,
                   java.io.IOException
Handles a POST request.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
req - The requust.
resp - The response.
Throws:
javax.servlet.ServletException - when an error occured.
java.io.IOException - when an error occured.

handleRequest

protected void handleRequest(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws java.io.IOException
Handles a servlet request.

Parameters:
request - The request.
response - The response.
Throws:
java.io.IOException - when something went wrong.

getSchedulerParameters

public static NamespaceMap getSchedulerParameters(javax.servlet.http.HttpServletRequest request)
Extracts the scheduler parameters from a request.

Parameters:
request - The request.
Returns:
A namespace map.

deleteDocumentJobs

public void deleteDocumentJobs(Document document)
                        throws DocumentBuildException,
                               org.quartz.SchedulerException,
                               PublicationException
Deletes

Parameters:
document -
Throws:
DocumentBuildException
org.quartz.SchedulerException
PublicationException

getJobId

protected java.lang.String getJobId(NamespaceMap schedulerParameters)
Extracts the job ID from the scheduler parameters.

Parameters:
schedulerParameters - A namespace map.
Returns:
A string.

logSessionAttributes

protected void logSessionAttributes(javax.servlet.http.HttpServletRequest request)
Logs the session attributes of a request.

Parameters:
request - The request.

getServletContextDirectory

public java.io.File getServletContextDirectory()
Returns the servlet context path.

Returns:
A string.

restoreJobs

public void restoreJobs()
                 throws org.quartz.SchedulerException
Restores the jobs.

Throws:
org.quartz.SchedulerException - when something went wrong.

getServlet

public static LoadQuartzServlet getServlet(java.lang.String contextPath)
Returns the servlet for a certain canonical servlet context path.

Parameters:
contextPath - The canonical servlet context path.
Returns:
A LoadQuartzServlet.

getDeleteDocumentRequestURI

public static java.lang.String getDeleteDocumentRequestURI(java.lang.String port,
                                                           java.lang.String servletContextPath,
                                                           Document document)
Generates the request URI needed to delete the jobs for a certain document.

Parameters:
document - The document.
Returns:
A string.


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.