1 18 19 package org.apache.tools.ant.taskdefs.rmic; 20 21 import org.apache.tools.ant.BuildException; 22 import org.apache.tools.ant.Task; 23 import org.apache.tools.ant.util.ClasspathUtils; 24 25 import java.util.Locale ; 26 27 28 33 public final class RmicAdapterFactory { 34 35 public static final String ERROR_UNKNOWN_COMPILER = "Class not found: "; 36 37 38 public static final String ERROR_NOT_RMIC_ADAPTER = "Class of unexpected Type: "; 39 40 41 public static final String DEFAULT_COMPILER = "default"; 42 43 44 private RmicAdapterFactory() { 45 } 46 47 67 public static RmicAdapter getRmic(String rmicType, Task task) 68 throws BuildException { 69 String compiler = rmicType.toLowerCase(Locale.ENGLISH); 71 72 if (DEFAULT_COMPILER.equals(compiler) || compiler.length() == 0) { 74 compiler = KaffeRmic.isAvailable() 75 ? KaffeRmic.COMPILER_NAME 76 : SunRmic.COMPILER_NAME; 77 } 78 if (SunRmic.COMPILER_NAME.equals(compiler)) { 79 return new SunRmic(); 80 } else if (KaffeRmic.COMPILER_NAME.equals(compiler)) { 81 return new KaffeRmic(); 82 } else if (WLRmic.COMPILER_NAME.equals(compiler)) { 83 return new WLRmic(); 84 } else if (ForkingSunRmic.COMPILER_NAME.equals(compiler)) { 85 return new ForkingSunRmic(); 86 } else if (XNewRmic.COMPILER_NAME.equals(compiler)) { 87 return new XNewRmic(); 88 } 89 return resolveClassName(rmicType); 91 } 92 93 101 private static RmicAdapter resolveClassName(String className) 102 throws BuildException { 103 return (RmicAdapter) ClasspathUtils.newInstance(className, 104 RmicAdapterFactory.class.getClassLoader(), RmicAdapter.class); 105 } 106 } 107 | Popular Tags |