Clover coverage report - Ant Coverage
Coverage timestamp: Tue Apr 8 2003 20:43:55 EST
file stats: LOC: 170   Methods: 4
NCLOC: 52   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DDCreator.java 0% 0% 0% 0%
 1   
 /*
 2   
  * The Apache Software License, Version 1.1
 3   
  *
 4   
  * Copyright (c) 2000,2002 The Apache Software Foundation.  All rights 
 5   
  * reserved.
 6   
  *
 7   
  * Redistribution and use in source and binary forms, with or without
 8   
  * modification, are permitted provided that the following conditions
 9   
  * are met:
 10   
  *
 11   
  * 1. Redistributions of source code must retain the above copyright
 12   
  *    notice, this list of conditions and the following disclaimer.
 13   
  *
 14   
  * 2. Redistributions in binary form must reproduce the above copyright
 15   
  *    notice, this list of conditions and the following disclaimer in
 16   
  *    the documentation and/or other materials provided with the
 17   
  *    distribution.
 18   
  *
 19   
  * 3. The end-user documentation included with the redistribution, if
 20   
  *    any, must include the following acknowlegement:
 21   
  *       "This product includes software developed by the
 22   
  *        Apache Software Foundation (http://www.apache.org/)."
 23   
  *    Alternately, this acknowlegement may appear in the software itself,
 24   
  *    if and wherever such third-party acknowlegements normally appear.
 25   
  *
 26   
  * 4. The names "Ant" and "Apache Software
 27   
  *    Foundation" must not be used to endorse or promote products derived
 28   
  *    from this software without prior written permission. For written
 29   
  *    permission, please contact apache@apache.org.
 30   
  *
 31   
  * 5. Products derived from this software may not be called "Apache"
 32   
  *    nor may "Apache" appear in their names without prior written
 33   
  *    permission of the Apache Group.
 34   
  *
 35   
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 36   
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 37   
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 38   
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
 39   
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 40   
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 41   
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 42   
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 43   
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 44   
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 45   
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 46   
  * SUCH DAMAGE.
 47   
  * ====================================================================
 48   
  *
 49   
  * This software consists of voluntary contributions made by many
 50   
  * individuals on behalf of the Apache Software Foundation.  For more
 51   
  * information on the Apache Software Foundation, please see
 52   
  * <http://www.apache.org/>.
 53   
  */
 54   
 package org.apache.tools.ant.taskdefs.optional.ejb;
 55   
 
 56   
 import java.io.File;
 57   
 import org.apache.tools.ant.BuildException;
 58   
 import org.apache.tools.ant.DirectoryScanner;
 59   
 import org.apache.tools.ant.taskdefs.Java;
 60   
 import org.apache.tools.ant.taskdefs.MatchingTask;
 61   
 import org.apache.tools.ant.types.Commandline;
 62   
 import org.apache.tools.ant.types.Path;
 63   
 
 64   
 /**
 65   
  * Builds a serialized deployment descriptor given a text file description of the
 66   
  * descriptor in the format supported by WebLogic.
 67   
  *
 68   
  * This ant task is a front end for the weblogic DDCreator tool.
 69   
  *
 70   
  * @author Conor MacNeill, Cortex ebusiness Pty Limited
 71   
  */
 72   
 public class DDCreator extends MatchingTask {
 73   
     /**
 74   
      * The root directory of the tree containing the textual deployment desciptors. The actual
 75   
      * deployment descriptor files are selected using include and exclude constructs
 76   
      * on the EJBC task, as supported by the MatchingTask superclass.
 77   
      */
 78   
     private File descriptorDirectory;
 79   
     
 80   
     /**
 81   
      * The directory where generated serialised deployment descriptors are placed.
 82   
      */
 83   
     private File generatedFilesDirectory;
 84   
         
 85   
     /**
 86   
      * The classpath to be used in the weblogic ejbc calls. It must contain the weblogic
 87   
      * classes necessary fro DDCreator <b>and</b> the implementation classes of the 
 88   
      * home and remote interfaces.
 89   
      */
 90   
     private String classpath;
 91   
     
 92   
     /**
 93   
      * Do the work.
 94   
      *
 95   
      * The work is actually done by creating a helper task. This approach allows
 96   
      * the classpath of the helper task to be set. Since the weblogic tools require
 97   
      * the class files of the project's home and remote interfaces to be available in
 98   
      * the classpath, this also avoids having to start ant with the class path of the
 99   
      * project it is building.
 100   
      *
 101   
      * @exception BuildException if someting goes wrong with the build
 102   
      */
 103  0
     public void execute() throws BuildException {
 104  0
         if (descriptorDirectory == null ||
 105   
             !descriptorDirectory.isDirectory()) {
 106  0
             throw new BuildException("descriptors directory " + descriptorDirectory.getPath() + 
 107   
                                      " is not valid");
 108   
         }
 109  0
         if (generatedFilesDirectory == null ||
 110   
             !generatedFilesDirectory.isDirectory()) {
 111  0
             throw new BuildException("dest directory " + generatedFilesDirectory.getPath() + 
 112   
                                      " is not valid");
 113   
         }
 114   
                                     
 115  0
         String args = descriptorDirectory + " " + generatedFilesDirectory;
 116   
             
 117   
         // get all the files in the descriptor directory
 118  0
         DirectoryScanner ds = super.getDirectoryScanner(descriptorDirectory);
 119   
     
 120  0
         String[] files = ds.getIncludedFiles();
 121   
 
 122  0
         for (int i = 0; i < files.length; ++i) {
 123  0
             args += " " + files[i];
 124   
         }
 125   
             
 126  0
         String systemClassPath = System.getProperty("java.class.path");
 127  0
         String execClassPath = getProject().translatePath(systemClassPath + ":" + classpath);
 128  0
         Java ddCreatorTask = (Java) getProject().createTask("java");
 129  0
         ddCreatorTask.setTaskName(getTaskName());
 130  0
         ddCreatorTask.setFork(true);
 131  0
         ddCreatorTask.setClassname("org.apache.tools.ant.taskdefs.optional.ejb.DDCreatorHelper");
 132  0
         Commandline.Argument arguments = ddCreatorTask.createArg();
 133  0
         arguments.setLine(args);
 134  0
         ddCreatorTask.setClasspath(new Path(getProject(), execClassPath));
 135  0
         if (ddCreatorTask.executeJava() != 0) {                         
 136  0
             throw new BuildException("Execution of ddcreator helper failed");
 137   
         }
 138   
     }
 139   
 
 140   
     /**
 141   
      * Set the directory from where the text descriptions of the deployment descriptors are
 142   
      * to be read.
 143   
      *
 144   
      * @param dirName the name of the directory containing the text deployment descriptor files.
 145   
      */
 146  0
     public void setDescriptors(String dirName) {
 147  0
         descriptorDirectory = new File(dirName);
 148   
     }
 149   
     
 150   
     /**
 151   
      * Set the directory into which the serialized deployment descriptors are to
 152   
      * be written.
 153   
      *
 154   
      * @param dirName the name of the directory into which the serialised deployment
 155   
      *                descriptors are written.
 156   
      */
 157  0
     public void setDest(String dirName) {
 158  0
         generatedFilesDirectory = new File(dirName);
 159   
     }
 160   
 
 161   
     /**
 162   
      * Set the classpath to be used for this compilation.
 163   
      *
 164   
      * @param s the classpath to use for the ddcreator tool.
 165   
      */
 166  0
     public void setClasspath(String s) {
 167  0
         this.classpath = getProject().translatePath(s);
 168   
     }
 169   
 }
 170