Class 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.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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 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 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
    • 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
      • 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
      • 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