Coverage report

  %line %branch
net.sf.infrared.tools.weaving.Aw2System
0% 
0% 

 1  
 /*
 2  
  * Copyright 2005 Tavant Technologies and Contributors
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License")
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  *
 16  
  *
 17  
  *
 18  
  * Original Author:  binil.thomas (Tavant Technologies)
 19  
  * Contributor(s):   -;
 20  
  *
 21  
  */
 22  
 package net.sf.infrared.tools.weaving;
 23  
 
 24  
 import java.io.File;
 25  
 import java.util.HashSet;
 26  
 import java.util.Set;
 27  
 import org.apache.tools.ant.BuildException;
 28  
 import org.codehaus.aspectwerkz.compiler.AspectWerkzC;
 29  
 import org.codehaus.aspectwerkz.compiler.CompileException;
 30  
 
 31  
 /**
 32  
  *
 33  
  * @author binil.thomas
 34  
  */
 35  
 public class Aw2System extends AbstractAspectSystem {   
 36  
     private AspectWerkzC compiler;
 37  
     
 38  0
     private boolean loggedOnce = false;
 39  
     
 40  0
     public Aw2System() {
 41  0
         compiler = new AspectWerkzC();        
 42  
         try {
 43  0
             compiler.setPreprocessor("org.codehaus.aspectwerkz.transform.AspectWerkzPreProcessor");
 44  0
         } catch (CompileException ex) {
 45  0
             throw new BuildException("Failed to set AW preprocessor", ex);
 46  0
         }
 47  0
         compiler.setHaltOnError(true);
 48  0
         compiler.setVerbose(false);
 49  0
         compiler.setVerify(false);
 50  
         // @TODO what does this do?
 51  
         // compiler.setGenJp(true);
 52  0
     }
 53  
 
 54  
     public void instrumentJars(File[] jars) {    
 55  0
         if (! loggedOnce) {
 56  0
             getLogger().verbose("[Aw2] Setup: " + 
 57  
                     "\n\t AspectPath = " + getAspectPathAsString() +
 58  
                     "\n\t ClassPath  = " + getClassPathAsString());
 59  0
             loggedOnce = true;
 60  
         }
 61  
         
 62  0
         Set cp = new HashSet();
 63  0
         cp.addAll(getClassPath());
 64  0
         cp.addAll(getAspectPath());
 65  
         
 66  0
         compiler.setCompilationPath((File[]) cp.toArray(new File[0]), getClass().getClassLoader());
 67  
         
 68  0
         for (int i = 0; i < jars.length; i++) {
 69  
             try {
 70  0
                 compiler.compileJar(jars[i]);
 71  0
                 getLogger().verbose("[Aw2] Instrumented jar " + jars[i].getAbsolutePath());
 72  0
             } catch (CompileException ex) {
 73  0
                 throw new BuildException("Error in compiling jars", ex);
 74  0
             }
 75  
         }
 76  0
     }
 77  
 
 78  
     public void instrumentClasses(File[] classes, String[] packaging) {
 79  0
         if (! loggedOnce) {
 80  0
             getLogger().verbose("[Aw2] Setup: " + 
 81  
                     "\n\t AspectPath = " + getAspectPathAsString() +
 82  
                     "\n\t ClassPath  = " + getClassPathAsString());
 83  0
             loggedOnce = true;
 84  
         }
 85  
         
 86  0
         for (int i = 0; i < classes.length; i++) {
 87  
             try {
 88  0
                 compiler.compileClass(classes[i], packaging[i]);
 89  0
             } catch (CompileException ex) {         
 90  0
                 throw new BuildException("Error in compiling class " + 
 91  
                         packaging[i] + "." + classes[i].getName() + "; " +
 92  
                         "the most common cause is due to all extra classes referenced from the " +
 93  
                         "application not being added to 'extraclasspath' of the infrared task", ex);
 94  0
             } 
 95  
         }
 96  0
         getLogger().verbose("[Aw2] Instrumented jar " + classes.length + " classes");
 97  0
     }    
 98  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.