org.codehaus.cargo.deployer.jetty
Class DeployerServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.codehaus.cargo.deployer.jetty.DeployerServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class DeployerServlet
extends javax.servlet.http.HttpServlet

This servlet is used to control deploy, undeploy, redeploy, start, and stop a web application within the jetty server.

Version:
$Id: DeployerServlet.java 1745 2008-10-13 09:43:29Z alitokmen $
See Also:
Serialized Form

Constructor Summary
DeployerServlet(org.mortbay.jetty.Server server)
          Creates the DeployerServlet and gives the servlet reference to the server in which it is deployed.This gives the servlet access to the server internals which allows for deployment control.
 
Method Summary
protected  void deleteDirectory(File webAppFile)
          Recursively delete the webapp directory.
protected  void deploy(javax.servlet.http.HttpServletResponse response, String contextPath, String warURL)
          Deploy the war to the given context path.
protected  void deployArchive(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String contextPath)
          Deploys the archive to the server.
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Performs the http GET method.
protected  void doPut(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Performs the http PUT method.
protected  org.mortbay.jetty.handler.ContextHandler getContextHandler(String context)
          Returns the context handler for the given context.
protected  File getFile(String contextPath)
          Returns the file if it exists for the specified context path.
protected  String getWebAppLocation(org.mortbay.jetty.webapp.WebAppContext webapp)
          Returns the file location for the specified webapp.
protected  void reload(javax.servlet.http.HttpServletResponse response, String contextPath)
          Reload the application specified with the given context.
protected  void sendError(javax.servlet.http.HttpServletResponse response, String message)
          Sends the given error message back in the http response.
protected  void sendMessage(javax.servlet.http.HttpServletResponse response, String message)
          Sends the given message back in the http response.
protected  void start(javax.servlet.http.HttpServletResponse response, String contextPath)
          Start the webapp for the given context path
protected  void stop(javax.servlet.http.HttpServletResponse response, String contextPath)
          Stop the webapp at the given context.
protected  void undeploy(javax.servlet.http.HttpServletResponse response, String contextPath)
          Undeploy the webapp with the given context path.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DeployerServlet

public DeployerServlet(org.mortbay.jetty.Server server)
Creates the DeployerServlet and gives the servlet reference to the server in which it is deployed.This gives the servlet access to the server internals which allows for deployment control.

Parameters:
server - The server object for the currently running server
Method Detail

doGet

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

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - The http request
response - The http response
Throws:
javax.servlet.ServletException - If a servlet exception occurs
IOException - If an io exception occurs

doPut

protected void doPut(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     IOException
Performs the http PUT method.

Overrides:
doPut in class javax.servlet.http.HttpServlet
Parameters:
request - The http request
response - The http response
Throws:
javax.servlet.ServletException - If a servlet exception occurs
IOException - If an io exception occurs

deployArchive

protected void deployArchive(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             String contextPath)
                      throws IOException
Deploys the archive to the server.

Parameters:
request - The http request
response - The http response
contextPath - The context path for the deployed archive
Throws:
IOException - If an io exception occurs

getFile

protected File getFile(String contextPath)
Returns the file if it exists for the specified context path. If the file does not exist then it will return null.

Parameters:
contextPath - The context path for the web app
Returns:
The file associated with the context path

sendMessage

protected void sendMessage(javax.servlet.http.HttpServletResponse response,
                           String message)
                    throws IOException
Sends the given message back in the http response.

Parameters:
response - The http response
message - The message to be send
Throws:
IOException - If an io exception occurs

sendError

protected void sendError(javax.servlet.http.HttpServletResponse response,
                         String message)
                  throws IOException
Sends the given error message back in the http response.

Parameters:
response - The http response
message - The error message to be send
Throws:
IOException - If an io exception occurs

deploy

protected void deploy(javax.servlet.http.HttpServletResponse response,
                      String contextPath,
                      String warURL)
               throws IOException
Deploy the war to the given context path.

Parameters:
response - The http response
contextPath - The context path to use
warURL - The location of the war
Throws:
IOException - If an io exception occurs

reload

protected void reload(javax.servlet.http.HttpServletResponse response,
                      String contextPath)
               throws IOException
Reload the application specified with the given context. Not yet implemented

Parameters:
response - The http response
contextPath - The context path
Throws:
IOException - If an IO exception occurs

undeploy

protected void undeploy(javax.servlet.http.HttpServletResponse response,
                        String contextPath)
                 throws IOException
Undeploy the webapp with the given context path.

Parameters:
response - The http response
contextPath - The context path
Throws:
IOException - If an IO exception occurs

deleteDirectory

protected void deleteDirectory(File webAppFile)
Recursively delete the webapp directory.

Parameters:
webAppFile - The file to delete

getWebAppLocation

protected String getWebAppLocation(org.mortbay.jetty.webapp.WebAppContext webapp)
Returns the file location for the specified webapp.

Parameters:
webapp - The webapp
Returns:
The location of the webapp

stop

protected void stop(javax.servlet.http.HttpServletResponse response,
                    String contextPath)
             throws IOException
Stop the webapp at the given context. Not yet implemented

Parameters:
response - The http response
contextPath - The webapp's context
Throws:
IOException - If an IO exception occured

start

protected void start(javax.servlet.http.HttpServletResponse response,
                     String contextPath)
              throws IOException
Start the webapp for the given context path

Parameters:
response - The http response
contextPath - The webapp's context
Throws:
IOException - If an IO exception occured

getContextHandler

protected org.mortbay.jetty.handler.ContextHandler getContextHandler(String context)
Returns the context handler for the given context.

Parameters:
context - The webapp context
Returns:
The context handler


Copyright © 2004-2012 Codehaus. All Rights Reserved.