org.codehaus.cargo.container.tomcat.internal
Class TomcatManager

java.lang.Object
  extended byorg.codehaus.cargo.util.log.LoggedObject
      extended byorg.codehaus.cargo.container.tomcat.internal.TomcatManager
All Implemented Interfaces:
org.codehaus.cargo.util.log.Loggable

public class TomcatManager
extends org.codehaus.cargo.util.log.LoggedObject

A Tomcat manager webapp invocation wrapper.

Version:
$Id: TomcatManager.java 1127 2006-07-23 10:23:10Z vmassol $

Constructor Summary
TomcatManager(java.net.URL url)
          Creates a Tomcat manager wrapper for the specified URL that uses a username of admin, an empty password and ISO-8859-1 URL encoding.
TomcatManager(java.net.URL url, java.lang.String username)
          Creates a Tomcat manager wrapper for the specified URL and username that uses an empty password and ISO-8859-1 URL encoding.
TomcatManager(java.net.URL url, java.lang.String username, java.lang.String password)
          Creates a Tomcat manager wrapper for the specified URL, username and password that uses ISO-8859-1 URL encoding.
TomcatManager(java.net.URL url, java.lang.String username, java.lang.String password, java.lang.String charset)
          Creates a Tomcat manager wrapper for the specified URL, username, password and URL encoding.
 
Method Summary
 void deploy(java.lang.String path, java.io.InputStream war)
          Deploys the specified WAR as a HTTP PUT to the specified context path.
 void deploy(java.lang.String path, java.io.InputStream war, boolean update)
          Deploys the specified WAR as a HTTP PUT to the specified context path, optionally undeploying the webapp if it already exists.
 void deploy(java.lang.String path, java.io.InputStream war, boolean update, java.lang.String tag)
          Deploys the specified WAR as a HTTP PUT to the specified context path, optionally undeploying the webapp if it already exists and using the specified tag name.
 void deploy(java.lang.String path, java.net.URL war)
          Deploys the specified WAR as a URL to the specified context path.
 void deploy(java.lang.String path, java.net.URL war, boolean update)
          Deploys the specified WAR as a URL to the specified context path, optionally undeploying the webapp if it already exists.
 void deploy(java.lang.String path, java.net.URL war, boolean update, java.lang.String tag)
          Deploys the specified WAR as a URL to the specified context path, optionally undeploying the webapp if it already exists and using the specified tag name.
 void deployContext(java.lang.String path, java.net.URL config)
          Deploys the specified context XML configuration to the specified context path.
 void deployContext(java.lang.String path, java.net.URL config, boolean update)
          Deploys the specified context XML configuration to the specified context path, optionally undeploying the webapp if it already exists.
 void deployContext(java.lang.String path, java.net.URL config, boolean update, java.lang.String tag)
          Deploys the specified context XML configuration to the specified context path, optionally undeploying the webapp if it already exists and using the specified tag name.
 void deployContext(java.lang.String path, java.net.URL config, java.net.URL war)
          Deploys the specified context XML configuration and WAR as a URL to the specified context path.
 void deployContext(java.lang.String path, java.net.URL config, java.net.URL war, boolean update)
          Deploys the specified context XML configuration and WAR as a URL to the specified context path, optionally undeploying the webapp if it already exists.
 void deployContext(java.lang.String path, java.net.URL config, java.net.URL war, boolean update, java.lang.String tag)
          Deploys the specified context XML configuration and WAR as a URL to the specified context path, optionally undeploying the webapp if it already exists and using the specified tag name.
 java.lang.String getCharset()
          Gets the URL encoding charset to use when communicating with Tomcat manager.
 java.lang.String getPassword()
          Gets the password to use when authenticating with Tomcat manager.
 TomcatDeployableStatus getStatus(java.lang.String path)
          Return the status of the webapp at the specified context path.
 java.net.URL getURL()
          Gets the full URL of the Tomcat manager instance.
 java.lang.String getUserAgent()
          Gets the user agent name to use when communicating with Tomcat manager.
 java.lang.String getUserName()
          Gets the username to use when authenticating with Tomcat manager.
protected  void invoke(java.lang.String path)
          Invokes Tomcat manager with the specified command.
protected  java.lang.String invoke(java.lang.String path, java.io.InputStream data)
          Invokes Tomcat manager with the specified command and content data.
 java.lang.String list()
          List currently deployed webapps.
 void reload(java.lang.String path)
          Reloads the webapp at the specified context path.
 void remove(java.lang.String path)
          Removes the webapp at the specified context path.
 void setUserAgent(java.lang.String userAgent)
          Sets the user agent name to use when communicating with Tomcat manager.
 void start(java.lang.String path)
          Starts the webapp at the specified context path.
 void stop(java.lang.String path)
          Stops the webapp at the specified context path.
 void undeploy(java.lang.String path)
          Undeploys the webapp at the specified context path.
 
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
 

