commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kohs...@apache.org
Subject svn commit: r360307 - /jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ant/AntRewriteTask.java
Date Sat, 31 Dec 2005 16:01:16 GMT
Author: kohsuke
Date: Sat Dec 31 08:01:13 2005
New Revision: 360307

URL: http://svn.apache.org/viewcvs?rev=360307&view=rev
Log:
added a new unpublished switch to decide which transformer to use.

Modified:
    jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ant/AntRewriteTask.java

Modified: jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ant/AntRewriteTask.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ant/AntRewriteTask.java?rev=360307&r1=360306&r2=360307&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ant/AntRewriteTask.java
(original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/ant/AntRewriteTask.java
Sat Dec 31 08:01:13 2005
@@ -22,11 +22,13 @@
 import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
 import org.apache.commons.javaflow.bytecode.transformation.ResourceTransformer;
+import org.apache.commons.javaflow.bytecode.transformation.asm.AsmClassTransformer;
 import org.apache.commons.javaflow.bytecode.transformation.bcel.BcelClassTransformer;
 import org.apache.commons.javaflow.utils.RewritingUtils;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.taskdefs.MatchingTask;
 
 /**
@@ -37,19 +39,50 @@
  */
 public class AntRewriteTask extends MatchingTask {
 
-    private ResourceTransformer transformer = new BcelClassTransformer();
+    private ResourceTransformer transformer;
 
     private File dstDir;
     private File srcDir;
 
+    /**
+     * Directory to which the transformed files will be written.
+     * This can be the same as the source directory.
+     */
     public void setDstDir(final File pFile) {
         dstDir = pFile;
     }
 
+    /**
+     * Directory from which the input files are read.
+     * This and the inherited {@link MatchingTask} forms an implicit
+     * {@link FileSet}.
+     */
     public void setSrcDir(final File pFile) {
         srcDir = pFile;
         fileset.setDir(srcDir);
     }
+
+    /**
+     * Sets the transformer to use.
+     *
+     * <p>
+     * This option is unpublished, because in a long run we'll
+     * likely to just focus on one transformer and get rid
+     * of the other (and this option will be removed then.)
+     *
+     * @param name
+     *      either "BCEL" or "ASM". Case insensitive.
+     */
+    public void setMode(String name) {
+        name = name.toLowerCase();
+        if(name.equals("bcel"))
+            transformer = new BcelClassTransformer();
+        else
+        if(name.equals("asm"))
+            transformer = new AsmClassTransformer();
+        else
+            throw new BuildException("Unrecognized mode: "+name);
+    }
     
     /**
      * Check that all required attributes have been set and nothing
@@ -77,9 +110,11 @@
     public void execute() throws BuildException {
         
         final DirectoryScanner ds = fileset.getDirectoryScanner(getProject());
-//        final DirectoryScanner ds = getDirectoryScanner(srcDir);
         final String[] fileNames = ds.getIncludedFiles();
 
+        // default to BCEL, since the BCEL version is more stable
+        if(transformer==null)
+            transformer = new BcelClassTransformer();
         
         try {
             for (int i = 0; i < fileNames.length; i++) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message