1 23 24 29 30 package com.sun.enterprise.tools.verifier.apiscan.stdapis; 31 32 import java.io.File ; 33 import java.io.IOException ; 34 import java.util.Collection ; 35 import java.util.Iterator ; 36 import java.util.jar.JarFile ; 37 import java.util.logging.ConsoleHandler ; 38 import java.util.logging.Handler ; 39 import java.util.logging.Level ; 40 import java.util.logging.Logger ; 41 42 import com.sun.enterprise.tools.verifier.apiscan.classfile.ClassFileLoader; 43 import com.sun.enterprise.tools.verifier.apiscan.classfile.ClassFileLoaderFactory; 44 import com.sun.enterprise.tools.verifier.apiscan.classfile.ClosureCompilerImpl; 45 import com.sun.enterprise.tools.verifier.apiscan.packaging.ClassPathBuilder; 46 47 50 public class EjbClosureCompiler extends ClosureCompilerImpl { 51 private static Logger logger = Logger.getLogger("apiscan.stdapis"); private static final String myClassName = "EjbClosureCompiler"; private String specVersion; 54 55 58 public EjbClosureCompiler(String specVersion, ClassFileLoader cfl) { 59 super(cfl); 60 logger.entering(myClassName, "init<>", specVersion); this.specVersion = specVersion; 62 addStandardAPIs(); 63 } 64 65 protected void addStandardAPIs() { 67 String apiName = "ejb_jar_" + specVersion; Collection classes = APIRepository.Instance().getClassesFor(apiName); 69 for (Iterator i = classes.iterator(); i.hasNext();) { 70 addExcludedClass((String ) i.next()); 71 } 72 Collection pkgs = APIRepository.Instance().getPackagesFor(apiName); 73 for (Iterator i = pkgs.iterator(); i.hasNext();) { 74 addExcludedPackage((String ) i.next()); 75 } 76 Collection patterns = APIRepository.Instance().getPatternsFor(apiName); 77 for (Iterator i = patterns.iterator(); i.hasNext();) { 78 addExcludedPattern((String ) i.next()); 79 } 80 } 81 82 public static void main(String [] args) { 83 Handler h = new ConsoleHandler (); 84 h.setLevel(Level.ALL); 85 Logger.getLogger("apiscan").addHandler(h); Logger.getLogger("apiscan").setLevel(Level.ALL); 88 int j = 0; 89 String pcp = ""; 90 String specVer = ""; 91 for (j = 0; j < args.length; ++j) { 92 if (args[j].equals("-prefixClassPath")) { pcp = args[++j]; 94 continue; 95 } else if (args[j].equals("-specVer")) { specVer = args[++j]; 97 continue; 98 } 99 } 100 if (args.length < 5) { 101 System.out.println( 102 "Usage: " + EjbClosureCompiler.class.getName() + " <-prefixClassPath> <prefix classpath> <-specVer> <something like ejb_2.1> <jar file name(s)>"); return; 105 } 106 107 for (int i = 4; i < args.length; ++i) { 108 try { 109 JarFile jar = new JarFile (args[i]); 110 String cp = pcp + File.pathSeparator + 111 ClassPathBuilder.buildClassPathForJar(jar); 112 System.out.println("Using CLASSPATH " + cp); ClassFileLoader cfl = ClassFileLoaderFactory.newInstance( 114 new Object []{cp}); 115 EjbClosureCompiler ejbClosureCompiler = new EjbClosureCompiler( 116 specVer, cfl); 117 boolean result = ejbClosureCompiler.buildClosure(jar); 118 jar.close(); 119 System.out.println("The closure is [\n"); System.out.println(ejbClosureCompiler); 121 if (result) { 122 System.out.println("Did not find any non-standard APIs "); } else { 124 System.out.println("Found non-standard APIs for " + args[i]); 126 } 127 } catch (IOException e) { 128 e.printStackTrace(); 129 continue; 130 } 131 System.out.println("\n]"); } } 134 135 } 136 | Popular Tags |