org.jcoderz.commons.tracing
Class TracingInjectorTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.jcoderz.commons.tracing.TracingInjectorTask
All Implemented Interfaces:
Cloneable

public class TracingInjectorTask
extends org.apache.tools.ant.Task

Ant task for TracingInjection.

This ant task takes a fileset fileset as input and one directory destDir as output. It copies ALL files from the input to the output, if the do not exist at the destination OR if the file last modified date of the source is newer than the target. Needed directories are created as used.

As a 'side effect' all class files (*.class) that match one of the patterns given in the patternFile get JDK14 tracing logging (entering/exiting/throwing) injected in all methods that match the given pattern.

If you set java5 to true the generated code uses the much more efficient factory methods to box native types that had been introduced with java5 (new Integer(int i) vs. Integer.valueOf(int i)). Nevertheless this only affects the code that is guarded with an isLoggable(..) so there no runtime penalty in the generated code if logging is disabled.

The patternFile is read line by line and each line is expected to be either empty, start with a '#' or '//' or hold a valid aspectJ like pattern as defined in the AspectPattern according to aspectwerkz. Call the target with '-v' to see the regular expression that is generated out of the input pattern.

The task supports a verbose attribute. If set to true a detailed log will be generated about what is going on. This is done by increasing the JDK logging loglevel - be aware of possible side effects.

The following code fragment defines the tracing-injector ant task.
   <taskdef name="tracing-injector"
       classname="org.jcoderz.commons.tracing.TracingInjectorTask"
       classpath="lib/tracing-injector-0.1.jar"/>
 
A valid usage sample is:
   <tracing-injector destDir="build/classes-log"
       patternFile="config/tracing"
       java5="false" verbose="false">
       <fileset dir="build/classes"/>
     </tracing-injector>
 
TODO: Support different Tracers to be set.

Author:
Andreas Mandel

Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
TracingInjectorTask()
           
 
Method Summary
 void addFileset(org.apache.tools.ant.types.FileSet fileset)
           
 void execute()
           
 void inject()
           
 void setDestDir(String destDir)
           
 void setJava5(boolean java5)
           
 void setPai(boolean pai)
           
 void setPatternFile(File patternFile)
           
 void setVerbose(boolean verbose)
           
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TracingInjectorTask

public TracingInjectorTask()
Method Detail

addFileset

public void addFileset(org.apache.tools.ant.types.FileSet fileset)
Parameters:
fileset - files to be collected.

setDestDir

public void setDestDir(String destDir)

setPatternFile

public void setPatternFile(File patternFile)

setJava5

public void setJava5(boolean java5)

setPai

public void setPai(boolean pai)

setVerbose

public void setVerbose(boolean verbose)

execute

public void execute()
Overrides:
execute in class org.apache.tools.ant.Task

inject

public void inject()
            throws IOException
Throws:
IOException


Copyright 2007 The jCoderZ Project.