1 18 package org.apache.tools.ant.taskdefs.optional.javah; 19 20 import org.apache.tools.ant.BuildException; 21 import org.apache.tools.ant.ProjectComponent; 22 import org.apache.tools.ant.util.ClasspathUtils; 23 import org.apache.tools.ant.util.JavaEnvUtils; 24 25 31 public class JavahAdapterFactory { 32 33 40 public static String getDefault() { 41 if (JavaEnvUtils.isKaffe()) { 42 return Kaffeh.IMPLEMENTATION_NAME; 43 } 44 return SunJavah.IMPLEMENTATION_NAME; 45 } 46 47 57 public static JavahAdapter getAdapter(String choice, 58 ProjectComponent log) 59 throws BuildException { 60 if ((JavaEnvUtils.isKaffe() && choice == null) 61 || Kaffeh.IMPLEMENTATION_NAME.equals(choice)) { 62 return new Kaffeh(); 63 } else if (SunJavah.IMPLEMENTATION_NAME.equals(choice)) { 64 return new SunJavah(); 65 } else if (choice != null) { 66 return resolveClassName(choice); 67 } 68 69 return new SunJavah(); 72 } 73 74 82 private static JavahAdapter resolveClassName(String className) 83 throws BuildException { 84 return (JavahAdapter) ClasspathUtils.newInstance(className, 85 JavahAdapterFactory.class.getClassLoader(), JavahAdapter.class); 86 } 87 } 88 | Popular Tags |