org.codehaus.cargo.container.jetty
Class JettyRemoteDeployer

java.lang.Object
  extended by org.codehaus.cargo.util.log.LoggedObject
      extended by org.codehaus.cargo.container.spi.deployer.AbstractDeployer
          extended by org.codehaus.cargo.container.spi.deployer.AbstractRemoteDeployer
              extended by org.codehaus.cargo.container.jetty.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.

Version:
$Id: JettyRemoteDeployer.java 1705 2008-09-02 13:14:55Z adriana $

Constructor Summary
JettyRemoteDeployer(RemoteContainer container)
          Remote deployer for the Jetty container.
 
Method Summary
protected  java.lang.String createDefaultDeployerUrl(Configuration configuration)
          Returns a deployerURL based on default values.
protected  java.net.HttpURLConnection createDeployConnection(WAR war)
          Creates an deploy connection for the deployer.
protected  java.net.HttpURLConnection createUndeployConnection(WAR war)
          Creates an undeploy connection for the deployer.
 void deploy(Deployable deployable)
          
protected  java.lang.String getResponseMessage(java.net.HttpURLConnection connection)
          Returns the response message from the server in a string format.
protected  void pipe(java.io.InputStream in, java.io.OutputStream out)
          Reads all the data from the specified input stream and writes it to the specified output stream.
 void redeploy(Deployable deployable)
          
protected  java.lang.String streamToString(java.io.InputStream in, java.lang.String charset)
          Gets the data from the specified input stream as a string using the specified charset.
protected static java.lang.String toAuthorization(java.lang.String username, java.lang.String password)
          Gets the HTTP Basic Authorization header value for the supplied username and password.
 void undeploy(Deployable deployable)
          Undeploy a Deployable from the running container.
 
Methods inherited from class org.codehaus.cargo.container.spi.deployer.AbstractRemoteDeployer
getType
 
Methods inherited from class org.codehaus.cargo.container.spi.deployer.AbstractDeployer
deploy, deploy, start, stop, undeploy
 
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.codehaus.cargo.util.log.Loggable
getLogger, setLogger
 

Constructor Detail

JettyRemoteDeployer

public JettyRemoteDeployer(RemoteContainer container)
Remote deployer for the Jetty container.

Parameters:
container - The container used for deployment
Method Detail

deploy

public void deploy(Deployable deployable)

Specified by:
deploy in interface Deployer
Overrides:
deploy in class AbstractDeployer

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

redeploy

public void redeploy(Deployable deployable)

Specified by:
redeploy in interface Deployer
Overrides:
redeploy in class AbstractDeployer

createDeployConnection

protected java.net.HttpURLConnection createDeployConnection(WAR war)
                                                     throws java.io.IOException
Creates an deploy connection for the deployer.

Parameters:
war - The war to be deployed
Returns:
The URL for the deployer
Throws:
java.io.IOException - If an IOException occurs

createUndeployConnection

protected java.net.HttpURLConnection createUndeployConnection(WAR war)
                                                       throws java.io.IOException
Creates an undeploy connection for the deployer.

Parameters:
war - The war to be undeployed
Returns:
The URL for the deployer
Throws:
java.io.IOException - If an IOException occurs

createDefaultDeployerUrl

protected java.lang.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 java.lang.String getResponseMessage(java.net.HttpURLConnection connection)
                                       throws java.io.IOException
Returns the response message from the server in a string format.

Parameters:
connection - The connection used
Returns:
The response message
Throws:
java.io.IOException - If an IO Exception occured

pipe

protected void pipe(java.io.InputStream in,
                    java.io.OutputStream out)
             throws java.io.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:
java.io.IOException - if an i/o error occurs

streamToString

protected java.lang.String streamToString(java.io.InputStream in,
                                          java.lang.String charset)
                                   throws java.io.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:
java.io.IOException - if an i/o error occurs

toAuthorization

protected static java.lang.String toAuthorization(java.lang.String username,
                                                  java.lang.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


Copyright © 2004-2011 Codehaus. All Rights Reserved.