2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

Clover coverage report - Cactus 1.8dev for J2EE API 1.3
Coverage timestamp: Sun Mar 26 2006 18:50:18 BRT
file stats: LOC: 198   Methods: 9
NCLOC: 86   Classes: 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
 
 Source file Conditionals Statements Methods TOTAL
AbstractTomcatContainer.java 0% 0% 0% 0%
coverage
 1   
 /* 
 2   
  * ========================================================================
 3   
  * 
 4   
  * Copyright 2003-2004 The Apache Software Foundation.
 5   
  *
 6   
  * Licensed under the Apache License, Version 2.0 (the "License");
 7   
  * you may not use this file except in compliance with the License.
 8   
  * You may obtain a copy of the License at
 9   
  * 
 10   
  *   http://www.apache.org/licenses/LICENSE-2.0
 11   
  * 
 12   
  * Unless required by applicable law or agreed to in writing, software
 13   
  * distributed under the License is distributed on an "AS IS" BASIS,
 14   
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15   
  * See the License for the specific language governing permissions and
 16   
  * limitations under the License.
 17   
  * 
 18   
  * ========================================================================
 19   
  */
 20   
 package org.apache.cactus.integration.ant.container.tomcat;
 21   
 
 22   
 import java.io.File;
 23   
 import java.io.IOException;
 24   
 import java.util.ArrayList;
 25   
 import java.util.Iterator;
 26   
 import java.util.List;
 27   
 
 28   
 import org.apache.cactus.integration.ant.container.AbstractJavaContainer;
 29   
 import org.apache.tools.ant.BuildException;
 30   
 import org.apache.tools.ant.taskdefs.Copy;
 31   
 import org.apache.tools.ant.types.FileSet;
 32   
 import org.apache.tools.ant.util.FileUtils;
 33   
 
 34   
 /**
 35   
  * Base support for Catalina based containers.
 36   
  * 
 37   
  * @version $Id: AbstractTomcatContainer.java 238811 2004-02-29 10:10:42Z vmassol $
 38   
  */
 39   
 public abstract class AbstractTomcatContainer extends AbstractJavaContainer
 40   
 {
 41   
 
 42   
     // Instance Variables ------------------------------------------------------
 43   
 
 44   
     /**
 45   
      * The Catalina installation directory.
 46   
      */
 47   
     private File dir;
 48   
 
 49   
     /**
 50   
      * List of filesets that contain user-specified files that should be added
 51   
      * to the Tomcat conf directory.
 52   
      */
 53   
     private List confFileSets = new ArrayList();
 54   
 
 55   
     /**
 56   
      * A user-specific server.xml configuration file. If this variable is not
 57   
      * set, the default configuration file from the JAR resources will be used.
 58   
      */
 59   
     private File serverXml;
 60   
 
 61   
     /**
 62   
      * The port to which the container should be bound.
 63   
      */
 64   
     private int port = 8080;
 65   
 
 66   
     // Public Methods ----------------------------------------------------------
 67   
 
 68   
     /**
 69   
      * Adds a set of files to include in the Tomcat configuration directory.
 70   
      * 
 71   
      * @param theConf The fileset to add
 72   
      */
 73  0
     public final void addConf(FileSet theConf)
 74   
     {
 75   
         // Exclude the server.xml file as there is a "serverXml" specific 
 76   
         // property for it.
 77  0
         theConf.createExclude().setName("**/server.xml");
 78   
 
 79  0
         this.confFileSets.add(theConf);
 80   
     }
 81   
 
 82   
     /**
 83   
      * Sets the Tomcat installation directory.
 84   
      * 
 85   
      * @return The directory
 86   
      */
 87  0
     public final File getDir()
 88   
     {
 89  0
         return this.dir;
 90   
     }
 91   
 
 92   
     /**
 93   
      * Sets the Tomcat installation directory.
 94   
      * 
 95   
      * @param theDir The directory to set
 96   
      */
 97  0
     public final void setDir(File theDir)
 98   
     {
 99  0
         this.dir = theDir;
 100   
     }
 101   
 
 102   
     /**
 103   
      * @return The server.xml file, if set or null otherwise
 104   
      */
 105  0
     public final File getServerXml()
 106   
     {
 107  0
         return this.serverXml;
 108   
     }
 109   
 
 110   
     /**
 111   
      * Sets the server configuration file to use for the test installation of
 112   
      * Tomcat.
 113   
      *  
 114   
      * @param theServerXml The server.xml file
 115   
      */
 116  0
     public final void setServerXml(File theServerXml)
 117   
     {
 118  0
         this.serverXml = theServerXml;
 119   
     }
 120   
 
 121   
     /**
 122   
      * Sets the port to which the container should listen.
 123   
      * 
 124   
      * @param thePort The port to set
 125   
      */
 126  0
     public final void setPort(int thePort)
 127   
     {
 128  0
         this.port = thePort;
 129   
     }
 130   
 
 131   
     // AbstractContainer Implementation ----------------------------------------
 132   
 
 133   
     /**
 134   
      * Returns the port to which the container should listen.
 135   
      * 
 136   
      * @return The port
 137   
      */
 138  0
     public final int getPort()
 139   
     {
 140  0
         return this.port;
 141   
     }
 142   
 
 143   
     /**
 144   
      * @see org.apache.cactus.integration.ant.container.Container#init
 145   
      */
 146  0
     public void init()
 147   
     {
 148  0
         if (!this.dir.isDirectory())
 149   
         {
 150  0
             throw new BuildException(this.dir + " is not a directory");
 151   
         }
 152   
 
 153  0
         if (!getDeployableFile().isWar())
 154   
         {
 155  0
             throw new BuildException("Tomcat doesn't support the "
 156   
                 + "deployment of EAR files");
 157   
         }
 158   
     }
 159   
 
 160   
     // Protected Methods -------------------------------------------------------
 161   
 
 162   
     /**
 163   
      * Copies the configuration files specified by nested <conf> filesets
 164   
      * to the conf/ directory.
 165   
      * 
 166   
      * @param theConfDir The Tomcat configuration directory
 167   
      */
 168  0
     protected final void copyConfFiles(File theConfDir)
 169   
     {
 170  0
         if (getServerXml() != null)
 171   
         {
 172  0
             FileUtils fileUtils = FileUtils.newFileUtils();
 173  0
             try
 174   
             {
 175  0
                 fileUtils.copyFile(getServerXml(),
 176   
                     new File(theConfDir, "server.xml"));
 177   
             }
 178   
             catch (IOException ioe)
 179   
             {
 180  0
                 throw new BuildException("Could not copy " + getServerXml()
 181   
                     + " to directory " + theConfDir, ioe);
 182   
             }
 183   
         }
 184   
 
 185  0
         if (!this.confFileSets.isEmpty())
 186   
         {
 187  0
             Copy copy = (Copy) createAntTask("copy");
 188  0
             copy.setTodir(theConfDir);
 189  0
             for (Iterator i = this.confFileSets.iterator(); i.hasNext();)
 190   
             {
 191  0
                 copy.addFileset((FileSet) i.next());
 192   
             }
 193  0
             copy.execute();
 194   
         }
 195   
     }
 196   
 
 197   
 }
 198