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  String createDefaultDeployerUrl(Configuration configuration)
          Returns a deployerURL based on default values.
protected  HttpURLConnection createDeployConnection(WAR war)
          Creates an deploy connection for the deployer.
protected  HttpURLConnection createUndeployConnection(WAR war)
          Creates an undeploy connection for the deployer.
 void deploy(Deployable deployable)
          Deploy a Deployable to the running container and make it available for requests.
protected  String getResponseMessage(HttpURLConnection connection)
          Returns the response message from the server in a string format.
protected  void pipe(InputStream in, OutputStream out)
          Reads all the data from the specified input stream and writes it to the specified output stream.
 void redeploy(Deployable deployable)
          Redeploy a Deployable already deployed to the running container.
protected  String streamToString(InputStream in, String charset)
          Gets the data from the specified input stream as a string using the specified charset.
protected static String toAuthorization(String username, 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)
Deploy a Deployable to the running container and make it available for requests.

Specified by:
deploy in interface Deployer
Overrides:
deploy in class AbstractDeployer
Parameters:
deployable - the Deployable to deploy
See Also:
Deployer.deploy(Deployable)

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
See Also:
Deployer.undeploy(org.codehaus.cargo.container.deployable.Deployable)

redeploy

public void redeploy(Deployable deployable)

Redeploy a Deployable already deployed to the running container. The service becomes available for requests.

Note that this method will be unsupported by the Deployers based on the AbstractCopyingInstalledLocalDeployer.

Specified by:
redeploy in interface Deployer
Overrides:
redeploy in class AbstractDeployer
Parameters:
deployable - the Deployable to redeploy
See Also:
Deployer.redeploy(Deployable)

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


Copyright © 2004-2012 Codehaus. All Rights Reserved.