You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by cr...@apache.org on 2002/01/11 01:37:31 UTC

cvs commit: jakarta-tomcat-4.0/webapps/tomcat-docs manager-howto.xml

craigmcc    02/01/10 16:37:31

  Modified:    catalina build.xml
               webapps/tomcat-docs manager-howto.xml
  Added:       catalina/src/share/org/apache/catalina/ant
                        AbstractCatalinaTask.java InstallTask.java
                        ListTask.java ReloadTask.java RemoveTask.java
                        StartTask.java StopTask.java
  Log:
  Many people find the Manager webapp useful in installing and removing
  applications from a running instance of Tomcat 4.  This checkin adds a
  set of custom Ant tasks that correspond to each of the commands that
  Manager supports, so you can use them in build.xml scripts for your
  web applications directly.
  
  Documentation and an example build.xml script are in the updated
  manager-howto.xml file.
  
  Revision  Changes    Path
  1.95      +9 -0      jakarta-tomcat-4.0/catalina/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/build.xml,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -r1.94 -r1.95
  --- build.xml	5 Jan 2002 20:24:30 -0000	1.94
  +++ build.xml	11 Jan 2002 00:37:30 -0000	1.95
  @@ -865,6 +865,7 @@
       <!-- Catalina Main JAR File -->
       <jar jarfile="${catalina.deploy}/server/lib/catalina.jar">
         <fileset dir="${catalina.build}/server/classes">
  +        <exclude name="org/apache/catalina/ant/**" />
           <exclude name="org/apache/naming/**" />
           <exclude name="**/connector/warp/**" />
           <exclude name="org/apache/catalina/startup/Bootstrap.class" />
  @@ -877,6 +878,14 @@
           <exclude name="org/apache/catalina/startup/SecurityClassLoad.class" />
           <exclude name="org/apache/catalina/servlets/**" />
           <exclude name="org/apache/catalina/util/ssi/**" />
  +      </fileset>
  +    </jar>
  +
  +    <!-- Catalina Ant Tasks JAR File -->
  +    <jar jarfile="${catalina.deploy}/server/lib/catalina-ant.jar">
  +      <fileset dir="${catalina.build}/server/classes">
  +        <include name="org/apache/catalina/ant/**" />
  +        <include name="org/apache/catalina/util/Base64.class" />
         </fileset>
       </jar>
   
  
  
  
  1.1                  jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/AbstractCatalinaTask.java
  
  Index: AbstractCatalinaTask.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/AbstractCatalinaTask.java,v 1.1 2002/01/11 00:37:30 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/11 00:37:30 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  package org.apache.catalina.ant;
  
  
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.net.URL;
  import java.net.URLConnection;
  import org.apache.catalina.util.Base64;
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.Task;
  
  
  /**
   * Abstract base class for Ant tasks that interact with the
   * <em>Manager</em> web application for dynamically deploying and
   * undeploying applications.  These tasks require Ant 1.4 or later.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/11 00:37:30 $
   */
  
  public abstract class AbstractCatalinaTask extends Task {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The login password for the <code>Manager</code> application.
       */
      protected String password = null;
  
      public String getPassword() {
          return (this.password);
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
  
      /**
       * The URL of the <code>Manager</code> application to be used.
       */
      protected String url = "http://localhost:8080/manager";
  
      public String getUrl() {
          return (this.url);
      }
  
      public void setUrl(String url) {
          this.url = url;
      }
  
  
      /**
       * The login username for the <code>Manager</code> application.
       */
      protected String username = null;
  
      public String getUsername() {
          return (this.username);
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Execute the specified command.  This logic only performs the common
       * attribute validation required by all subclasses; it does not perform
       * any functional logic directly.
       *
       * @exception BuildException if a validation error occurs
       */
      public void execute() throws BuildException {
  
          if ((username == null) || (password == null) || (url == null)) {
              throw new BuildException
                  ("Must specify all of 'username', 'password', and 'url'");
          }
  
      }
  
  
      // ------------------------------------------------------ Protected Methods
  
  
      /**
       * Execute the specified command, based on the configured properties.
       *
       * @param command Command to be executed
       *
       * @exception BuildException if an error occurs
       */
      public void execute(String command) throws BuildException {
  
          URLConnection conn = null;
          InputStreamReader reader = null;
          try {
  
              // Create a connection for this command
              conn = (new URL(url + command)).openConnection();
  
              // Set up standard connection characteristics
              conn.setAllowUserInteraction(false);
              conn.setDoInput(true);
              conn.setDoOutput(false);
              conn.setUseCaches(false);
              conn.setRequestProperty("User-Agent",
                                      "Catalina-Ant-Task/1.0");
  
              // Set up an authorization header with our credentials
              String input = username + ":" + password;
              String output = new String(Base64.encode(input.getBytes()));
              conn.setRequestProperty("Authorization",
                                      "Basic " + output);
  
              // Perform the requested command and process the output
              conn.connect();
              reader = new InputStreamReader(conn.getInputStream());
              StringBuffer buff = new StringBuffer();
              String error = null;
              boolean first = true;
              while (true) {
                  int ch = reader.read();
                  if (ch < 0) {
                      break;
                  } else if ((ch == '\r') || (ch == '\n')) {
                      String line = buff.toString();
                      buff.setLength(0);
                      log(line, Project.MSG_INFO);
                      if (first) {
                          if (!line.startsWith("OK -")) {
                              error = line;
                          }
                          first = false;
                      }
                  } else {
                      buff.append((char) ch);
                  }
              }
              if (buff.length() > 0) {
                  log(buff.toString(), Project.MSG_INFO);
              }
              if (error != null) {
                  throw new BuildException(error);
              }
          } catch (Throwable t) {
              throw new BuildException(t);
          } finally {
              if (reader != null) {
                  try {
                      reader.close();
                  } catch (Throwable u) {
                      ;
                  }
                  reader = null;
              }
          }
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/InstallTask.java
  
  Index: InstallTask.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/InstallTask.java,v 1.1 2002/01/11 00:37:30 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/11 00:37:30 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  package org.apache.catalina.ant;
  
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  
  
  /**
   * Ant task that implements the <code>/install</code> command, supported by the
   * Tomcat manager application.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/11 00:37:30 $
   */
  public class InstallTask extends AbstractCatalinaTask {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * URL of the context configuration file for this application, if any.
       */
      protected String config = null;
  
      public String getConfig() {
          return (this.config);
      }
  
      public void setConfig(String config) {
          this.config = config;
      }
  
  
      /**
       * The context path of the web application we are managing.
       */
      protected String path = null;
  
      public String getPath() {
          return (this.path);
      }
  
      public void setPath(String path) {
          this.path = path;
      }
  
  
      /**
       * URL of the web application archive (WAR) file, or the unpacked directory
       * containing this application, if any.
       */
      protected String war = null;
  
      public String getWar() {
          return (this.war);
      }
  
      public void setWar(String war) {
          this.war = war;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Execute the requested operation.
       *
       * @exception BuildException if an error occurs
       */
      public void execute() throws BuildException {
  
          super.execute();
          if (path == null) {
              throw new BuildException
                  ("Must specify 'path' attribute");
          }
          if ((config == null) && (war == null)) {
              throw new BuildException
                  ("Must specify at least one of 'config' and 'war'");
          }
          StringBuffer sb = new StringBuffer("/install?path=");
          sb.append(this.path);
          if (config != null) {
              sb.append("&config=");
              sb.append(config);
          }
          if (war != null) {
              sb.append("&war=");
              sb.append(war);
          }
          execute(sb.toString());
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/ListTask.java
  
  Index: ListTask.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/ListTask.java,v 1.1 2002/01/11 00:37:30 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/11 00:37:30 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  package org.apache.catalina.ant;
  
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  
  
  /**
   * Ant task that implements the <code>/list</code> command, supported by the
   * Tomcat manager application.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/11 00:37:30 $
   */
  public class ListTask extends AbstractCatalinaTask {
  
  
      // ------------------------------------------------------------- Properties
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Execute the requested operation.
       *
       * @exception BuildException if an error occurs
       */
      public void execute() throws BuildException {
  
          super.execute();
          execute("/list");
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/ReloadTask.java
  
  Index: ReloadTask.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/ReloadTask.java,v 1.1 2002/01/11 00:37:30 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/11 00:37:30 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  package org.apache.catalina.ant;
  
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  
  
  /**
   * Ant task that implements the <code>/reload</code> command, supported by the
   * Tomcat manager application.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/11 00:37:30 $
   */
  public class ReloadTask extends AbstractCatalinaTask {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The context path of the web application we are managing.
       */
      protected String path = null;
  
      public String getPath() {
          return (this.path);
      }
  
      public void setPath(String path) {
          this.path = path;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Execute the requested operation.
       *
       * @exception BuildException if an error occurs
       */
      public void execute() throws BuildException {
  
          super.execute();
          if (path == null) {
              throw new BuildException
                  ("Must specify 'path' attribute");
          }
          execute("/reload?path=" + this.path);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/RemoveTask.java
  
  Index: RemoveTask.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/RemoveTask.java,v 1.1 2002/01/11 00:37:30 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/11 00:37:30 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  package org.apache.catalina.ant;
  
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  
  
  /**
   * Ant task that implements the <code>/remove</code> command, supported by the
   * Tomcat manager application.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/11 00:37:30 $
   */
  public class RemoveTask extends AbstractCatalinaTask {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The context path of the web application we are managing.
       */
      protected String path = null;
  
      public String getPath() {
          return (this.path);
      }
  
      public void setPath(String path) {
          this.path = path;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Execute the requested operation.
       *
       * @exception BuildException if an error occurs
       */
      public void execute() throws BuildException {
  
          super.execute();
          if (path == null) {
              throw new BuildException
                  ("Must specify 'path' attribute");
          }
          execute("/remove?path=" + this.path);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/StartTask.java
  
  Index: StartTask.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/StartTask.java,v 1.1 2002/01/11 00:37:30 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/11 00:37:30 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  package org.apache.catalina.ant;
  
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  
  
  /**
   * Ant task that implements the <code>/start</code> command, supported by the
   * Tomcat manager application.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/11 00:37:30 $
   */
  public class StartTask extends AbstractCatalinaTask {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The context path of the web application we are managing.
       */
      protected String path = null;
  
      public String getPath() {
          return (this.path);
      }
  
      public void setPath(String path) {
          this.path = path;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Execute the requested operation.
       *
       * @exception BuildException if an error occurs
       */
      public void execute() throws BuildException {
  
          super.execute();
          if (path == null) {
              throw new BuildException
                  ("Must specify 'path' attribute");
          }
          execute("/start?path=" + this.path);
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/StopTask.java
  
  Index: StopTask.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/ant/StopTask.java,v 1.1 2002/01/11 00:37:30 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/11 00:37:30 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  package org.apache.catalina.ant;
  
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Task;
  
  
  /**
   * Ant task that implements the <code>/stop</code> command, supported by the
   * Tomcat manager application.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/01/11 00:37:30 $
   */
  public class StopTask extends AbstractCatalinaTask {
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The context path of the web application we are managing.
       */
      protected String path = null;
  
      public String getPath() {
          return (this.path);
      }
  
      public void setPath(String path) {
          this.path = path;
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Execute the requested operation.
       *
       * @exception BuildException if an error occurs
       */
      public void execute() throws BuildException {
  
          super.execute();
          if (path == null) {
              throw new BuildException
                  ("Must specify 'path' attribute");
          }
          execute("/stop?path=" + this.path);
  
      }
  
  
  }
  
  
  
  1.7       +90 -0     jakarta-tomcat-4.0/webapps/tomcat-docs/manager-howto.xml
  
  Index: manager-howto.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/tomcat-docs/manager-howto.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- manager-howto.xml	16 Nov 2001 19:04:06 -0000	1.6
  +++ manager-howto.xml	11 Jan 2002 00:37:31 -0000	1.7
  @@ -55,6 +55,12 @@
       web browser.</li>
   </ul>
   
  +<p>In addition to executing Manager commands directly via HTTP, Tomcat 4
  +includes a convenient set of task definitions for the <em>Ant</em>
  +(version 1.4 or later) build tool.  See
  +<a href="#Executing Manager Commands With Ant">Executing Manager Commands
  +With Ant</a> for more information.</p>
  +
   </section>
   
   <section name="Configuring Manager Application Access">
  @@ -457,6 +463,90 @@
   </ul>
   
   </subsection>
  +
  +</section>
  +
  +
  +<section name="Executing Manager Commands With Ant">
  +
  +<p>In addition to the ability to execute Manager commands via HTTP requests,
  +as documented above, Tomcat 4 includes a convenient set of Task definitions
  +for the <em>Ant</em> (version 1.4 or later) build tool.  In order to use these
  +commands, you must perform the following setup operations:</p>
  +<ul>
  +<li>Download the binary distribution of Ant from
  +    <a href="http://jakarta.apache.org/ant/">http://jakarta.apache.org/ant</a>.
  +    You must use version <strong>1.4</strong> or later.</li>
  +<li>Install the Ant distribution in a convenient directory (called
  +    ANT_HOME in the remainder of these instructions).</li>
  +<li>Copy the file <code>server/lib/catalina-ant.jar</code> from your Tomcat 4
  +    installation into Ant's library directory (<code>$ANT_HOME/lib</code>).
  +    </li>
  +<li>Add the <code>$ANT_HOME/bin</code> directory to your <code>PATH</code>
  +    environment variable.</li>
  +<li>Configure at least one username/password combination in your Tomcat
  +    user database that includes the <code>manager</code> role.</li>
  +</ul>
  +
  +<p>To use custom tasks within Ant, you must declare them first with a
  +<code>&lt;taskdef&gt;</code> element.  Therefore, your <code>build.xml</code>
  +file might look something like this:</p>
  +
  +<table border="1">
  +<tr><td><pre>
  +&lt;project name="My Application" default="compile" basedir="."&gt;
  +
  +  &lt;-- Configure the directory into which the web application is built --&gt;
  +  &lt;property name="build"    value="${basedir}/build"/&gt;
  +
  +  &lt;-- Configure the context path for this application --&gt;
  +  &lt;property name="path"     value="/myapp"/&gt;
  +
  +  &lt;-- Configure properties to access the Manager application --&gt;
  +  &lt;property name="url"      value="http://localhost:8080/manager"/&gt;
  +  &lt;property name="username" value="myusername"/&gt;
  +  &lt;property name="password" value="mypassword"/&gt;
  +
  +  &lt;-- Configure the custom Ant tasks for the Manager application --&gt;
  +  &lt;taskdef name="install" classname="org.apache.catalina.ant.InstallTask"/&gt;
  +  &lt;taskdef name="list"    classname="org.apache.catalina.ant.ListTask"/&gt;
  +  &lt;taskdef name="reload"  classname="org.apache.catalina.ant.ReloadTask"/&gt;
  +  &lt;taskdef name="remove"  classname="org.apache.catalina.ant.RemoveTask"/&gt;
  +  &lt;taskdef name="start"   classname="org.apache.catalina.ant.StartTask"/&gt;
  +  &lt;taskdef name="stop"    classname="org.apache.catalina.ant.StopTask"/&gt;
  +
  +  &lt;-- Executable Targets --&gt;
  +  &lt;target name="compile" description="Compile web application"&gt;
  +    ... construct web application in ${build} subdirectory ...
  +  &lt;/target&gt;
  +
  +  &lt;target name="deploy" description="Deploy web application"
  +          depends="compile"&gt;
  +    &lt;install url="${url}" username="${username}" password="${password}"
  +            path="${path}" war="file://${build}"/&gt;
  +  &lt;/target&gt;
  +
  +  &lt;target name="reload" description="Reload web application"
  +          depends="compile"&gt;
  +    &lt;reload  url="${url}" username="${username}" password="${password}"
  +            path="${path}" war="file://${build}"/&gt;
  +  &lt;/target&gt;
  +
  +&lt;/project&gt;
  +</pre></td></tr>
  +</table>
  +
  +<p>Now, you can execute commands like <code>ant deploy</code> to deploy the
  +applcation to a running instance of Tomcat, or <code>ant reload</code> to
  +tell Tomcat to reload it.  Note also that most of the interesting values in
  +this <code>build.xml</code> file are defined as replaceable properties, so
  +you can override their values from the command line.  For example, you might
  +consider it a security risk to include the real manager password in your
  +<code>build.xml</code> file's source code.  To avoid this, omit the password
  +property, and specify it from the command line:</p>
  +<pre>
  +  ant -Dpassword=secret deploy
  +</pre>
   
   </section>
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>