1 23 24 29 30 package com.sun.enterprise.tools.verifier.apiscan.classfile; 31 32 import java.lang.reflect.Constructor ; 33 import java.util.logging.Level ; 34 import java.util.logging.Logger ; 35 36 44 public class ClassFileLoaderFactory { 45 private static String resourceBundleName = "com.sun.enterprise.tools.verifier.apiscan.LocalStrings"; 46 private static Logger logger = Logger.getLogger("apiscan.classfile", resourceBundleName); private final static String myClassName = "ClassFileLoaderFactory"; 61 public static ClassFileLoader newInstance(Object [] args) 62 throws RuntimeException { 63 logger.entering(myClassName, "newInstance", args); String loaderClassName = System.getProperty("apiscan.ClassFileLoader"); 65 if (loaderClassName == null) { 66 loaderClassName = 67 com.sun.enterprise.tools.verifier.apiscan.classfile.BCELClassFileLoader.class.getName(); 68 logger.logp(Level.FINE, myClassName, "newInstance", "System Property apiscan.ClassFileLoader is null, so defaulting to " + loaderClassName); 71 } 72 try { 73 Class clazz = Class.forName(loaderClassName); 74 Object o = null; 75 Constructor [] constrs = clazz.getConstructors(); 76 for (int i = 0; i < constrs.length; ++i) { 77 try { 78 o = constrs[i].newInstance(args); 79 } catch (IllegalArgumentException e) { 80 } 82 } 83 if (o == null) throw new Exception ( 84 "Could not find a suitable constructor for this argument types."); 85 logger.exiting(myClassName, "<init>", o); return (ClassFileLoader) o; 87 } catch (Exception e) { 88 logger.log(Level.SEVERE, "com.sun.enterprise.tools.verifier.apiscan.classfile.ClassFileLoaderFactory.exception1", e); 89 throw new RuntimeException ("Unable to instantiate a loader.", e); 90 } 91 } 92 } 93 | Popular Tags |