You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by cm...@apache.org on 2003/05/08 12:55:19 UTC

cvs commit: jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/tomcat AbstractTomcatContainer.java Tomcat3xContainer.java AbstractCatalinaContainer.java

cmlenz      2003/05/08 03:55:18

  Modified:    integration/ant/src/java/org/apache/cactus/integration/ant/container/tomcat
                        Tag: CACTUS_14_ANT_BRANCH
                        AbstractTomcatContainer.java Tomcat3xContainer.java
                        AbstractCatalinaContainer.java
  Log:
  Provide a way for the user to specify custom files to be included in the ./conf directory of Tomcat.
  This is realized by allowing nested <conf> filesets.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.3   +62 -1     jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/tomcat/Attic/AbstractTomcatContainer.java
  
  Index: AbstractTomcatContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/tomcat/Attic/AbstractTomcatContainer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- AbstractTomcatContainer.java	7 May 2003 11:02:44 -0000	1.1.2.2
  +++ AbstractTomcatContainer.java	8 May 2003 10:55:18 -0000	1.1.2.3
  @@ -57,9 +57,16 @@
   package org.apache.cactus.integration.ant.container.tomcat;
   
   import java.io.File;
  +import java.io.IOException;
  +import java.util.ArrayList;
  +import java.util.Iterator;
  +import java.util.List;
   
   import org.apache.cactus.integration.ant.container.AbstractJavaContainer;
   import org.apache.tools.ant.BuildException;
  +import org.apache.tools.ant.taskdefs.Copy;
  +import org.apache.tools.ant.types.FileSet;
  +import org.apache.tools.ant.util.FileUtils;
   
   /**
    * Base support for Catalina based containers.
  @@ -79,6 +86,12 @@
       private File dir;
   
       /**
  +     * List of filesets that contain user-specified files that should be added
  +     * to the Tomcat conf directory.
  +     */
  +    private List confFileSets = new ArrayList();
  +
  +    /**
        * A user-specific server.xml configuration file. If this variable is not
        * set, the default configuration file from the JAR resources will be used.
        */
  @@ -92,6 +105,17 @@
       // Public Methods ----------------------------------------------------------
   
       /**
  +     * Adds a set of files to include in the Tomcat configuration directory.
  +     * 
  +     * @param theConf The fileset to add
  +     */
  +    public final void addConf(FileSet theConf)
  +    {
  +        theConf.createExclude().setName("**/server.xml");
  +        this.confFileSets.add(theConf);
  +    }
  +
  +    /**
        * Sets the Tomcat installation directory.
        * 
        * @return The directory
  @@ -163,6 +187,43 @@
           if (!this.dir.isDirectory())
           {
               throw new BuildException(this.dir + " is not a directory");
  +        }
  +    }
  +
  +    // Protected Methods -------------------------------------------------------
  +
  +    /**
  +     * Copies the configuration files specified by nested &lt;conf&gt; filesets
  +     * to the conf directory.
  +     * 
  +     * @param theConfDir The Tomcat configuration directory
  +     */
  +    protected final void copyConfFiles(File theConfDir)
  +    {
  +        if (getServerXml() != null)
  +        {
  +            FileUtils fileUtils = FileUtils.newFileUtils();
  +            try
  +            {
  +                fileUtils.copyFile(getServerXml(),
  +                    new File(theConfDir, "server.xml"));
  +            }
  +            catch (IOException ioe)
  +            {
  +                throw new BuildException("Could not copy " + getServerXml()
  +                    + " to directory " + theConfDir, ioe);
  +            }
  +        }
  +
  +        if (!this.confFileSets.isEmpty())
  +        {
  +            Copy copy = (Copy) createAntTask("copy");
  +            copy.setTodir(theConfDir);
  +            for (Iterator i = this.confFileSets.iterator(); i.hasNext();)
  +            {
  +                copy.addFileset((FileSet) i.next());
  +            }
  +            copy.execute();
           }
       }
   
  
  
  
  1.1.2.3   +5 -6      jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/tomcat/Attic/Tomcat3xContainer.java
  
  Index: Tomcat3xContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/tomcat/Attic/Tomcat3xContainer.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Tomcat3xContainer.java	7 May 2003 11:02:44 -0000	1.1.2.2
  +++ Tomcat3xContainer.java	8 May 2003 10:55:18 -0000	1.1.2.3
  @@ -163,16 +163,15 @@
           
           // copy configuration files into the temporary container directory
           File confDir = createDirectory(tmpDir, "conf");
  -        if (getServerXml() != null)
  -        {
  -            fileUtils.copyFile(getServerXml(), new File(confDir, "server.xml"));
  -        }
  -        else
  +        copyConfFiles(confDir);
  +        if (getServerXml() == null)
           {
               ResourceUtils.copyResource(getProject(),
                   RESOURCE_PATH + "tomcat3x/server.xml",
                   new File(confDir, "server.xml"), filterChain);
           }
  +        // TODO: only copy these files if they haven't been provided by the
  +        // user as a conf fileset
           ResourceUtils.copyResource(getProject(),
               RESOURCE_PATH + "tomcat3x/tomcat-users.xml",
               new File(confDir, "tomcat-users.xml"));
  
  
  
  1.1.2.4   +5 -6      jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/tomcat/Attic/AbstractCatalinaContainer.java
  
  Index: AbstractCatalinaContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/tomcat/Attic/AbstractCatalinaContainer.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- AbstractCatalinaContainer.java	7 May 2003 11:02:44 -0000	1.1.2.3
  +++ AbstractCatalinaContainer.java	8 May 2003 10:55:18 -0000	1.1.2.4
  @@ -223,16 +223,15 @@
   
           // copy configuration files into the temporary container directory
           File confDir = createDirectory(tmpDir, "conf");
  -        if (getServerXml() != null)
  -        {
  -            fileUtils.copyFile(getServerXml(), new File(confDir, "server.xml"));
  -        }
  -        else
  +        copyConfFiles(confDir);
  +        if (getServerXml() == null)
           {
               ResourceUtils.copyResource(getProject(),
                   RESOURCE_PATH + theResourcePrefix + "/server.xml",
                   new File(confDir, "server.xml"), filterChain);
           }
  +        // TODO: only copy these files if they haven't been provided by the
  +        // user as a conf fileset
           ResourceUtils.copyResource(getProject(),
               RESOURCE_PATH + theResourcePrefix + "/tomcat-users.xml",
               new File(confDir, "tomcat-users.xml"));
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org