Constructor Detail

TomcatManager

public TomcatManager(java.net.URL url)
Creates a Tomcat manager wrapper for the specified URL that uses a username of admin, an empty password and ISO-8859-1 URL encoding.

Parameters:
url - the full URL of the Tomcat manager instance to use

TomcatManager

public TomcatManager(java.net.URL url,
                     java.lang.String username)
Creates a Tomcat manager wrapper for the specified URL and username that uses an empty password and ISO-8859-1 URL encoding.

Parameters:
url - the full URL of the Tomcat manager instance to use
username - the username to use when authenticating with Tomcat manager

TomcatManager

public TomcatManager(java.net.URL url,
                     java.lang.String username,
                     java.lang.String password)
Creates a Tomcat manager wrapper for the specified URL, username and password that uses ISO-8859-1 URL encoding.

Parameters:
url - the full URL of the Tomcat manager instance to use
username - the username to use when authenticating with Tomcat manager
password - the password to use when authenticating with Tomcat manager

TomcatManager

public TomcatManager(java.net.URL url,
                     java.lang.String username,
                     java.lang.String password,
                     java.lang.String charset)
Creates a Tomcat manager wrapper for the specified URL, username, password and URL encoding.

Parameters:
url - the full URL of the Tomcat manager instance to use
username - the username to use when authenticating with Tomcat manager
password - the password to use when authenticating with Tomcat manager
charset - the URL encoding charset to use when communicating with Tomcat manager
Method Detail

getURL

public java.net.URL getURL()
Gets the full URL of the Tomcat manager instance.

Returns:
the full URL of the Tomcat manager instance

getUserName

public java.lang.String getUserName()
Gets the username to use when authenticating with Tomcat manager.

Returns:
the username to use when authenticating with Tomcat manager

getPassword

public java.lang.String getPassword()
Gets the password to use when authenticating with Tomcat manager.

Returns:
the password to use when authenticating with Tomcat manager

getCharset

public java.lang.String getCharset()
Gets the URL encoding charset to use when communicating with Tomcat manager.

Returns:
the URL encoding charset to use when communicating with Tomcat manager

getUserAgent

public java.lang.String getUserAgent()
Gets the user agent name to use when communicating with Tomcat manager.

Returns:
the user agent name to use when communicating with Tomcat manager

setUserAgent

public void setUserAgent(java.lang.String userAgent)
Sets the user agent name to use when communicating with Tomcat manager.

Parameters:
userAgent - the user agent name to use when communicating with Tomcat manager

deploy

public void deploy(java.lang.String path,
                   java.net.URL war)
            throws TomcatManagerException,
                   java.io.IOException
Deploys the specified WAR as a URL to the specified context path.

Parameters:
path - the webapp context path to deploy to
war - the URL of the WAR to deploy
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deploy

public void deploy(java.lang.String path,
                   java.net.URL war,
                   boolean update)
            throws TomcatManagerException,
                   java.io.IOException
Deploys the specified WAR as a URL to the specified context path, optionally undeploying the webapp if it already exists.

Parameters:
path - the webapp context path to deploy to
war - the URL of the WAR to deploy
update - whether to first undeploy the webapp if it already exists
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deploy

public void deploy(java.lang.String path,
                   java.net.URL war,
                   boolean update,
                   java.lang.String tag)
            throws TomcatManagerException,
                   java.io.IOException
Deploys the specified WAR as a URL to the specified context path, optionally undeploying the webapp if it already exists and using the specified tag name.

Parameters:
path - the webapp context path to deploy to
war - the URL of the WAR to deploy
update - whether to first undeploy the webapp if it already exists
tag - the tag name to use
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deploy

public void deploy(java.lang.String path,
                   java.io.InputStream war)
            throws TomcatManagerException,
                   java.io.IOException
Deploys the specified WAR as a HTTP PUT to the specified context path.

Parameters:
path - the webapp context path to deploy to
war - an input stream to the WAR to deploy
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deploy

public void deploy(java.lang.String path,
                   java.io.InputStream war,
                   boolean update)
            throws TomcatManagerException,
                   java.io.IOException
Deploys the specified WAR as a HTTP PUT to the specified context path, optionally undeploying the webapp if it already exists.

Parameters:
path - the webapp context path to deploy to
war - an input stream to the WAR to deploy
update - whether to first undeploy the webapp if it already exists
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deploy

public void deploy(java.lang.String path,
                   java.io.InputStream war,
                   boolean update,
                   java.lang.String tag)
            throws TomcatManagerException,
                   java.io.IOException
Deploys the specified WAR as a HTTP PUT to the specified context path, optionally undeploying the webapp if it already exists and using the specified tag name.

Parameters:
path - the webapp context path to deploy to
war - an input stream to the WAR to deploy
update - whether to first undeploy the webapp if it already exists
tag - the tag name to use
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deployContext

