Class JettyWebAppContext<T>

  • Type Parameters:
    T - Jetty WebAppContext type
    All Implemented Interfaces:
    JettyDeployer.Context

    public abstract class JettyWebAppContext<T>
    extends Object
    implements JettyDeployer.Context
    Common Jetty context operations used by the Cargo Jetty deployer.
    • Constructor Detail

      • JettyWebAppContext

        protected JettyWebAppContext​(T currentContext)
        Creates a context adapter.
        Parameters:
        currentContext - current Jetty WebAppContext
    • Method Detail

      • getCurrentContext

        protected T getCurrentContext()
        Returns the current WebAppContext.
        Returns:
        current WebAppContext
      • getServer

        protected abstract org.eclipse.jetty.server.Server getServer()
        Returns the Jetty server.
        Returns:
        Jetty server
      • isWebAppContext

        protected abstract boolean isWebAppContext​(org.eclipse.jetty.server.Handler handler)
        Returns whether a handler is a WebAppContext.
        Parameters:
        handler - Jetty handler
        Returns:
        true if the handler is a WebAppContext
      • getContextPath

        protected abstract String getContextPath​(org.eclipse.jetty.server.Handler handler)
        Returns the context path of a WebAppContext.
        Parameters:
        handler - WebAppContext handler
        Returns:
        context path
      • deployWebApp

        protected abstract void deployWebApp​(String contextPath,
                                             File warFile,
                                             org.eclipse.jetty.server.handler.ContextHandlerCollection contextCollection)
                                      throws Exception
        Creates and starts a WebAppContext.
        Parameters:
        contextPath - context path
        warFile - WAR file
        contextCollection - context handler collection
        Throws:
        Exception - if deployment fails
      • undeployWebApp

        protected abstract String undeployWebApp​(Object contextHandler,
                                                 org.eclipse.jetty.server.handler.ContextHandlerCollection contextCollection)
                                          throws Exception
        Stops and removes a WebAppContext.
        Parameters:
        contextHandler - context handler
        contextCollection - context handler collection
        Returns:
        WAR location
        Throws:
        Exception - if undeployment fails
      • getContextHandler

        public Object getContextHandler​(String contextPath)
        Finds a deployed context by its context path.
        Specified by:
        getContextHandler in interface JettyDeployer.Context
        Parameters:
        contextPath - context path
        Returns:
        context handler, or null if none exists
      • deploy

        public void deploy​(String contextPath,
                           File warFile)
                    throws Exception
        Deploys a WAR at the specified context path.
        Specified by:
        deploy in interface JettyDeployer.Context
        Parameters:
        contextPath - context path
        warFile - WAR file
        Throws:
        Exception - if deployment fails
      • undeploy

        public String undeploy​(Object contextHandler)
                        throws Exception
        Stops and removes a deployed context.
        Specified by:
        undeploy in interface JettyDeployer.Context
        Parameters:
        contextHandler - context handler
        Returns:
        location of the deployed WAR
        Throws:
        Exception - if undeployment fails