1 18 19 package org.apache.tools.ant.taskdefs.rmic; 20 21 import java.lang.reflect.Method ; 22 import org.apache.tools.ant.AntClassLoader; 23 import org.apache.tools.ant.BuildException; 24 import org.apache.tools.ant.Project; 25 import org.apache.tools.ant.types.Commandline; 26 27 32 public class WLRmic extends DefaultRmicAdapter { 33 34 public static final String WLRMIC_CLASSNAME = "weblogic.rmic"; 35 38 public static final String COMPILER_NAME = "weblogic"; 39 40 41 public static final String ERROR_NO_WLRMIC_ON_CLASSPATH = 42 "Cannot use WebLogic rmic, as it is not " 43 + "available. A common solution is to " 44 + "set the environment variable " 45 + "CLASSPATH."; 46 47 48 public static final String ERROR_WLRMIC_FAILED = "Error starting WebLogic rmic: "; 49 50 public static final String WL_RMI_STUB_SUFFIX = "_WLStub"; 51 52 public static final String WL_RMI_SKEL_SUFFIX = "_WLSkel"; 53 54 59 public boolean execute() throws BuildException { 60 getRmic().log("Using WebLogic rmic", Project.MSG_VERBOSE); 61 Commandline cmd = setupRmicCommand(new String [] {"-noexit"}); 62 63 AntClassLoader loader = null; 64 try { 65 Class c = null; 67 if (getRmic().getClasspath() == null) { 68 c = Class.forName(WLRMIC_CLASSNAME); 69 } else { 70 loader 71 = getRmic().getProject().createClassLoader(getRmic().getClasspath()); 72 c = Class.forName(WLRMIC_CLASSNAME, true, loader); 73 } 74 Method doRmic = c.getMethod("main", 75 new Class [] {String [].class}); 76 doRmic.invoke(null, new Object [] {cmd.getArguments()}); 77 return true; 78 } catch (ClassNotFoundException ex) { 79 throw new BuildException(ERROR_NO_WLRMIC_ON_CLASSPATH, getRmic().getLocation()); 80 } catch (Exception ex) { 81 if (ex instanceof BuildException) { 82 throw (BuildException) ex; 83 } else { 84 throw new BuildException(ERROR_WLRMIC_FAILED, ex, 85 getRmic().getLocation()); 86 } 87 } finally { 88 if (loader != null) { 89 loader.cleanup(); 90 } 91 } 92 } 93 94 98 public String getStubClassSuffix() { 99 return WL_RMI_STUB_SUFFIX; 100 } 101 102 106 public String getSkelClassSuffix() { 107 return WL_RMI_SKEL_SUFFIX; 108 } 109 } 110 | Popular Tags |