FileDocCategorySizeDatePackage
DeployTask.javaAPI DocGlassfish v2 API6498Fri May 04 22:31:52 BST 2007org.apache.catalina.ant

DeployTask

public class DeployTask extends AbstractCatalinaTask
Ant task that implements the /deploy command, supported by the Tomcat manager application.
author
Craig R. McClanahan
version
$Revision: 1.3 $ $Date: 2007/05/05 05:31:52 $
since
4.1

Fields Summary
protected String
config
URL of the context configuration file for this application, if any.
protected String
localWar
URL of the server local web application archive (WAR) file to be deployed.
protected String
path
The context path of the web application we are managing.
protected String
tag
Tag to associate with this to be deployed webapp.
protected boolean
update
Update existing webapps.
protected String
war
URL of the web application archive (WAR) file to be deployed.
Constructors Summary
Methods Summary
public voidexecute()
Execute the requested operation.

exception
BuildException if an error occurs


        super.execute();
        if (path == null) {
            throw new BuildException
                ("Must specify 'path' attribute");
        }
        if ((war == null) && (localWar == null) && (tag == null)) {
            throw new BuildException
                ("Must specify either 'war', 'localWar', or 'tag' attribute");
        }

        // Building an input stream on the WAR to upload, if any
        BufferedInputStream stream = null;
        String contentType = null;
        int contentLength = -1;
        if (war != null) {
            if (war.startsWith("file:")) {
                try {
                    URL url = new URL(war);
                    URLConnection conn = url.openConnection();
                    contentLength = conn.getContentLength();
                    stream = new BufferedInputStream
                        (conn.getInputStream(), 1024);
                } catch (IOException e) {
                    throw new BuildException(e);
                }
            } else {
                try {
                    stream = new BufferedInputStream
                        (new FileInputStream(war), 1024);
                } catch (IOException e) {
                    throw new BuildException(e);
                }
            }
            contentType = "application/octet-stream";
        }

        // Building URL
        StringBuffer sb = new StringBuffer("/deploy?path=");
        sb.append(URLEncoder.encode(this.path));
        if ((war == null) && (config != null)) {
            sb.append("&config=");
            sb.append(URLEncoder.encode(config));
        }
        if ((war == null) && (localWar != null)) {
            sb.append("&war=");
            sb.append(URLEncoder.encode(localWar));
        }
        if (update) {
            sb.append("&update=true");
        }
        if (tag != null) {
            sb.append("&tag=");
            sb.append(URLEncoder.encode(tag));
        }

        execute(sb.toString(), stream, contentType, contentLength);

    
public java.lang.StringgetConfig()


       
        return (this.config);
    
public java.lang.StringgetLocalWar()


       
        return (this.localWar);
    
public java.lang.StringgetPath()


       
        return (this.path);
    
public java.lang.StringgetTag()


       
        return (this.tag);
    
public booleangetUpdate()


       
        return (this.update);
    
public java.lang.StringgetWar()


       
        return (this.war);
    
public voidsetConfig(java.lang.String config)

        this.config = config;
    
public voidsetLocalWar(java.lang.String localWar)

        this.localWar = localWar;
    
public voidsetPath(java.lang.String path)

        this.path = path;
    
public voidsetTag(java.lang.String tag)

        this.tag = tag;
    
public voidsetUpdate(boolean update)

        this.update = update;
    
public voidsetWar(java.lang.String war)

        this.war = war;