FileDocCategorySizeDatePackage
DefaultRmicAdapter.javaAPI DocApache Ant 1.7014867Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.taskdefs.rmic

DefaultRmicAdapter

public abstract class DefaultRmicAdapter extends Object implements RmicAdapter
This is the default implementation for the RmicAdapter interface. Currently, this is a cut-and-paste of the original rmic task and DefaultCopmpilerAdapter.
since
Ant 1.4

Fields Summary
private org.apache.tools.ant.taskdefs.Rmic
attributes
private org.apache.tools.ant.util.FileNameMapper
mapper
private static final Random
RAND
public static final String
RMI_STUB_SUFFIX
suffix denoting a stub file
public static final String
RMI_SKEL_SUFFIX
suffix denoting a skel file
public static final String
RMI_TIE_SUFFIX
suffix denoting a tie file
public static final String
STUB_COMPAT
arg for compat
public static final String
STUB_1_1
arg for 1.1
public static final String
STUB_1_2
arg for 1.2
Constructors Summary
public DefaultRmicAdapter()
Default constructor


           
      
    
Methods Summary
public org.apache.tools.ant.types.PathgetClasspath()
Gets the CLASSPATH this rmic process will use.

return
the classpath

        return getCompileClasspath();
    
protected org.apache.tools.ant.types.PathgetCompileClasspath()
Builds the compilation classpath.

return
the classpath

        Path classpath = new Path(attributes.getProject());
        // add dest dir to classpath so that previously compiled and
        // untouched classes are on classpath
        classpath.setLocation(attributes.getBase());

        // Combine the build classpath with the system classpath, in an
        // order determined by the value of build.sysclasspath

        Path cp = attributes.getClasspath();
        if (cp == null) {
            cp = new Path(attributes.getProject());
        }
        if (attributes.getIncludeantruntime()) {
            classpath.addExisting(cp.concatSystemClasspath("last"));
        } else {
            classpath.addExisting(cp.concatSystemClasspath("ignore"));
        }

        if (attributes.getIncludejavaruntime()) {
            classpath.addJavaRuntime();
        }
        return classpath;
    
public org.apache.tools.ant.util.FileNameMappergetMapper()
This implementation returns a mapper that may return up to two file names.
  • for JRMP it will return *_getStubClassSuffix (and *_getSkelClassSuffix if JDK 1.1 is used)
  • for IDL it will return a random name, causing <rmic> to always recompile.
  • for IIOP it will return _*_getStubClassSuffix for interfaces and _*_getStubClassSuffix for non-interfaces (and determine the interface and create _*_Stub from that).

return
a FileNameMapper

        return mapper;
    
public org.apache.tools.ant.taskdefs.RmicgetRmic()
Get the Rmic attributes

return
the attributes as a Rmic taskdef

        return attributes;
    
protected java.lang.StringgetSkelClassSuffix()
Gets the skeleton class suffix

return
the skeleton suffix "_Skel"

        return RMI_SKEL_SUFFIX;
    
protected java.lang.StringgetStubClassSuffix()
Gets the stub class suffix

return
the stub suffix "_Stub"

        return RMI_STUB_SUFFIX;
    
protected java.lang.StringgetTieClassSuffix()
Gets the tie class suffix

return
the tie suffix "_Tie"

        return RMI_TIE_SUFFIX;
    
protected voidlogAndAddFilesToCompile(org.apache.tools.ant.types.Commandline cmd)
Logs the compilation parameters, adds the files to compile and logs the "niceSourceList"

param
cmd the commandline args

        Vector compileList = attributes.getCompileList();

        attributes.log("Compilation " + cmd.describeArguments(),
                       Project.MSG_VERBOSE);

        StringBuffer niceSourceList = new StringBuffer("File");
        int cListSize = compileList.size();
        if (cListSize != 1) {
            niceSourceList.append("s");
        }
        niceSourceList.append(" to be compiled:");

        for (int i = 0; i < cListSize; i++) {
            String arg = (String) compileList.elementAt(i);
            cmd.createArgument().setValue(arg);
            niceSourceList.append("    ");
            niceSourceList.append(arg);
        }

        attributes.log(niceSourceList.toString(), Project.MSG_VERBOSE);
    
public voidsetRmic(org.apache.tools.ant.taskdefs.Rmic attributes)
Sets Rmic attributes

param
attributes the rmic attributes

        this.attributes = attributes;
        mapper = new RmicFileNameMapper();
    
protected org.apache.tools.ant.types.CommandlinesetupRmicCommand()
Setup rmic argument for rmic.

return
the command line

        return setupRmicCommand(null);
    
protected org.apache.tools.ant.types.CommandlinesetupRmicCommand(java.lang.String[] options)
Setup rmic argument for rmic.

param
options additional parameters needed by a specific implementation.
return
the command line

        Commandline cmd = new Commandline();

        if (options != null) {
            for (int i = 0; i < options.length; i++) {
                cmd.createArgument().setValue(options[i]);
            }
        }

        Path classpath = getCompileClasspath();

        cmd.createArgument().setValue("-d");
        cmd.createArgument().setFile(attributes.getBase());

        if (attributes.getExtdirs() != null) {
            cmd.createArgument().setValue("-extdirs");
            cmd.createArgument().setPath(attributes.getExtdirs());
        }

        cmd.createArgument().setValue("-classpath");
        cmd.createArgument().setPath(classpath);

        //handle the many different stub options.
        String stubVersion = attributes.getStubVersion();
        //default is compatibility
        String stubOption = null;
        if (null != stubVersion) {
            if ("1.1".equals(stubVersion)) {
                stubOption = STUB_1_1;
            } else if ("1.2".equals(stubVersion)) {
                stubOption = STUB_1_2;
            } else if ("compat".equals(stubVersion)) {
                stubOption = STUB_COMPAT;
            } else {
                //anything else
                attributes.log("Unknown stub option " + stubVersion);
                //do nothing with the value? or go -v+stubVersion??
            }
        }
        //for java1.5+, we generate compatible stubs, that is, unless
        //the caller asked for IDL or IIOP support.
        if (stubOption == null
            && !attributes.getIiop()
            && !attributes.getIdl()) {
            stubOption = STUB_COMPAT;
        }
        if (stubOption != null) {
            //set the non-null stubOption
            cmd.createArgument().setValue(stubOption);
        }
        if (null != attributes.getSourceBase()) {
            cmd.createArgument().setValue("-keepgenerated");
        }

        if (attributes.getIiop()) {
            attributes.log("IIOP has been turned on.", Project.MSG_INFO);
            cmd.createArgument().setValue("-iiop");
            if (attributes.getIiopopts() != null) {
                attributes.log("IIOP Options: " + attributes.getIiopopts(),
                               Project.MSG_INFO);
                cmd.createArgument().setValue(attributes.getIiopopts());
            }
        }

        if (attributes.getIdl())  {
            cmd.createArgument().setValue("-idl");
            attributes.log("IDL has been turned on.", Project.MSG_INFO);
            if (attributes.getIdlopts() != null) {
                cmd.createArgument().setValue(attributes.getIdlopts());
                attributes.log("IDL Options: " + attributes.getIdlopts(),
                               Project.MSG_INFO);
            }
        }

        if (attributes.getDebug()) {
            cmd.createArgument().setValue("-g");
        }

        cmd.addArguments(attributes.getCurrentCompilerArgs());

        logAndAddFilesToCompile(cmd);
        return cmd;