1 4 5 package com.triactive.jdo.enhance; 6 7 import java.io.File ; 8 import java.util.Arrays ; 9 import java.util.ArrayList ; 10 import java.util.Collection ; 11 import java.util.List ; 12 13 19 public class SunReferenceEnhancer 20 extends Enhancer 21 { 22 private final Collection jdoFiles; 23 private final String destDir; 24 private final boolean verbose; 25 26 27 private SunReferenceEnhancer(String destDir, boolean verbose, Collection jdoFiles) 28 { 29 super(); 30 31 this.destDir = destDir; 32 this.verbose = verbose; 33 this.jdoFiles = jdoFiles; 34 } 35 36 37 43 protected int callExternalEnhancer(String [] classNames) throws Exception 44 { 45 int returnCode = 0; 46 47 if (classNames.length > 0) 48 { 49 ArrayList args = new ArrayList (); 50 51 args.add("-f"); args.add("-d"); 53 args.add(destDir); 54 55 if (verbose) 56 args.add("-v"); 57 58 args.addAll(jdoFiles); 59 60 for (int i = 0; i < classNames.length; ++i) 61 { 62 String name = classNames[i]; 63 System.out.println("Enhancing class " + name); 64 65 args.add(new File (destDir, name.replace('.', '/') + ".class").toString()); 66 } 67 68 com.sun.jdori.enhancer.Main main = new com.sun.jdori.enhancer.Main(); 69 returnCode = main.process((String [])args.toArray(new String [args.size()])); 70 } 71 72 return returnCode; 73 } 74 75 76 87 public static void main(String [] args) throws Exception 88 { 89 String classListFile = null; 90 String destDir = "."; 91 boolean verbose = false; 92 ArrayList jdoFiles = new ArrayList (); 93 94 for (int i=0; i<args.length; i++) 95 { 96 if (args[i].equals("-l")) 97 { 98 classListFile = args[++i]; 99 } 100 else if (args[i].equals("-d")) 101 { 102 destDir = args[++i]; 103 } 104 else if (args[i].equals("-v")) 105 { 106 verbose = true; 107 } 108 else 109 { 110 jdoFiles.add(args[i]); 111 } 112 } 113 114 List classNames = getOrderedClassNames((String [])jdoFiles.toArray(new String [jdoFiles.size()])); 115 116 if (classListFile != null) 117 writeClassListFile(classListFile, classNames); 118 119 System.exit(new SunReferenceEnhancer(destDir, verbose, jdoFiles).enhance(classNames)); 120 } 121 } 122 | Popular Tags |