Clover coverage report - Cactus 1.5 for J2EE API 1.3
Coverage timestamp: Wed Feb 18 2004 09:09:13 EST
file stats: LOC: 240   Methods: 9
NCLOC: 86   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AbstractTomcatContainer.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * ====================================================================
 3   
  *
 4   
  * The Apache Software License, Version 1.1
 5   
  *
 6   
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
 7   
  * reserved.
 8   
  *
 9   
  * Redistribution and use in source and binary forms, with or without
 10   
  * modification, are permitted provided that the following conditions
 11   
  * are met:
 12   
  *
 13   
  * 1. Redistributions of source code must retain the above copyright
 14   
  *    notice, this list of conditions and the following disclaimer.
 15   
  *
 16   
  * 2. Redistributions in binary form must reproduce the above copyright
 17   
  *    notice, this list of conditions and the following disclaimer in
 18   
  *    the documentation and/or other materials provided with the
 19   
  *    distribution.
 20   
  *
 21   
  * 3. The end-user documentation included with the redistribution, if
 22   
  *    any, must include the following acknowlegement:
 23   
  *       "This product includes software developed by the
 24   
  *        Apache Software Foundation (http://www.apache.org/)."
 25   
  *    Alternately, this acknowlegement may appear in the software itself,
 26   
  *    if and wherever such third-party acknowlegements normally appear.
 27   
  *
 28   
  * 4. The names "The Jakarta Project", "Cactus" and "Apache Software
 29   
  *    Foundation" must not be used to endorse or promote products
 30   
  *    derived from this software without prior written permission. For
 31   
  *    written permission, please contact apache@apache.org.
 32   
  *
 33   
  * 5. Products derived from this software may not be called "Apache"
 34   
  *    nor may "Apache" appear in their names without prior written
 35   
  *    permission of the Apache Group.
 36   
  *
 37   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 38   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 39   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 40   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 41   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 42   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 43   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 44   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 45   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 46   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 47   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 48   
  * SUCH DAMAGE.
 49   
  * ====================================================================
 50   
  *
 51   
  * This software consists of voluntary contributions made by many
 52   
  * individuals on behalf of the Apache Software Foundation.  For more
 53   
  * information on the Apache Software Foundation, please see
 54   
  * <http://www.apache.org/>.
 55   
  *
 56   
  */
 57   
 package org.apache.cactus.integration.ant.container.tomcat;
 58   
 
 59   
 import java.io.File;
 60   
 import java.io.IOException;
 61   
 import java.util.ArrayList;
 62   
 import java.util.Iterator;
 63   
 import java.util.List;
 64   
 
 65   
 import org.apache.cactus.integration.ant.container.AbstractJavaContainer;
 66   
 import org.apache.tools.ant.BuildException;
 67   
 import org.apache.tools.ant.taskdefs.Copy;
 68   
 import org.apache.tools.ant.types.FileSet;
 69   
 import org.apache.tools.ant.util.FileUtils;
 70   
 
 71   
 /**
 72   
  * Base support for Catalina based containers.
 73   
  * 
 74   
  * @author <a href="mailto:cmlenz@apache.org">Christopher Lenz</a>
 75   
  * 
 76   
  * @version $Id: AbstractTomcatContainer.java,v 1.3.2.4 2003/11/23 19:33:25 vmassol Exp $
 77   
  */
 78   
 public abstract class AbstractTomcatContainer extends AbstractJavaContainer
 79   
 {
 80   
 
 81   
     // Instance Variables ------------------------------------------------------
 82   
 
 83   
     /**
 84   
      * The Catalina installation directory.
 85   
      */
 86   
     private File dir;
 87   
 
 88   
     /**
 89   
      * List of filesets that contain user-specified files that should be added
 90   
      * to the Tomcat conf directory.
 91   
      */
 92   
     private List confFileSets = new ArrayList();
 93   
 
 94   
     /**
 95   
      * A user-specific server.xml configuration file. If this variable is not
 96   
      * set, the default configuration file from the JAR resources will be used.
 97   
      */
 98   
     private File serverXml;
 99   
 
 100   
     /**
 101   
      * The port to which the container should be bound.
 102   
      */
 103   
     private int port = 8080;
 104   
 
 105   
     // Public Methods ----------------------------------------------------------
 106   
 
 107   
     /**
 108   
      * Adds a set of files to include in the Tomcat configuration directory.
 109   
      * 
 110   
      * @param theConf The fileset to add
 111   
      */
 112  0
     public final void addConf(FileSet theConf)
 113   
     {
 114   
         // Exclude the server.xml file as there is a "serverXml" specific 
 115   
         // property for it.
 116  0
         theConf.createExclude().setName("**/server.xml");
 117   
 
 118  0
         this.confFileSets.add(theConf);
 119   
     }
 120   
 
 121   
     /**
 122   
      * Sets the Tomcat installation directory.
 123   
      * 
 124   
      * @return The directory
 125   
      */
 126  0
     public final File getDir()
 127   
     {
 128  0
         return this.dir;
 129   
     }
 130   
 
 131   
     /**
 132   
      * Sets the Tomcat installation directory.
 133   
      * 
 134   
      * @param theDir The directory to set
 135   
      */
 136  0
     public final void setDir(File theDir)
 137   
     {
 138  0
         this.dir = theDir;
 139   
     }
 140   
 
 141   
     /**
 142   
      * Sets the server configuration file to use for the test installation of
 143   
      * Tomcat.
 144   
      * 
 145   
      * @return The server.xml file, if set
 146   
      */
 147  0
     public final File getServerXml()
 148   
     {
 149  0
         return this.serverXml;
 150   
     }
 151   
 
 152   
     /**
 153   
      * Sets the server configuration file to use for the test installation of
 154   
      * Tomcat.
 155   
      *  
 156   
      * @param theServerXml The server.xml file
 157   
      */
 158  0
     public final void setServerXml(File theServerXml)
 159   
     {
 160  0
         this.serverXml = theServerXml;
 161   
     }
 162   
 
 163   
     /**
 164   
      * Sets the port to which the container should listen.
 165   
      * 
 166   
      * @param thePort The port to set
 167   
      */
 168  0
     public final void setPort(int thePort)
 169   
     {
 170  0
         this.port = thePort;
 171   
     }
 172   
 
 173   
     // AbstractContainer Implementation ----------------------------------------
 174   
 
 175   
     /**
 176   
      * Returns the port to which the container should listen.
 177   
      * 
 178   
      * @return The port
 179   
      */
 180  0
     public final int getPort()
 181   
     {
 182  0
         return this.port;
 183   
     }
 184   
 
 185   
     /**
 186   
      * @see org.apache.cactus.integration.ant.container.Container#init
 187   
      */
 188  0
     public void init()
 189   
     {
 190  0
         if (!this.dir.isDirectory())
 191   
         {
 192  0
             throw new BuildException(this.dir + " is not a directory");
 193   
         }
 194   
 
 195  0
         if (!getDeployableFile().isWar())
 196   
         {
 197  0
             throw new BuildException("Tomcat doesn't support the "
 198   
                 + "deployment of EAR files");
 199   
         }
 200   
     }
 201   
 
 202   
     // Protected Methods -------------------------------------------------------
 203   
 
 204   
     /**
 205   
      * Copies the configuration files specified by nested &lt;conf&gt; filesets
 206   
      * to the conf directory.
 207   
      * 
 208   
      * @param theConfDir The Tomcat configuration directory
 209   
      */
 210  0
     protected final void copyConfFiles(File theConfDir)
 211   
     {
 212  0
         if (getServerXml() != null)
 213   
         {
 214  0
             FileUtils fileUtils = FileUtils.newFileUtils();
 215  0
             try
 216   
             {
 217  0
                 fileUtils.copyFile(getServerXml(),
 218   
                     new File(theConfDir, "server.xml"));
 219   
             }
 220   
             catch (IOException ioe)
 221   
             {
 222  0
                 throw new BuildException("Could not copy " + getServerXml()
 223   
                     + " to directory " + theConfDir, ioe);
 224   
             }
 225   
         }
 226   
 
 227  0
         if (!this.confFileSets.isEmpty())
 228   
         {
 229  0
             Copy copy = (Copy) createAntTask("copy");
 230  0
             copy.setTodir(theConfDir);
 231  0
             for (Iterator i = this.confFileSets.iterator(); i.hasNext();)
 232   
             {
 233  0
                 copy.addFileset((FileSet) i.next());
 234   
             }
 235  0
             copy.execute();
 236   
         }
 237   
     }
 238   
 
 239   
 }
 240