1 23 24 25 package com.sun.enterprise.tools.verifier.apiscan.classfile; 26 27 import java.util.*; 28 import java.util.logging.Logger ; 29 import java.io.IOException ; 30 import java.io.File ; 31 32 67 public class ClosureCompilerImpl implements ClosureCompiler { 68 69 74 75 79 private ClosureCompilerImplBase imp; 80 private static String resourceBundleName = "com.sun.enterprise.tools.verifier.apiscan.LocalStrings"; 81 private static Logger logger = Logger.getLogger("apiscan.classfile", resourceBundleName); private static final String myClassName = "ClosureCompilerImpl"; 84 88 public ClosureCompilerImpl(ClassFileLoader loader) { 89 94 if(loader instanceof ASMClassFileLoader){ 95 imp = new ASMClosureCompilerImpl(loader); 96 } else if(loader instanceof BCELClassFileLoader || 97 loader instanceof BCELClassFileLoader1) { 98 imp = new BCELClosureCompilerImpl(loader); 99 } else { 100 throw new RuntimeException ("Unknown loader type [" + loader + "]"); 101 } 102 } 103 104 109 public ClosureCompilerImpl(ClosureCompilerImplBase imp) { 110 this.imp = imp; 111 } 112 113 123 public void addExcludedClass(String className) { 124 imp.addExcludedClass(className); 125 } 126 127 138 public void addExcludedPackage(String pkgName) { 139 imp.addExcludedPackage(pkgName); 140 } 141 142 153 public void addExcludedPattern(String pattern) { 154 imp.addExcludedPattern(pattern); 155 } 156 157 public boolean buildClosure(String className) { 159 logger.entering(myClassName, "buildClosure", className); return imp.buildClosure(className); 161 } 162 163 168 public boolean buildClosure(java.util.jar.JarFile jar) throws IOException { 169 return imp.buildClosure(jar); 170 } 171 172 public Collection getClosure() { 174 return imp.getClosure(); 175 } 176 177 public Map getFailed() { 179 return imp.getFailed(); 180 } 181 182 188 public void reset() { 189 imp.reset(); 190 } 191 192 public Collection<String > getNativeMethods() { 193 return imp.getNativeMethods(); 194 } 195 196 public String toString() { 197 return imp.toString(); 198 } 199 200 public static void main(String [] args) { 201 if (args.length < 2) { 202 System.out.println( 203 "Usage : java " + com.sun.enterprise.tools.verifier.apiscan.classfile.ClosureCompilerImpl.class.getName() + " <classpath> <external class name(s)>"); System.out.println("Example: to find the closure of " + "mypkg.MySessionBean which is packaged in myejb.jar run\n" + " java " + com.sun.enterprise.tools.verifier.apiscan.classfile.ClosureCompilerImpl.class.getName() + " path_to_j2ee.jar"+File.pathSeparator+"path_to_myejb.jar"+ " mypkg.MySessionBean"); System.exit(1); 211 } 212 213 String cp=args[0]; 214 System.out.println("Using classpath " + cp); ClassFileLoader cfl = ClassFileLoaderFactory.newInstance( 216 new Object []{cp}); 217 ClosureCompilerImpl closure = new ClosureCompilerImpl(cfl); 218 closure.addExcludedPattern("java."); for (int i = 1; i < args.length; i++) { 220 String clsName = args[i]; 221 System.out.println("Building closure for " + clsName); closure.reset(); 223 closure.buildClosure(clsName); 224 System.out.println("The closure is [" + closure+"\n]"); } 226 } 227 228 } 229 | Popular Tags |