| Method from org.apache.tools.ant.taskdefs.Rmic Detail: |
public Path createClasspath() {
if (compileClasspath == null) {
compileClasspath = new Path(getProject());
}
return compileClasspath.createPath();
}
Creates a nested classpath element. |
public Rmic.ImplementationSpecificArgument createCompilerArg() {
ImplementationSpecificArgument arg =
new ImplementationSpecificArgument();
facade.addImplementationArgument(arg);
return arg;
}
Adds an implementation specific command line argument. |
public Path createExtdirs() {
if (extDirs == null) {
extDirs = new Path(getProject());
}
return extDirs.createPath();
}
Maybe creates a nested extdirs element. |
public void execute() throws BuildException {
if (baseDir == null) {
throw new BuildException(ERROR_BASE_NOT_SET, getLocation());
}
if (!baseDir.exists()) {
throw new BuildException(ERROR_NO_BASE_EXISTS + baseDir, getLocation());
}
if (!baseDir.isDirectory()) {
throw new BuildException(ERROR_NOT_A_DIR + baseDir, getLocation());
}
if (verify) {
log("Verify has been turned on.", Project.MSG_VERBOSE);
}
RmicAdapter adapter = RmicAdapterFactory.getRmic(getCompiler(), this);
// now we need to populate the compiler adapter
adapter.setRmic(this);
Path classpath = adapter.getClasspath();
loader = getProject().createClassLoader(classpath);
try {
// scan base dirs to build up compile lists only if a
// specific classname is not given
if (classname == null) {
DirectoryScanner ds = this.getDirectoryScanner(baseDir);
String[] files = ds.getIncludedFiles();
scanDir(baseDir, files, adapter.getMapper());
} else {
// otherwise perform a timestamp comparison - at least
String path = classname.replace('.", File.separatorChar) + ".class";
File f = new File(baseDir, path);
if (f.isFile()) {
scanDir(baseDir, new String[] {path}, adapter.getMapper());
} else {
// Does not exist, so checking whether it is up to date makes no sense.
// Compilation will fail later anyway, but tests expect a certain output.
compileList.add(classname);
}
}
int fileCount = compileList.size();
if (fileCount > 0) {
log("RMI Compiling " + fileCount
+ " class" + (fileCount > 1 ? "es" : "") + " to " + baseDir,
Project.MSG_INFO);
// finally, lets execute the compiler!!
if (!adapter.execute()) {
throw new BuildException(ERROR_RMIC_FAILED, getLocation());
}
}
/*
* Move the generated source file to the base directory. If
* base directory and sourcebase are the same, the generated
* sources are already in place.
*/
if (null != sourceBase && !baseDir.equals(sourceBase)
&& fileCount > 0) {
if (idl) {
log("Cannot determine sourcefiles in idl mode, ",
Project.MSG_WARN);
log("sourcebase attribute will be ignored.",
Project.MSG_WARN);
} else {
for (int j = 0; j < fileCount; j++) {
moveGeneratedFile(baseDir, sourceBase,
(String) compileList.elementAt(j),
adapter);
}
}
}
} finally {
compileList.removeAllElements();
}
}
execute by creating an instance of an implementation
class and getting to do the work |
public File getBase() {
return this.baseDir;
}
Gets the base directory to output generated class. |
public String getClassname() {
return classname;
}
Gets the class name to compile. |
public Path getClasspath() {
return compileClasspath;
}
|
public Vector getCompileList() {
return compileList;
}
|
public String getCompiler() {
facade.setMagicValue(getProject().getProperty("build.rmic"));
return facade.getImplementation();
}
get the name of the current compiler |
public String[] getCurrentCompilerArgs() {
getCompiler();
return facade.getArgs();
}
Get the additional implementation specific command line arguments. |
public boolean getDebug() {
return debug;
}
|
public Path getExtdirs() {
return extDirs;
}
Gets the extension directories that will be used during the
compilation. |
public Vector getFileList() {
return compileList;
}
Gets file list to compile. |
public boolean getFiltering() {
return filtering;
}
Gets whether token filtering is set |
public boolean getIdl() {
return idl;
}
|
public String getIdlopts() {
return idlOpts;
}
Gets additional arguments for idl compile. |
public boolean getIiop() {
return iiop;
}
|
public String getIiopopts() {
return iiopOpts;
}
Gets additional arguments for iiop. |
public boolean getIncludeantruntime() {
return includeAntRuntime;
}
Gets whether or not the ant classpath is to be included in the
task's classpath. |
public boolean getIncludejavaruntime() {
return includeJavaRuntime;
}
Gets whether or not the java runtime should be included in this
task's classpath. |
public ClassLoader getLoader() {
return loader;
}
Classloader for the user-specified classpath. |
public Class getRemoteInterface(Class testClass) {
if (Remote.class.isAssignableFrom(testClass)) {
Class [] interfaces = testClass.getInterfaces();
if (interfaces != null) {
for (int i = 0; i < interfaces.length; i++) {
if (Remote.class.isAssignableFrom(interfaces[i])) {
return interfaces[i];
}
}
}
}
return null;
}
Returns the topmost interface that extends Remote for a given
class - if one exists. |
public File getSourceBase() {
return sourceBase;
}
Gets the source dirs to find the source java files. |
public String getStubVersion() {
return stubVersion;
}
Gets the JDK version for the generated stub code. |
public boolean getVerify() {
return verify;
}
|
public boolean isValidRmiRemote(String classname) {
try {
Class testClass = loader.loadClass(classname);
// One cannot RMIC an interface for "classic" RMI (JRMP)
if (testClass.isInterface() && !iiop && !idl) {
return false;
}
return isValidRmiRemote(testClass);
} catch (ClassNotFoundException e) {
log(ERROR_UNABLE_TO_VERIFY_CLASS + classname
+ ERROR_NOT_FOUND, Project.MSG_WARN);
} catch (NoClassDefFoundError e) {
log(ERROR_UNABLE_TO_VERIFY_CLASS + classname
+ ERROR_NOT_DEFINED, Project.MSG_WARN);
} catch (Throwable t) {
log(ERROR_UNABLE_TO_VERIFY_CLASS + classname
+ ERROR_LOADING_CAUSED_EXCEPTION
+ t.getMessage(), Project.MSG_WARN);
}
// we only get here if an exception has been thrown
return false;
}
Load named class and test whether it can be rmic'ed |
protected void scanDir(File baseDir,
String[] files,
FileNameMapper mapper) {
String[] newFiles = files;
if (idl) {
log("will leave uptodate test to rmic implementation in idl mode.",
Project.MSG_VERBOSE);
} else if (iiop
&& iiopOpts != null && iiopOpts.indexOf("-always") > -1) {
log("no uptodate test as -always option has been specified",
Project.MSG_VERBOSE);
} else {
SourceFileScanner sfs = new SourceFileScanner(this);
newFiles = sfs.restrict(files, baseDir, baseDir, mapper);
}
for (int i = 0; i < newFiles.length; i++) {
String name = newFiles[i].replace(File.separatorChar, '.");
name = name.substring(0, name.lastIndexOf(".class"));
compileList.addElement(name);
}
}
Scans the directory looking for class files to be compiled.
The result is returned in the class variable compileList. |
public void setBase(File base) {
this.baseDir = base;
}
Sets the location to store the compiled files; required |
public void setClassname(String classname) {
this.classname = classname;
}
Sets the class to run rmic against;
optional |
public void setClasspath(Path classpath) {
if (compileClasspath == null) {
compileClasspath = classpath;
} else {
compileClasspath.append(classpath);
}
}
Set the classpath to be used for this compilation. |
public void setClasspathRef(Reference pathRef) {
createClasspath().setRefid(pathRef);
}
Adds to the classpath a reference to
a <path> defined elsewhere. |
public void setCompiler(String compiler) {
if (compiler.length() > 0) {
facade.setImplementation(compiler);
}
}
Sets the compiler implementation to use; optional,
defaults to the value of the build.rmic property,
or failing that, default compiler for the current VM |
public void setDebug(boolean debug) {
this.debug = debug;
}
Generate debug info (passes -g to rmic);
optional, defaults to false |
public void setExtdirs(Path extDirs) {
if (this.extDirs == null) {
this.extDirs = extDirs;
} else {
this.extDirs.append(extDirs);
}
}
Sets the extension directories that will be used during the
compilation; optional. |
public void setFiltering(boolean filter) {
this.filtering = filter;
}
Sets token filtering [optional], default=false |
public void setIdl(boolean idl) {
this.idl = idl;
}
Indicates that IDL output should be
generated. This defaults to false
if not set. |
public void setIdlopts(String idlOpts) {
this.idlOpts = idlOpts;
}
pass additional arguments for IDL compile |
public void setIiop(boolean iiop) {
this.iiop = iiop;
}
Indicates that IIOP compatible stubs should
be generated; optional, defaults to false
if not set. |
public void setIiopopts(String iiopOpts) {
this.iiopOpts = iiopOpts;
}
Set additional arguments for iiop |
public void setIncludeantruntime(boolean include) {
includeAntRuntime = include;
}
Sets whether or not to include ant's own classpath in this task's
classpath.
Optional; default is true. |
public void setIncludejavaruntime(boolean include) {
includeJavaRuntime = include;
}
task's classpath.
Enables or disables including the default run-time
libraries from the executing VM; optional,
defaults to false |
public void setSourceBase(File sourceBase) {
this.sourceBase = sourceBase;
}
optional directory to save generated source files to. |
public void setStubVersion(String stubVersion) {
this.stubVersion = stubVersion;
}
Specify the JDK version for the generated stub code.
Specify "1.1" to pass the "-v1.1" option to rmic. |
public void setVerify(boolean verify) {
this.verify = verify;
}
Flag to enable verification so that the classes
found by the directory match are
checked to see if they implement java.rmi.Remote.
optional; This defaults to false if not set. |