FileDocCategorySizeDatePackage
JavaBuildFileWriter.javaAPI DocApache Axis 1.45759Sat Apr 22 18:57:26 BST 2006org.apache.axis.wsdl.toJava

JavaBuildFileWriter

public class JavaBuildFileWriter extends JavaWriter

This is Wsdl2java's build file Writer. It writes the build.xml file. The build.xml file is a ant build file. After run the WSDL2Java and filling the implementation the user just have to cd to the out dir and type and "ant" (of course you must have ant installed). Then the ant will genarate a jar file which named after the wsdl file you used for WSDL2Java. (named after wsdl file ??? I do not get anything better .. the wsdl file may have more than one service ect ... so we can use them.)

This build file work on the where it is created ... User can not move the genarated code to another mechine and try to build. (class path is broken). But of cource user can move genarated build file at his will.

deploy the webservice using the AdminClient and drop the jar to servlet Container. We might even add another task to deploy the WS as well.

This feature can be on and off using the -B option default is off

author
Srinath Perera(hemapani@opensource.lk)

Fields Summary
protected javax.wsdl.Definition
definition
protected org.apache.axis.wsdl.symbolTable.SymbolTable
symbolTable
Field symbolTable
Constructors Summary
public JavaBuildFileWriter(Emitter emitter, javax.wsdl.Definition definition, org.apache.axis.wsdl.symbolTable.SymbolTable symbolTable)
Constructor


        super(emitter, "build");

        this.definition = definition;
        this.symbolTable = symbolTable;
    
Methods Summary
public voidgenerate()

        if (emitter.isBuildFileWanted()) {
            super.generate();
        }
    
private java.util.StringTokenizergetClasspathComponets()

        String classpath = System.getProperty("java.class.path");
        String spearator = ";";
        if (classpath.indexOf(';") < 0) {
            //t hen it is UNIX
            spearator = ":";
        }

        return new StringTokenizer(classpath, spearator);
    
protected java.lang.StringgetFileName()

        String dir = emitter.getOutputDir();
        if (dir == null) {
            dir = ".";
        }
        return dir + "/build.xml";
    
private java.lang.StringgetJarFileName(java.lang.String wsdlFile)

        int index = 0;
        if ((index = wsdlFile.lastIndexOf("/")) > 0) {
            wsdlFile = wsdlFile.substring(index + 1);
        }
        if ((index = wsdlFile.lastIndexOf("?")) > 0) {
            wsdlFile = wsdlFile.substring(0, index);
        }
        if ((index = wsdlFile.indexOf('.")) != -1) {
            return wsdlFile.substring(0, index);
        } else {
            return wsdlFile;
        }
    
protected voidwriteFileBody(java.io.PrintWriter out)

        out.write("<?xml version=\"1.0\"?>\n");

        out.write("<project basedir=\".\" default=\"jar\">\n");
        out.write("    <property name=\"src\" location=\".\"/>\n");
        out.write("    <property name=\"build.classes\" location=\"classes\"/>\n");

        out.write("    <path id=\"classpath\">\n");
        StringTokenizer tok = getClasspathComponets();
        while (tok.hasMoreTokens()) {
            out.write("        <pathelement location=\"" + tok.nextToken() + "\"/>\n");
        }
        out.write("    </path>\n");

        out.write("    <target name=\"compile\">\n");
        out.write("       <mkdir dir=\"${build.classes}\"/>\n");
        out.write("        <javac destdir=\"${build.classes}\" debug=\"on\">\n");
        out.write("            <classpath refid=\"classpath\" />\n");
        out.write("            <src path=\"${src}\"/>\n");
        out.write("        </javac>\n");
        out.write("    </target>\n");

        out.write("    <target name=\"jar\" depends=\"compile\">\n");
        out.write("        <copy todir=\"${build.classes}\">\n");
        out.write("            <fileset dir=\".\" casesensitive=\"yes\" >\n");
        out.write("                <include name=\"**/*.wsdd\"/>\n");
        out.write("            </fileset>\n");
        out.write("        </copy>\n");

        out.write("        <jar jarfile=\"" + getJarFileName(symbolTable.getWSDLURI()) + ".jar\" basedir=\"${build.classes}\" >\n");
        out.write("        <include name=\"**\" />\n");
        out.write("        <manifest>\n");
        out.write("            <section name=\"org/apache/ws4j2ee\">\n");
        out.write("            <attribute name=\"Implementation-Title\" value=\"Apache Axis\"/>\n");
        out.write("            <attribute name=\"Implementation-Vendor\" value=\"Apache Web Services\"/>\n");
        out.write("            </section>\n");
        out.write("        </manifest>\n");
        out.write("        </jar>\n");
        out.write("        <delete dir=\"${build.classes}\"/>\n");
        out.write("    </target>\n");
        out.write("</project>\n");
        out.close();