Class JettyRemoteDeployer

  • All Implemented Interfaces:
    Deployer, Loggable

    public class JettyRemoteDeployer
    extends AbstractRemoteDeployer
    A remote deployer for the Jetty container.

    NOTE: undeploy DELETES the webapp from the Jetty webapp directory.

    Limitations:
    • Will not undeploy files from anywhere other than the servers webapp directory
    • Cannot be used to undeploy webapps that were deployed using a xml context file in /contexts
    • Should not be used with multiple webapps sharing a common war
    • Constructor Detail

      • JettyRemoteDeployer

        public JettyRemoteDeployer​(RemoteContainer container)
        Remote deployer for the Jetty container.
        Parameters:
        container - The container used for deployment
    • Method Detail

      • undeploy

        public void undeploy​(Deployable deployable)
        Undeploy a Deployable from the running container. NOTE: THIS WILL DELETE THE WAR FROM THE WEBAPP DIRECTORY
        Specified by:
        undeploy in interface Deployer
        Overrides:
        undeploy in class AbstractDeployer
        Parameters:
        deployable - The deployable to be undeployed
      • createDeployConnection

        protected HttpURLConnection createDeployConnection​(WAR war)
                                                    throws IOException
        Creates an deploy connection for the deployer.
        Parameters:
        war - The war to be deployed
        Returns:
        The URL for the deployer
        Throws:
        IOException - If an IOException occurs
      • createUndeployConnection

        protected HttpURLConnection createUndeployConnection​(WAR war)
                                                      throws IOException
        Creates an undeploy connection for the deployer.
        Parameters:
        war - The war to be undeployed
        Returns:
        The URL for the deployer
        Throws:
        IOException - If an IOException occurs
      • createDefaultDeployerUrl

        protected String createDefaultDeployerUrl​(Configuration configuration)
        Returns a deployerURL based on default values.
        Parameters:
        configuration - The server configuration object
        Returns:
        The url for the deployer
      • getResponseMessage

        protected String getResponseMessage​(HttpURLConnection connection)
                                     throws IOException
        Returns the response message from the server in a string format.
        Parameters:
        connection - The connection used
        Returns:
        The response message
        Throws:
        IOException - If an IO Exception occured
      • pipe

        protected void pipe​(InputStream in,
                            OutputStream out)
                     throws IOException
        Reads all the data from the specified input stream and writes it to the specified output stream. Both streams are also closed. TODO: make these commands as part of a generic helper class in Cargo. Duplicate function in the Tomcat remote deployer
        Parameters:
        in - the input stream to read from
        out - the output stream to write to
        Throws:
        IOException - if an i/o error occurs
      • streamToString

        protected String streamToString​(InputStream in,
                                        String charset)
                                 throws IOException
        Gets the data from the specified input stream as a string using the specified charset. TODO: make these commands as part of a generic helper class in Cargo. Duplicate function in the Tomcat remote deployer
        Parameters:
        in - the input stream to read from
        charset - the charset to use when constructing the string
        Returns:
        a string representation of the data read from the input stream
        Throws:
        IOException - if an i/o error occurs
      • toAuthorization

        protected static String toAuthorization​(String username,
                                                String password)
        Gets the HTTP Basic Authorization header value for the supplied username and password. TODO: make these commands as part of a generic helper class in Cargo. Duplicate function in the Tomcat remote deployer
        Parameters:
        username - the username to use for authentication
        password - the password to use for authentication
        Returns:
        the HTTP Basic Authorization header value
      • lastLine

        protected String lastLine​(String string)
                           throws IOException
        Returns the last line of a string.
        Parameters:
        string - String of which to get the last line
        Returns:
        Last line of string
        Throws:
        IOException - if an i/o error occurs