org.apache.tomcat.maven.common.deployer
Class TomcatManager

java.lang.Object
  extended by org.apache.tomcat.maven.common.deployer.TomcatManager

public class TomcatManager
extends Object

FIXME http connection tru a proxy A Tomcat manager webapp invocation wrapper.

Version:
$Id: TomcatManager.html 1305321 2012-03-26 12:01:12Z olamy $
Author:
Mark Hobson

Constructor Summary
TomcatManager(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(URL url, 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(URL url, String username, String password)
          Creates a Tomcat manager wrapper for the specified URL, username and password that uses ISO-8859-1 URL encoding.
TomcatManager(URL url, String username, String password, String charset)
          Creates a Tomcat manager wrapper for the specified URL, username, password and URL encoding.
 
Method Summary
 TomcatManagerResponse deploy(String path, InputStream war)
          Deploys the specified WAR as a HTTP PUT to the specified context path.
 TomcatManagerResponse deploy(String path, 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.
 TomcatManagerResponse deploy(String path, InputStream war, boolean update, 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.
 TomcatManagerResponse deploy(String path, InputStream war, boolean update, String tag, long length)
           
 TomcatManagerResponse deploy(String path, URL war)
          Deploys the specified WAR as a URL to the specified context path.
 TomcatManagerResponse deploy(String path, URL war, boolean update)
          Deploys the specified WAR as a URL to the specified context path, optionally undeploying the webapp if it already exists.
 TomcatManagerResponse deploy(String path, URL war, boolean update, 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.
 TomcatManagerResponse deployContext(String path, URL config)
          Deploys the specified context XML configuration to the specified context path.
 TomcatManagerResponse deployContext(String path, URL config, boolean update)
          Deploys the specified context XML configuration to the specified context path, optionally undeploying the webapp if it already exists.
 TomcatManagerResponse deployContext(String path, URL config, boolean update, 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.
 TomcatManagerResponse deployContext(String path, URL config, URL war)
          Deploys the specified context XML configuration and WAR as a URL to the specified context path.
 TomcatManagerResponse deployContext(String path, URL config, 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.
 TomcatManagerResponse deployContext(String path, URL config, URL war, boolean update, 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.
 String getCharset()
          Gets the URL encoding charset to use when communicating with Tomcat manager.
 String getPassword()
          Gets the password to use when authenticating with Tomcat manager.
 TomcatManagerResponse getResources()
          Lists all of the global JNDI resources.
 TomcatManagerResponse getResources(String type)
          Lists the global JNDI resources of the given type.
 TomcatManagerResponse getRoles()
          Lists the security role names and corresponding descriptions that are available.
 TomcatManagerResponse getServerInfo()
          Lists information about the Tomcat version, OS, and JVM properties.
 TomcatManagerResponse getSessions(String path)
          Lists the default session timeout and the number of currently active sessions for the given context path.
 URL getURL()
          Gets the full URL of the Tomcat manager instance.
 String getUserAgent()
          Gets the user agent name to use when communicating with Tomcat manager.
 String getUserName()
          Gets the username to use when authenticating with Tomcat manager.
protected  TomcatManagerResponse invoke(String path)
          Invokes Tomcat manager with the specified command.
protected  TomcatManagerResponse invoke(String path, InputStream data, long length)
          Invokes Tomcat manager with the specified command and content data.
 TomcatManagerResponse list()
          Lists all the currently deployed web applications.
 TomcatManagerResponse reload(String path)
          Reloads the webapp at the specified context path.
 void setUserAgent(String userAgent)
          Sets the user agent name to use when communicating with Tomcat manager.
 TomcatManagerResponse start(String path)
          Starts the webapp at the specified context path.
 TomcatManagerResponse stop(String path)
          Stops the webapp at the specified context path.
 TomcatManagerResponse undeploy(String path)
          Undeploys the webapp at the specified context path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TomcatManager

public TomcatManager(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(URL url,
                     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(URL url,
                     String username,
                     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(URL url,
                     String username,
                     String password,
                     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 URL getURL()
Gets the full URL of the Tomcat manager instance.

Returns:
the full URL of the Tomcat manager instance

getUserName

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

Returns:
the username to use when authenticating with Tomcat manager

getPassword

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

Returns:
the password to use when authenticating with Tomcat manager

getCharset

public 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 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(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 TomcatManagerResponse deploy(String path,
                                    URL war)
                             throws TomcatManagerException,
                                    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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deploy

public TomcatManagerResponse deploy(String path,
                                    URL war,
                                    boolean update)
                             throws TomcatManagerException,
                                    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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deploy

public TomcatManagerResponse deploy(String path,
                                    URL war,
                                    boolean update,
                                    String tag)
                             throws TomcatManagerException,
                                    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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deploy

public TomcatManagerResponse deploy(String path,
                                    InputStream war)
                             throws TomcatManagerException,
                                    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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deploy

public TomcatManagerResponse deploy(String path,
                                    InputStream war,
                                    boolean update)
                             throws TomcatManagerException,
                                    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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deploy

public TomcatManagerResponse deploy(String path,
                                    InputStream war,
                                    boolean update,
                                    String tag)
                             throws TomcatManagerException,
                                    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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deploy

public TomcatManagerResponse deploy(String path,
                                    InputStream war,
                                    boolean update,
                                    String tag,
                                    long length)
                             throws TomcatManagerException,
                                    IOException
Parameters:
path -
war -
update -
tag -
length -
Returns:
Throws:
TomcatManagerException
IOException
Since:
2.0

deployContext

public TomcatManagerResponse deployContext(String path,
                                           URL config)
                                    throws TomcatManagerException,
                                           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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deployContext

public TomcatManagerResponse deployContext(String path,
                                           URL config,
                                           boolean update)
                                    throws TomcatManagerException,
                                           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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deployContext

public TomcatManagerResponse deployContext(String path,
                                           URL config,
                                           boolean update,
                                           String tag)
                                    throws TomcatManagerException,
                                           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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deployContext

public TomcatManagerResponse deployContext(String path,
                                           URL config,
                                           URL war)
                                    throws TomcatManagerException,
                                           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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deployContext

public TomcatManagerResponse deployContext(String path,
                                           URL config,
                                           URL war,
                                           boolean update)
                                    throws TomcatManagerException,
                                           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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

deployContext

public TomcatManagerResponse deployContext(String path,
                                           URL config,
                                           URL war,
                                           boolean update,
                                           String tag)
                                    throws TomcatManagerException,
                                           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
Returns:
the Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

undeploy

public TomcatManagerResponse undeploy(String path)
                               throws TomcatManagerException,
                                      IOException
Undeploys the webapp at the specified context path.

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

reload

public TomcatManagerResponse reload(String path)
                             throws TomcatManagerException,
                                    IOException
Reloads the webapp at the specified context path.

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

start

public TomcatManagerResponse start(String path)
                            throws TomcatManagerException,
                                   IOException
Starts the webapp at the specified context path.

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

stop

public TomcatManagerResponse stop(String path)
                           throws TomcatManagerException,
                                  IOException
Stops the webapp at the specified context path.

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

list

public TomcatManagerResponse list()
                           throws TomcatManagerException,
                                  IOException
Lists all the currently deployed web applications.

Returns:
the list of currently deployed applications
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

getServerInfo

public TomcatManagerResponse getServerInfo()
                                    throws TomcatManagerException,
                                           IOException
Lists information about the Tomcat version, OS, and JVM properties.

Returns:
the server information
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

getResources

public TomcatManagerResponse getResources()
                                   throws TomcatManagerException,
                                          IOException
Lists all of the global JNDI resources.

Returns:
the list of all global JNDI resources
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

getResources

public TomcatManagerResponse getResources(String type)
                                   throws TomcatManagerException,
                                          IOException
Lists the global JNDI resources of the given type.

Parameters:
type - the class name of the resources to list, or null for all
Returns:
the list of global JNDI resources of the given type
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

getRoles

public TomcatManagerResponse getRoles()
                               throws TomcatManagerException,
                                      IOException
Lists the security role names and corresponding descriptions that are available.

Returns:
the list of security role names and corresponding descriptions
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

getSessions

public TomcatManagerResponse getSessions(String path)
                                  throws TomcatManagerException,
                                         IOException
Lists the default session timeout and the number of currently active sessions for the given context path.

Parameters:
path - the context path to list session information for
Returns:
the default session timeout and the number of currently active sessions
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs

invoke

protected TomcatManagerResponse invoke(String path)
                                throws TomcatManagerException,
                                       IOException
Invokes Tomcat manager with the specified command.

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

invoke

protected TomcatManagerResponse invoke(String path,
                                       InputStream data,
                                       long length)
                                throws TomcatManagerException,
                                       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 Tomcat manager response
Throws:
TomcatManagerException - if the Tomcat manager request fails
IOException - if an i/o error occurs


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.