public void deployContext(java.lang.String path,
                          java.net.URL config)
                   throws TomcatManagerException,
                          java.io.IOException
Deploys the specified context XML configuration to the specified context path.

Parameters:
path - the webapp context path to deploy to
config - the URL of the context XML configuration to deploy
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deployContext

public void deployContext(java.lang.String path,
                          java.net.URL config,
                          boolean update)
                   throws TomcatManagerException,
                          java.io.IOException
Deploys the specified context XML configuration to the specified context path, optionally undeploying the webapp if it already exists.

Parameters:
path - the webapp context path to deploy to
config - the URL of the context XML configuration to deploy
update - whether to first undeploy the webapp if it already exists
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deployContext

public void deployContext(java.lang.String path,
                          java.net.URL config,
                          boolean update,
                          java.lang.String tag)
                   throws TomcatManagerException,
                          java.io.IOException
Deploys the specified context XML configuration to the specified context path, optionally undeploying the webapp if it already exists and using the specified tag name.

Parameters:
path - the webapp context path to deploy to
config - the URL of the context XML configuration to deploy
update - whether to first undeploy the webapp if it already exists
tag - the tag name to use
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deployContext

public void deployContext(java.lang.String path,
                          java.net.URL config,
                          java.net.URL war)
                   throws TomcatManagerException,
                          java.io.IOException
Deploys the specified context XML configuration and WAR as a URL to the specified context path.

Parameters:
path - the webapp context path to deploy to
config - the URL of the context XML configuration to deploy
war - the URL of the WAR to deploy
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deployContext

public void deployContext(java.lang.String path,
                          java.net.URL config,
                          java.net.URL war,
                          boolean update)
                   throws TomcatManagerException,
                          java.io.IOException
Deploys the specified context XML configuration and WAR as a URL to the specified context path, optionally undeploying the webapp if it already exists.

Parameters:
path - the webapp context path to deploy to
config - the URL of the context XML configuration to deploy
war - the URL of the WAR to deploy
update - whether to first undeploy the webapp if it already exists
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

deployContext

public void deployContext(java.lang.String path,
                          java.net.URL config,
                          java.net.URL war,
                          boolean update,
                          java.lang.String tag)
                   throws TomcatManagerException,
                          java.io.IOException
Deploys the specified context XML configuration and WAR as a URL to the specified context path, optionally undeploying the webapp if it already exists and using the specified tag name.

Parameters:
path - the webapp context path to deploy to
config - the URL of the context XML configuration to deploy
war - the URL of the WAR to deploy
update - whether to first undeploy the webapp if it already exists
tag - the tag name to use
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

undeploy

public void undeploy(java.lang.String path)
              throws TomcatManagerException,
                     java.io.IOException
Undeploys the webapp at the specified context path.

Parameters:
path - the webapp context path to undeploy
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

remove

public void remove(java.lang.String path)
            throws TomcatManagerException,
                   java.io.IOException
Removes the webapp at the specified context path.

Parameters:
path - the webapp context path to remove
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

reload

public void reload(java.lang.String path)
            throws TomcatManagerException,
                   java.io.IOException
Reloads the webapp at the specified context path.

Parameters:
path - the webapp context path to reload
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

start

public void start(java.lang.String path)
           throws TomcatManagerException,
                  java.io.IOException
Starts the webapp at the specified context path.

Parameters:
path - the webapp context path to start
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

stop

public void stop(java.lang.String path)
          throws TomcatManagerException,
                 java.io.IOException
Stops the webapp at the specified context path.

Parameters:
path - the webapp context path to stop
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

invoke

protected void invoke(java.lang.String path)
               throws TomcatManagerException,
                      java.io.IOException
Invokes Tomcat manager with the specified command.

Parameters:
path - the Tomcat manager command to invoke
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

invoke

protected java.lang.String invoke(java.lang.String path,
                                  java.io.InputStream data)
                           throws TomcatManagerException,
                                  java.io.IOException
Invokes Tomcat manager with the specified command and content data.

Parameters:
path - the Tomcat manager command to invoke
data - an input stream to the content data
Returns:
the result of the invoking command, as returned by the Tomcat Manager application
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

list

public java.lang.String list()
                      throws java.io.IOException,
                             TomcatManagerException
List currently deployed webapps.

Returns:
a string representing the result of invoked command
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs

getStatus

public TomcatDeployableStatus getStatus(java.lang.String path)
                                 throws java.io.IOException,
                                        TomcatManagerException
Return the status of the webapp at the specified context path.

Parameters:
path - the webapp context path to get status
Returns:
the current status of the webapp in the running container
Throws:
TomcatManagerException - if the Tomcat manager request fails
java.io.IOException - if an i/o error occurs


Copyright © 2004-2007 Codehaus. All Rights Reserved.