butek       2002/06/07 05:45:09

  Modified:    java/samples/integrationGuide/example1
                        MyListPortsWriter.java
               java/samples/integrationGuide/example2 MyDeployWriter.java
               java/src/org/apache/axis/utils axisNLS.properties
               java/src/org/apache/axis/wsdl/toJava
                        JavaBeanHelperWriter.java JavaBeanWriter.java
                        JavaDeployWriter.java JavaEnumTypeWriter.java
                        JavaFaultWriter.java JavaHolderWriter.java
                        JavaImplWriter.java JavaInterfaceWriter.java
                        JavaServiceIfaceWriter.java
                        JavaServiceImplWriter.java JavaSkelWriter.java
                        JavaStubWriter.java JavaTestCaseWriter.java
                        JavaUndeployWriter.java JavaWriter.java
  Added:       java/src/org/apache/axis/wsdl/toJava JavaClassWriter.java
  Log:
  My next step in revamping WSDL2Java was rewriting JavaWriter (and
  consequently all its subclasses).  Primarily, the changes are:
  
  1. JavaWriter is broken into two abstract classes:  JavaWriter and
  subclass JavaClassWriter.  JavaDeployWriter and JavaUndeployWriter
  extend JavaWriter directly.  The rest, since they all generate Java classes,
  extend JavaClassWriter.  In the old version, JavaDeployWriter and
  JavaUndeployWriter did some hokey things to fit into the class model.
  
  2. The constructors are simpler:  JavaWriter(Emitter e),
  JavaClassWriter(Emitter e, String filename, String type).  Less has to be
  known/calculated in the constructor.
  
  3. Most write methods now take a PrintWriter parameter instead of
  assuming the superclass has a PrintWriter.  This makes it easy to embed
  one generated class inside another (JavaBeanHelperWriter).
  
  4. There is now behaviour on JavaWriter and JavaClassWriter.  This
  behavior makes it easier to do piecemeal extensions.
  
  See the javadoc comments for JavaWriter and JavaClassWriter for details.
  
  Revision  Changes    Path
  1.2       +16 -8     
xml-axis/java/samples/integrationGuide/example1/MyListPortsWriter.java
  
  Index: MyListPortsWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/samples/integrationGuide/example1/MyListPortsWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MyListPortsWriter.java    16 May 2002 14:48:20 -0000      1.1
  +++ MyListPortsWriter.java    7 Jun 2002 12:45:08 -0000       1.2
  @@ -55,12 +55,12 @@
   package samples.integrationGuide.example1;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Iterator;
   import java.util.Map;
   
   import javax.wsdl.Port;
  -import javax.wsdl.QName;
   import javax.wsdl.Service;
   
   import org.apache.axis.wsdl.symbolTable.ServiceEntry;
  @@ -68,6 +68,7 @@
   
   import org.apache.axis.wsdl.toJava.Emitter;
   import org.apache.axis.wsdl.toJava.JavaWriter;
  +import org.apache.axis.wsdl.toJava.Utils;
   
   /**
   * This is my example of a class that writes a list of a service's
  @@ -88,6 +89,7 @@
   */
   public class MyListPortsWriter extends JavaWriter {
       private Service service;
  +    private String fileName;
   
       /**
        * Constructor.
  @@ -96,24 +98,30 @@
               Emitter emitter,
               ServiceEntry sEntry,
               SymbolTable symbolTable) {
  -        super(emitter,
  -                new QName(
  -                    sEntry.getQName().getNamespaceURI(),
  -                    sEntry.getQName().getLocalPart() + "Lst"),
  -                "", "lst", "Generating service port list file", "service list");
  +        super(emitter, "service list");
           this.service = sEntry.getService();
  +
  +        // Create the fully-qualified file name
  +        String javaName = sEntry.getName();
  +        fileName = emitter.getNamespaces().toDir(
  +                Utils.getJavaPackageName(javaName))
  +                + Utils.getJavaLocalName(javaName) + ".lst";
       } // ctor
   
  +    protected String getFileName() {
  +        return fileName;
  +    } // getFileName
  +
       /**
        * Override the common JavaWriter header to a no-op.
        */
  -    protected void writeFileHeader() throws IOException {
  +    protected void writeFileHeader(PrintWriter pw) throws IOException {
       } // writeFileHeader
   
       /**
        * Write the service list file.
        */
  -    protected void writeFileBody() throws IOException {
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           Map portMap = service.getPorts();
           Iterator portIterator = portMap.values().iterator();
   
  
  
  
  1.2       +15 -7     
xml-axis/java/samples/integrationGuide/example2/MyDeployWriter.java
  
  Index: MyDeployWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/samples/integrationGuide/example2/MyDeployWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MyDeployWriter.java       16 May 2002 14:48:20 -0000      1.1
  +++ MyDeployWriter.java       7 Jun 2002 12:45:08 -0000       1.2
  @@ -55,9 +55,9 @@
   package samples.integrationGuide.example2;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import javax.wsdl.Definition;
  -import javax.wsdl.QName;
   
   import org.apache.axis.wsdl.symbolTable.SymbolTable;
   
  @@ -66,11 +66,16 @@
   
   public class MyDeployWriter extends JavaWriter {
   
  +    private String filename;
  +
       public MyDeployWriter(Emitter emitter, Definition definition,
               SymbolTable symbolTable) {
  -        super(emitter,
  -                new QName(definition.getTargetNamespace(), "deploy"),
  -                "", "useless", "Generating deploy.useless", "deploy");
  +        super(emitter, "deploy");
  +
  +        // Create the fully-qualified file name
  +        String dir = emitter.getNamespaces().getAsDir(
  +                definition.getTargetNamespace());
  +        filename = dir + "deploy.useless";
       } // ctor
   
       public void generate() throws IOException {
  @@ -79,16 +84,20 @@
           }
       } // generate
   
  +    protected String getFileName() {
  +        return filename;
  +    } // getFileName
  +
       /**
        * Override the common JavaWriter header to a no-op.
        */
  -    protected void writeFileHeader() throws IOException {
  +    protected void writeFileHeader(PrintWriter pw) throws IOException {
       } // writeFileHeader
   
       /**
        * Write the service list file.
        */
  -    protected void writeFileBody() throws IOException {
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           MyEmitter myEmitter = (MyEmitter) emitter;
           if (myEmitter.getSong() == MyEmitter.RUM) {
               pw.println("Yo!  Ho!  Ho!  And a bottle of rum.");
  @@ -99,6 +108,5 @@
           else {
               pw.println("Feelings...  Nothing more than feelings...");
           }
  -        pw.close(); // Note:  this really should be done in JavaWriter.
       } // writeFileBody
   } // class MyDeployWriter
  
  
  
  1.7       +4 -2      xml-axis/java/src/org/apache/axis/utils/axisNLS.properties
  
  Index: axisNLS.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/axisNLS.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- axisNLS.properties        5 Jun 2002 19:28:58 -0000       1.6
  +++ axisNLS.properties        7 Jun 2002 12:45:08 -0000       1.7
  @@ -604,8 +604,8 @@
   # NOTE:  in wsdlGenLine00, do not translate "WSDL"
   wsdlGenLine00=This file was auto-generated from WSDL
   
  -# NOTE:  in wsdlGenLine01, do not translate "Apache Axis Wsdl2java"
  -wsdlGenLine01=by the Apache Axis Wsdl2java emitter.
  +# NOTE:  in wsdlGenLine01, do not translate "Apache Axis WSDL2Java"
  +wsdlGenLine01=by the Apache Axis WSDL2Java emitter.
   
   wsdlMissing00=Missing WSDL document
   
  @@ -850,6 +850,8 @@
   ftsf03=isClientTrusted: yes
   ftsf04=isServerTrusted: yes
   ftsf05=getAcceptedIssuers: none
  +
  +generating=Generating {0}
   
   j2woptStyle00=The style of binding in the WSDL.  Values are DOCUMENT or LITERAL.
   j2woptBadStyle00=The value of --style must be DOCUMENT or LITERAL.
  
  
  
  1.12      +66 -22    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanHelperWriter.java
  
  Index: JavaBeanHelperWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanHelperWriter.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JavaBeanHelperWriter.java 30 May 2002 18:55:21 -0000      1.11
  +++ JavaBeanHelperWriter.java 7 Jun 2002 12:45:08 -0000       1.12
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Vector;
   import java.util.HashMap;
  @@ -73,11 +74,12 @@
   /**
    * This is Wsdl2java's Helper Type Writer.  It writes the <typeName>.java file.
    */
  -public class JavaBeanHelperWriter extends JavaWriter {
  +public class JavaBeanHelperWriter extends JavaClassWriter {
       protected TypeEntry type;
       protected Vector elements;
       protected Vector attributes;
       protected TypeEntry extendType;
  +    protected PrintWriter wrapperPW = null;
       protected Vector elementMetaData = null;
   
       /**
  @@ -94,8 +96,7 @@
                                      Vector elements,
                                      TypeEntry extendType,
                                      Vector attributes) {
  -        super(emitter, type, "_Helper", "java",
  -              JavaUtils.getMessage("genType00"), "helper");
  +        super(emitter, type.getName() + "_Helper", "helper");
           this.type = type;
           this.elements = elements;
           this.attributes = attributes;
  @@ -103,31 +104,74 @@
       } // ctor
   
       /**
  -     * Generate the binding for the given complex type.
  -     * The elements vector contains the Types (even indices) and
  -     * element names (odd indices) of the contained elements
  +     * The bean helper class may be its own class, or it may be
  +     * embedded within the bean class.  If it's embedded within the
  +     * bean class, the JavaBeanWriter will set JavaBeanHelperWriter's
  +     * PrintWriter to its own.
        */
  -    protected void writeFileBody() throws IOException {
  +    protected void setPrintWriter(PrintWriter pw) {
  +        this.wrapperPW = pw;
  +    } // setPrintWriter
   
  -        if (!embeddedCode) {
  -            pw.println("public class " + className + " {");
  +    /**
  +     * The default behaviour (of super.getPrintWriter) is, given the
  +     * file name, create a PrintWriter for it.  If the bean helper
  +     * that this class is generating is embedded within a bean, then
  +     * the PrintWriter returned by this method is the JavaBeanWriter's
  +     * PrintWriter.  Otherwise super.getPrintWriter is called.
  +     */
  +    protected PrintWriter getPrintWriter(String filename) throws IOException {
  +        return wrapperPW == null ? super.getPrintWriter(filename) : wrapperPW;
  +    } // getPrintWriter
  +
  +    /**
  +     * Only write the file header if the bean helper is not wrapped
  +     * within a bean.
  +     */
  +    protected void writeFileHeader(PrintWriter pw) throws IOException {
  +        if (wrapperPW == null) {
  +            super.writeFileHeader(pw);
           }
  +    } // writeFileHeader
   
  -        writeMetaData();
  -        writeSerializer();
  -        writeDeserializer();
  +    /**
  +     * Generate the file body for the bean helper.
  +     */
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
  +        writeMetaData(pw);
  +        writeSerializer(pw);
  +        writeDeserializer(pw);
  +    } // writeFileBody
   
  -        if (!embeddedCode) {
  -            pw.println("}");
  +    /**
  +     * Only write the file footer if the bean helper is not
  +     * wrapped within a bean.
  +     */
  +    protected void writeFileFooter(PrintWriter pw) throws IOException {
  +        if (wrapperPW == null) {
  +            super.writeFileFooter(pw);
  +        }
  +    } // writeFileFooter
  +
  +    /**
  +     * Only close the PrintWriter if the PrintWriter belongs to
  +     * this class.  If the bean helper is embedded within a bean
  +     * then the PrintWriter belongs to JavaBeanWriter and THAT
  +     * class is responsible for closing the PrintWriter.
  +     */
  +    protected void closePrintWriter(PrintWriter pw) {
  +        // If the output of this writer is wrapped within
  +        // another writer (JavaBeanWriter), then THAT
  +        // writer will close the PrintWriter, not this one.
  +        if (wrapperPW == null) {
               pw.close();
           }
  -        
  -    } // writeFileBody
  +    } // closePrintWriter
   
       /**
        * write MetaData code
        */
  -    protected void writeMetaData() throws IOException {
  +    protected void writeMetaData(PrintWriter pw) throws IOException {
           // Collect elementMetaData
           if (elements != null) {
               for (int i = 0; i < elements.size(); i++) {
  @@ -171,7 +215,7 @@
               pw.println("    // " + JavaUtils.getMessage("typeMeta"));
               pw.println("    private static org.apache.axis.description.TypeDesc 
typeDesc =");
               pw.println("        new org.apache.axis.description.TypeDesc(" +
  -                       rootName + ".class);");
  +                       Utils.getJavaLocalName(type.getName()) + ".class);");
               pw.println();
               pw.println("    static {");
   
  @@ -235,7 +279,7 @@
        * write Serializer getter code and pass in meta data to avoid
        * undo introspection.
        */
  -    protected void writeSerializer() throws IOException {
  +    protected void writeSerializer(PrintWriter pw) throws IOException {
           String typeDesc = null;
           if (attributes != null || elementMetaData != null) {
               typeDesc = "typeDesc";
  @@ -254,7 +298,7 @@
           pw.println("        return ");
           pw.println("          new " + ser +"(");
           pw.println("            _javaType, _xmlType, " + typeDesc + ");");
  -        pw.println("    };");
  +        pw.println("    }");
           pw.println();
       }
   
  @@ -262,7 +306,7 @@
        * write Deserializer getter code and pass in meta data to avoid
        * undo introspection.
        */
  -    protected void writeDeserializer()  throws IOException {
  +    protected void writeDeserializer(PrintWriter pw)  throws IOException {
           String typeDesc = null;
           if (attributes != null || elementMetaData != null) {
               typeDesc = "typeDesc";
  @@ -281,7 +325,7 @@
           pw.println("        return ");
           pw.println("          new " + dser + "(");
           pw.println("            _javaType, _xmlType, " + typeDesc + ");");
  -        pw.println("    };");
  +        pw.println("    }");
           pw.println();
       }
   } // class JavaBeanHelperWriter
  
  
  
  1.16      +31 -54    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java
  
  Index: JavaBeanWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaBeanWriter.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JavaBeanWriter.java       31 May 2002 15:17:10 -0000      1.15
  +++ JavaBeanWriter.java       7 Jun 2002 12:45:08 -0000       1.16
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Vector;
   
  @@ -69,14 +70,15 @@
   /**
    * This is Wsdl2java's Complex Type Writer.  It writes the <typeName>.java file.
    */
  -public class JavaBeanWriter extends JavaWriter {
  +public class JavaBeanWriter extends JavaClassWriter {
       private TypeEntry type;
       private Vector elements;
       private Vector attributes;
       private TypeEntry extendType;
  -    protected JavaWriter helper;
  +    protected JavaBeanHelperWriter helper;
       protected Vector names = new Vector(); // even indices: types, odd: vars
       protected String simpleValueType = null;  // name of type of simple value
  +    protected PrintWriter pw;
   
       // The following fields can be set by extended classes
       // to control processing
  @@ -105,13 +107,12 @@
               TypeEntry extendType,
               Vector attributes,
               JavaWriter helper) {
  -        super(emitter, type, "", "java",
  -              JavaUtils.getMessage("genType00"), "complexType");
  +        super(emitter, type.getName(), "complexType");
           this.type = type;
           this.elements = elements;
           this.attributes = attributes;
           this.extendType = extendType;
  -        this.helper = helper;
  +        this.helper = (JavaBeanHelperWriter) helper;
           if (type.isSimpleType()) {
               enableSimpleConstructors = true;
               enableToString = true;
  @@ -121,15 +122,15 @@
       /**
        * Generate the binding for the given complex type.
        */
  -    protected void writeFileBody() throws IOException {
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
  +
  +        this.pw = pw;
  +
           // Populate Names Vector with the names and types of the members.
           // The write methods use the names vector whenever they need to get
           // a member name or type.
           preprocess();
   
  -        // Write the start of the class definition
  -        writeClassStart(getAbstractText(), getExtendsText(), getImplementsText());
  -
           // Write Member Fields
           writeMemberFields();
   
  @@ -166,15 +167,11 @@
   
           // Write the meta data into a Helper class or
           // embed it in the bean class
  -        if (emitter.isHelperWanted()) {
  -            helper.generate(); // separate Helper Class
  -        } else {
  -            helper.generate(pw); // embed in Bean Class
  -        }
  -        
  -        // Write end of class definition
  -        writeClassStop();
  -        pw.close();
  +        if (!emitter.isHelperWanted()) {
  +            // Write the helper info into the bean class
  +            helper.setPrintWriter(pw);
  +        }
  +        helper.generate();
       } // writeFileBody
   
       /**
  @@ -220,6 +217,22 @@
       
       /**
        * Returns the appropriate extends text
  +     * @return "" or "abstract "
  +     */
  +    protected String getClassModifiers() {
  +        Node node = type.getNode();
  +        if (node != null) {
  +            String abstractValue = Utils.getAttribute(node, "abstract");
  +            if (abstractValue != null && 
  +                abstractValue.equalsIgnoreCase("true")) {
  +                return super.getClassModifiers() + "abstract ";
  +            }
  +        }
  +        return super.getClassModifiers();
  +    } // getClassModifiers
  +
  +    /**
  +     * Returns the appropriate extends text
        * @return "" or " extends <class> "
        */
       protected String getExtendsText() {
  @@ -243,42 +256,6 @@
           }
           implementsText += " ";
           return implementsText;
  -    }
  -
  -    /**
  -     * Returns the appropriate extends text
  -     * @return "" or "abstract "
  -     */
  -    protected String getAbstractText() {
  -        Node node = type.getNode();
  -        if (node != null) {
  -            String abstractValue = Utils.getAttribute(node, "abstract");
  -            if (abstractValue != null && 
  -                abstractValue.equalsIgnoreCase("true")) {
  -                return "abstract ";
  -            }
  -        }
  -        return "";
  -    }
  -
  -    /**
  -     * Writes the start of the class definition.
  -     * @param String abstractText is the abstract keyword (or "")
  -     * @param String extendsText is the extends clause (or "")
  -     * @param String implementsText is the implements clause (or "")
  -     */
  -    protected void writeClassStart(String abstractText, 
  -                                   String extendsText,
  -                                   String implementsText) {
  -        pw.println("public " + abstractText + "class " + className + extendsText +
  -                   implementsText + " {");
  -    }
  -
  -    /**
  -     * Writes the end of the class definition.
  -     */
  -    protected void writeClassStop() {
  -        pw.println("}");
       }
   
       /**
  
  
  
  1.47      +64 -37    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
  
  Index: JavaDeployWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- JavaDeployWriter.java     5 Jun 2002 23:24:35 -0000       1.46
  +++ JavaDeployWriter.java     7 Jun 2002 12:45:08 -0000       1.47
  @@ -54,10 +54,30 @@
    */
   package org.apache.axis.wsdl.toJava;
   
  +import java.io.IOException;
  +import java.io.PrintWriter;
  +
  +import java.util.Iterator;
  +import java.util.Map;
  +import java.util.Vector;
  +
  +import javax.wsdl.Binding;
  +import javax.wsdl.BindingOperation;
  +import javax.wsdl.Definition;
  +import javax.wsdl.Operation;
  +import javax.wsdl.OperationType;
  +import javax.wsdl.Port;
  +import javax.wsdl.QName;
  +import javax.wsdl.Service;
  +
   import org.apache.axis.Constants;
  +
   import org.apache.axis.deployment.wsdd.WSDDConstants;
  +
   import org.apache.axis.providers.java.JavaProvider;
  +
   import org.apache.axis.utils.JavaUtils;
  +
   import org.apache.axis.wsdl.symbolTable.BindingEntry;
   import org.apache.axis.wsdl.symbolTable.CollectionType;
   import org.apache.axis.wsdl.symbolTable.DefinedElement;
  @@ -67,19 +87,6 @@
   import org.apache.axis.wsdl.symbolTable.SymbolTable;
   import org.apache.axis.wsdl.symbolTable.TypeEntry;
   
  -import javax.wsdl.Binding;
  -import javax.wsdl.BindingOperation;
  -import javax.wsdl.Definition;
  -import javax.wsdl.Operation;
  -import javax.wsdl.OperationType;
  -import javax.wsdl.Port;
  -import javax.wsdl.QName;
  -import javax.wsdl.Service;
  -import java.io.IOException;
  -import java.util.Iterator;
  -import java.util.Map;
  -import java.util.Vector;
  -
   /**
   * This is Wsdl2java's deploy Writer.  It writes the deploy.java file.
   */
  @@ -93,15 +100,15 @@
       public JavaDeployWriter(Emitter emitter,
                                  Definition definition,
                                  SymbolTable symbolTable) {
  -        super(emitter,
  -                new QName(definition.getTargetNamespace(), "deploy"),
  -                "",
  -                "wsdd",
  -                JavaUtils.getMessage("genDeploy00"), "deploy");
  +        super(emitter, "deploy");
           this.definition = definition;
           this.symbolTable = symbolTable;
       } // ctor
   
  +    /**
  +     * Generate deploy.wsdd.  Only generate it if the emitter
  +     * is generating server-side mappings.
  +     */
       public void generate() throws IOException {
           if (emitter.isServerSide()) {
               super.generate();
  @@ -109,25 +116,45 @@
       } // generate
   
       /**
  +     * Return the fully-qualified name of the deploy.wsdd file
  +     * to be generated.
  +     */
  +    protected String getFileName() {
  +        String dir = emitter.getNamespaces().getAsDir(
  +                definition.getTargetNamespace());
  +        return dir + "deploy.wsdd";
  +    } // getFileName
  +
  +    /**
        * Replace the default file header with the deployment doc file header.
        */
  -    protected void writeFileHeader() throws IOException {
  -        initializeDeploymentDoc("deploy");
  +    protected void writeFileHeader(PrintWriter pw) throws IOException {
  +        pw.println(JavaUtils.getMessage("deploy00"));
  +        pw.println(JavaUtils.getMessage("deploy02"));
  +        pw.println(JavaUtils.getMessage("deploy03"));
  +        pw.println(JavaUtils.getMessage("deploy05"));
  +        pw.println(JavaUtils.getMessage("deploy06"));
  +        pw.println(JavaUtils.getMessage("deploy07"));
  +        pw.println(JavaUtils.getMessage("deploy09"));
  +        pw.println();
  +        pw.println("<deployment");
  +        pw.println("    xmlns=\"" + WSDDConstants.URI_WSDD +"\"");
  +        pw.println("    xmlns:" + WSDDConstants.NS_PREFIX_WSDD_JAVA + "=\"" +
  +                   WSDDConstants.URI_WSDD_JAVA +"\">");
       } // writeFileHeader
   
       /**
  -     * Write the body of the deploy.xml file.
  +     * Write the body of the deploy.wsdd file.
        */
  -    protected void writeFileBody() throws IOException {
  -        writeDeployServices();
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
  +        writeDeployServices(pw);
           pw.println("</deployment>");
  -        pw.close();
       } // writeFileBody
   
       /**
        * Write out deployment and undeployment instructions for each WSDL service
        */
  -    protected void writeDeployServices() throws IOException {
  +    protected void writeDeployServices(PrintWriter pw) throws IOException {
           //deploy the ports on each service
           Map serviceMap = definition.getServices();
           for (Iterator mapIterator = serviceMap.values().iterator();
  @@ -151,7 +178,7 @@
                   if (bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
                       continue;
                   }
  -                writeDeployPort(myPort);
  +                writeDeployPort(pw, myPort);
               }
           }
       } //writeDeployServices
  @@ -159,7 +186,7 @@
       /**
        * Write out bean mappings for each type
        */
  -    protected void writeDeployTypes(boolean hasLiteral) throws IOException {
  +    protected void writeDeployTypes(PrintWriter pw, boolean hasLiteral) throws 
IOException {
           Vector types = symbolTable.getTypes();
   
           pw.println();
  @@ -213,7 +240,7 @@
                       serializerFactory = 
"org.apache.axis.encoding.ser.BeanSerializerFactory";
                       deserializerFactory = 
"org.apache.axis.encoding.ser.BeanDeserializerFactory";
                   }
  -                writeTypeMapping(namespaceURI, localPart, javaType, 
serializerFactory,
  +                writeTypeMapping(pw, namespaceURI, localPart, javaType, 
serializerFactory,
                                    deserializerFactory, encodingStyle);
                   }
           }
  @@ -222,7 +249,7 @@
       /**
        * Raw routine that writes out the typeMapping.
        */
  -    protected void writeTypeMapping(String namespaceURI, String localPart, String 
javaType,
  +    protected void writeTypeMapping(PrintWriter pw, String namespaceURI, String 
localPart, String javaType,
                                       String serializerFactory, String 
deserializerFactory,
                                       String encodingStyle) throws IOException {
           pw.println("      <typeMapping");
  @@ -238,7 +265,7 @@
       /**
        * Write out deployment and undeployment instructions for given WSDL port
        */
  -    protected void writeDeployPort(Port port) throws IOException {
  +    protected void writeDeployPort(PrintWriter pw, Port port) throws IOException {
           Binding binding = port.getBinding();
           BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
           String serviceName = port.getName();
  @@ -260,9 +287,8 @@
                   + "\" provider=\"" + prefix +":RPC"
                   + "\"" + styleStr + ">");
   
  -        writeDeployBinding(binding);
  -        writeDeployTypes(hasLiteral);
  -
  +        writeDeployBinding(pw, binding);
  +        writeDeployTypes(pw, hasLiteral);
   
           pw.println("  </service>");
       } //writeDeployPort
  @@ -270,7 +296,7 @@
       /**
        * Write out deployment instructions for given WSDL binding
        */
  -    protected void writeDeployBinding(Binding binding) throws IOException {
  +    protected void writeDeployBinding(PrintWriter pw, Binding binding) throws 
IOException {
           BindingEntry bEntry = symbolTable.getBindingEntry(binding.getQName());
           String className = bEntry.getName();
           if (emitter.isSkeletonWanted())
  @@ -313,7 +339,7 @@
                           returnQName = Utils.getWSDLQName(params.returnName);
   
                       // Write the operation metadata
  -                    writeOperation(javaOperName, elementQName, returnQName,
  +                    writeOperation(pw, javaOperName, elementQName, returnQName,
                                      params);
                   }
               }
  @@ -341,7 +367,8 @@
       /**
        * Raw routine that writes out the operation and parameters.
        */
  -    protected void writeOperation(String javaOperName,
  +    protected void writeOperation(PrintWriter pw,
  +                                  String javaOperName,
                                     QName elementQName,
                                     QName returnQName,
                                     Parameters params) {
  @@ -367,7 +394,7 @@
               QName paramType = null;
   
               // Get the parameter type QName
  -            if (typeEntry instanceof DefinedElement && 
  +            if (typeEntry instanceof DefinedElement &&
                   typeEntry.getRefType() != null) {
                   paramType = typeEntry.getRefType().getQName();
               } else {
  
  
  
  1.8       +13 -13    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaEnumTypeWriter.java
  
  Index: JavaEnumTypeWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaEnumTypeWriter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JavaEnumTypeWriter.java   17 May 2002 19:09:33 -0000      1.7
  +++ JavaEnumTypeWriter.java   7 Jun 2002 12:45:08 -0000       1.8
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Vector;
   
  @@ -67,7 +68,7 @@
   /**
   * This is Wsdl2java's Complex Type Writer.  It writes the <typeName>.java file.
   */
  -public class JavaEnumTypeWriter extends JavaWriter {
  +public class JavaEnumTypeWriter extends JavaClassWriter {
       private TypeEntry type;
       private Vector elements;
   
  @@ -77,20 +78,26 @@
       protected JavaEnumTypeWriter(
               Emitter emitter,
               TypeEntry type, Vector elements) {
  -        super(emitter, type, "", "java",
  -                JavaUtils.getMessage("genType00"), "enumType");
  +        super(emitter, type.getName(), "enumType");
           this.type = type;
           this.elements = elements;
       } // ctor
   
  +    /**
  +     * Return "implements java.io.Serializable ".
  +     */
  +    protected String getImplementsText() {
  +        return "implements java.io.Serializable ";
  +    } // getImplementsText
  +
      /**
        * Generate the binding for the given enumeration type.
        * The values vector contains the base type (first index) and
        * the values (subsequent Strings)
        */
  -    protected void writeFileBody() throws IOException {
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           // Get the java name of the type
  -        String javaName = Utils.getJavaLocalName(type.getName());
  +        String javaName = getClassName();
   
           // The first index is the base type.
           // The base type could be a non-object, if so get the corresponding Class.
  @@ -143,10 +150,6 @@
                   ids.add(elements.get(i));
           }
   
  -        // Note:
  -        // This class conforms to the JSR 101 Version 0.6 Public Draft
  -        pw.println("public class " + javaName + " implements java.io.Serializable 
{");
  -
           // Each object has a private _value_ variable to store the base value
           pw.println("    private " + baseType + " _value_;");
   
  @@ -229,9 +232,6 @@
               pw.println("    public String toString() { return _value_;}");
           else                            
               pw.println("    public String toString() { return 
String.valueOf(_value_);}");
  -        pw.println("}");
  -
  -        pw.close();
  -    } // writeOperation
  +    } // writeFileBody
   
   } // class JavaEnumTypeWriter
  
  
  
  1.9       +11 -17    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaFaultWriter.java
  
  Index: JavaFaultWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaFaultWriter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JavaFaultWriter.java      9 May 2002 13:14:28 -0000       1.8
  +++ JavaFaultWriter.java      7 Jun 2002 12:45:08 -0000       1.9
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Vector;
   
  @@ -70,7 +71,7 @@
   * This is Wsdl2java's Fault Writer.  It writes the <faultName>.java file.
   * NOTE:  this must be rewritten.  It doesn't follow JAX-RPC.
   */
  -public class JavaFaultWriter extends JavaWriter {
  +public class JavaFaultWriter extends JavaClassWriter {
       private Fault fault;
       private SymbolTable symbolTable;
   
  @@ -78,25 +79,22 @@
        * Constructor.
        */
       protected JavaFaultWriter(Emitter emitter, QName qname, Fault fault, 
SymbolTable symbolTable) {
  -        super(emitter, qname, "", "java", JavaUtils.getMessage("genFault00"), 
"fault");
  -
  -        // Need to adjust the className and fileName to make sure they are 
consistent with
  -        // the full name.  The alternative is to pass a 'dummy' qname into 
JavaFaultWriter,
  -        // which is not appropriate.
  -        String fullName = Utils.getFullExceptionName(fault, emitter);
  -        className = fullName.substring(fullName.lastIndexOf(".") + 1);
  -        fileName = className + ".java";
  -
  +        super(emitter, Utils.getFullExceptionName(fault, emitter), "fault");
           this.fault = fault;
           this.symbolTable = symbolTable;
       } // ctor
   
       /**
  -     * Write the body of the Fault file.
  +     * Return "extends org.apache.axis.AxisFault ".
        */
  -    protected void writeFileBody() throws IOException {
  -        pw.println("public class " + className + " extends 
org.apache.axis.AxisFault {");
  +    protected String getExtendsText() {
  +        return "extends org.apache.axis.AxisFault ";
  +    } // getExtendsText
   
  +    /**
  +     * Write the body of the Fault file.
  +     */
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           Vector params = new Vector();
   
           // XXX  Have to get use information (literal/encoded) for fault from
  @@ -142,10 +140,6 @@
               }
               pw.println("    }");
           }
  -        
  -        // Done with class
  -        pw.println("}");
  -        pw.close();
       } // writeFileBody
   
   } // class JavaFaultWriter
  
  
  
  1.9       +18 -14    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaHolderWriter.java
  
  Index: JavaHolderWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaHolderWriter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JavaHolderWriter.java     9 May 2002 13:14:28 -0000       1.8
  +++ JavaHolderWriter.java     7 Jun 2002 12:45:08 -0000       1.9
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import javax.wsdl.QName;
   
  @@ -65,31 +66,36 @@
   /**
   * This is Wsdl2java's Holder Writer.  It writes the <typeName>Holder.java file.
   */
  -public class JavaHolderWriter extends JavaWriter {
  +public class JavaHolderWriter extends JavaClassWriter {
       private TypeEntry type;
   
       /**
        * Constructor.
        */
       protected JavaHolderWriter(Emitter emitter, TypeEntry type) {
  -        super(
  -                emitter,
  -                new QName(
  -                        type.getQName().getNamespaceURI(),
  -                        Utils.holder(type, emitter).substring(
  -                        Utils.holder(type, emitter).lastIndexOf('.') + 1)),
  -                null,
  -                "java",
  -                JavaUtils.getMessage("genHolder00"), "holder");
  +        super(emitter, Utils.holder(type, emitter), "holder");
           this.type = type;
       } // ctor
   
       /**
  +     * Return "public final ".
  +     */
  +    protected String getClassModifiers() {
  +        return super.getClassModifiers() + "final ";
  +    } // getClassModifiers
  +
  +    /**
  +     * Return "implements javax.xml.rpc.holders.Holder ".
  +     */
  +    protected String getImplementsText() {
  +        return "implements javax.xml.rpc.holders.Holder ";
  +    } // getImplementsText
  +
  +    /**
        * Generate the holder for the given complex type.
        */
  -    protected void writeFileBody() throws IOException {
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           String holderType = Utils.getJavaLocalName(type.getName());
  -        pw.println("public final class " + className + " implements 
javax.xml.rpc.holders.Holder {");
           pw.println("    public " + holderType + " value;");
           pw.println();
           pw.println("    public " + className + "() {");
  @@ -100,8 +106,6 @@
           pw.println("    }");
           pw.println();
           pw.println("    // ?++?");
  -        pw.println("}");
  -        pw.close();
       } // writeOperation
   
   } // class JavaHolderWriter
  
  
  
  1.23      +10 -22    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaImplWriter.java
  
  Index: JavaImplWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaImplWriter.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JavaImplWriter.java       20 May 2002 20:07:28 -0000      1.22
  +++ JavaImplWriter.java       7 Jun 2002 12:45:08 -0000       1.23
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Collection;
   import java.util.HashMap;
  @@ -93,7 +94,7 @@
   * This is Wsdl2java's implementation template writer.  It writes the 
<BindingName>Impl.java
   * file which contains the <bindingName>Impl class.
   */
  -public class JavaImplWriter extends JavaWriter {
  +public class JavaImplWriter extends JavaClassWriter {
       protected Binding binding;
       protected SymbolTable symbolTable;
       protected BindingEntry bEntry;
  @@ -105,8 +106,7 @@
               Emitter emitter,
               BindingEntry bEntry,
               SymbolTable symbolTable) {
  -        super(emitter, bEntry, "Impl", "java",
  -                JavaUtils.getMessage("genImpl00"), "skeletonImpl");
  +        super(emitter, bEntry.getName() + "Impl", "templateImpl");
           this.binding = bEntry.getBinding();
           this.symbolTable = symbolTable;
           this.bEntry = bEntry;
  @@ -115,11 +115,7 @@
       /**
        * Write the body of the binding's stub file.
        */
  -    protected void writeFileBody() throws IOException {
  -
  -        pw.print("public class " + className + getExtendsText() + 
getImplementsText());
  -        pw.println(" {");
  -
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           List operations = binding.getBindingOperations();
           for (int i = 0; i < operations.size(); ++i) {
               BindingOperation operation = (BindingOperation) operations.get(i);
  @@ -136,33 +132,25 @@
                   pw.println();
               }
               else {
  -                writeOperation(parameters);
  +                writeOperation(pw, parameters);
               }
           }
  -        pw.println("}");
  -        pw.close();
       } // writeFileBody
   
       /**
  -     * Returns the appropriate extends text
  -     * @return "" or " extends <class> "
  -     */
  -    protected String getExtendsText() {
  -        // See if this class extends another class
  -        return "";
  -    }
  -    
  -    /**
        * Returns the appropriate implements text
        * @return " implements <classes>"
        */
       protected String getImplementsText() {
           String portTypeName = (String) 
bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME);
  -        String implementsText = " implements " + portTypeName;
  +        String implementsText = "implements " + portTypeName;
           return implementsText;
       }
   
  -    protected void writeOperation(Parameters parms) throws IOException {
  +    /**
  +     * Write the implementation template for the given operation.
  +     */
  +    protected void writeOperation(PrintWriter pw, Parameters parms) throws 
IOException {
           pw.println(parms.signature + " {");
   
           // Fill in any out parameter holders
  
  
  
  1.11      +24 -21    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaInterfaceWriter.java
  
  Index: JavaInterfaceWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaInterfaceWriter.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JavaInterfaceWriter.java  16 May 2002 22:27:46 -0000      1.10
  +++ JavaInterfaceWriter.java  7 Jun 2002 12:45:08 -0000       1.11
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Iterator;
   
  @@ -72,11 +73,9 @@
   * This is Wsdl2java's PortType Writer.  It writes the <portTypeName>.java file
   * which contains the <portTypeName> interface.
   */
  -public class JavaInterfaceWriter extends JavaWriter {
  -    protected PortType      portType;
  -    protected PortTypeEntry ptEntry;
  -    protected SymbolTable   symbolTable;
  -    protected BindingEntry  bEntry;
  +public class JavaInterfaceWriter extends JavaClassWriter {
  +    protected PortType     portType;
  +    protected BindingEntry bEntry;
   
       /**
        * Constructor.
  @@ -84,15 +83,10 @@
       protected JavaInterfaceWriter(
               Emitter emitter,
               PortTypeEntry ptEntry, BindingEntry bEntry, SymbolTable symbolTable) {
  -        super(emitter, ptEntry, "", "java", JavaUtils.getMessage("genIface00"), 
"interface");
  -        this.ptEntry = ptEntry;
  +        super(emitter, (String) bEntry.getDynamicVar(
  +                JavaBindingWriter.INTERFACE_NAME), "interface");
           this.portType = ptEntry.getPortType();
  -        this.symbolTable = symbolTable;
           this.bEntry = bEntry;
  -
  -        super.className = Utils.getJavaLocalName(
  -                (String) bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME));
  -        super.fileName = className + ".java";
       } // ctor
   
       /**
  @@ -100,7 +94,7 @@
        * of two bindings referencing the same portType
        */
       public void generate() throws IOException {
  -        String fqClass = packageName + "." + className;
  +        String fqClass = getPackage() + "." + getClassName();
   
           // Do not emit the same portType/interface twice
           if (!emitter.getGeneratedFileInfo().getClassNames().contains(fqClass)) {
  @@ -109,25 +103,34 @@
       } // generate
   
       /**
  -     * Write the body of the portType interface file.
  +     * Returns "interface ".
  +     */
  +    protected String getClassText() {
  +        return "interface ";
  +    } // getClassString
  +
  +    /**
  +     * Returns "extends java.rmi.Remote ".
        */
  -    protected void writeFileBody() throws IOException {
  -        pw.println("public interface " + className + " extends java.rmi.Remote {");
  +    protected String getExtendsText() {
  +        return "extends java.rmi.Remote ";
  +    } // getExtendsText
   
  +    /**
  +     * Write the body of the portType interface file.
  +     */
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           Iterator operations = portType.getOperations().iterator();
           while(operations.hasNext()) {
               Operation operation = (Operation) operations.next();
  -            writeOperation(operation);
  +            writeOperation(pw, operation);
           }
  -
  -        pw.println("}");
  -        pw.close();
       } // writeFileBody
   
       /**
        * This method generates the interface signatures for the given operation.
        */
  -    protected void writeOperation(Operation operation) throws IOException {
  +    protected void writeOperation(PrintWriter pw, Operation operation) throws 
IOException {
           writeComment(pw, operation.getDocumentationElement());
           Parameters parms = bEntry.getParameters(operation);
           pw.println(parms.signature + ";");
  
  
  
  1.6       +18 -11    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceIfaceWriter.java
  
  Index: JavaServiceIfaceWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceIfaceWriter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JavaServiceIfaceWriter.java       16 May 2002 19:34:17 -0000      1.5
  +++ JavaServiceIfaceWriter.java       7 Jun 2002 12:45:08 -0000       1.6
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Iterator;
   import java.util.Map;
  @@ -73,7 +74,7 @@
   /**
   * This is Wsdl2java's service writer.  It writes the <serviceName>.java file.
   */
  -public class JavaServiceIfaceWriter extends JavaWriter {
  +public class JavaServiceIfaceWriter extends JavaClassWriter {
       private Service service;
       private SymbolTable symbolTable;
   
  @@ -84,20 +85,29 @@
               Emitter emitter,
               ServiceEntry sEntry,
               SymbolTable symbolTable) {
  -        super(emitter, sEntry, "", "java",
  -                JavaUtils.getMessage("genService00"), "service");
  +        super(emitter, sEntry.getName(), "service");
           this.service = sEntry.getService();
           this.symbolTable = symbolTable;
       } // ctor
   
       /**
  -     * Write the body of the service file.
  +     * Returns "interface ".
  +     */
  +    protected String getClassText() {
  +        return "interface ";
  +    } // getClassString
  +
  +    /**
  +     * Returns "extends javax.xml.rpc.Service ".
        */
  -    protected void writeFileBody() throws IOException {
  -        // declare class
  -        pw.println("public interface " + className
  -                + " extends javax.xml.rpc.Service {");
  +    protected String getExtendsText() {
  +        return "extends javax.xml.rpc.Service ";
  +    } // getExtendsText
   
  +    /**
  +     * Write the body of the service file.
  +     */
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           // output comments
           writeComment(pw, service.getDocumentationElement());
   
  @@ -151,9 +161,6 @@
               pw.println("    public " + bindingType + " get" + portName
                       + "(java.net.URL portAddress) throws 
javax.xml.rpc.ServiceException;");
           }
  -        // all done
  -        pw.println("}");
  -        pw.close();
       } // writeFileBody
   
   } // class JavaServiceIfaceWriter
  
  
  
  1.15      +18 -14    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java
  
  Index: JavaServiceImplWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaServiceImplWriter.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JavaServiceImplWriter.java        21 May 2002 15:43:02 -0000      1.14
  +++ JavaServiceImplWriter.java        7 Jun 2002 12:45:08 -0000       1.15
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.net.MalformedURLException;
   import java.net.URL;
  @@ -80,7 +81,7 @@
   * This is Wsdl2java's service implementation writer.
   * It writes the <serviceName>Locator.java file.
   */
  -public class JavaServiceImplWriter extends JavaWriter {
  +public class JavaServiceImplWriter extends JavaClassWriter {
       private ServiceEntry sEntry;
       private SymbolTable  symbolTable;
   
  @@ -91,23 +92,30 @@
               Emitter emitter,
               ServiceEntry sEntry,
               SymbolTable symbolTable) {
  -        super(emitter, sEntry, "Locator", "java",
  -                JavaUtils.getMessage("genService00"), "service");
  +        super(emitter, sEntry.getName() + "Locator", "service");
           this.sEntry = sEntry;
           this.symbolTable = symbolTable;
       } // ctor
   
       /**
  -     * Write the body of the service file.
  +     * Returns "extends org.apache.axis.client.Service ".
        */
  -    protected void writeFileBody() throws IOException {
  -        Service service = sEntry.getService();
  +    protected String getExtendsText() {
  +        return "extends org.apache.axis.client.Service ";
  +    } // getExtendsText
   
  -        // declare class
  -        pw.println("public class " + className
  -                + " extends org.apache.axis.client.Service implements "
  -                + sEntry.getName() + " {");
  +    /**
  +     * Returns "implements <serviceInterface>".
  +     */
  +    protected String getImplementsText() {
  +        return "implements " + sEntry.getName() + ' ';
  +    } // getImplementsText
   
  +    /**
  +     * Write the body of the service file.
  +     */
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
  +        Service service = sEntry.getService();
           // output comments
           writeComment(pw, service.getDocumentationElement());
   
  @@ -250,10 +258,6 @@
           }
           pw.println("    }");
           pw.println();
  -
  -        // all done
  -        pw.println("}");
  -        pw.close();
       } // writeFileBody
   
   } // class JavaServiceImplWriter
  
  
  
  1.29      +29 -28    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java
  
  Index: JavaSkelWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- JavaSkelWriter.java       3 Jun 2002 02:15:53 -0000       1.28
  +++ JavaSkelWriter.java       7 Jun 2002 12:45:08 -0000       1.29
  @@ -54,13 +54,11 @@
    */
   package org.apache.axis.wsdl.toJava;
   
  -import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.wsdl.symbolTable.BindingEntry;
  -import org.apache.axis.wsdl.symbolTable.Element;
  -import org.apache.axis.wsdl.symbolTable.Parameter;
  -import org.apache.axis.wsdl.symbolTable.Parameters;
  -import org.apache.axis.wsdl.symbolTable.SymbolTable;
  -import org.apache.axis.wsdl.symbolTable.TypeEntry;
  +import java.io.IOException;
  +import java.io.PrintWriter;
  +
  +import java.util.Iterator;
  +import java.util.List;
   
   import javax.wsdl.Binding;
   import javax.wsdl.BindingInput;
  @@ -68,19 +66,26 @@
   import javax.wsdl.BindingOutput;
   import javax.wsdl.Operation;
   import javax.wsdl.OperationType;
  +
   import javax.wsdl.extensions.ExtensibilityElement;
  +
   import javax.wsdl.extensions.soap.SOAPBody;
   import javax.wsdl.extensions.soap.SOAPOperation;
  +
   import javax.xml.rpc.namespace.QName;
  -import java.io.IOException;
  -import java.util.Iterator;
  -import java.util.List;
  +
  +import org.apache.axis.wsdl.symbolTable.BindingEntry;
  +import org.apache.axis.wsdl.symbolTable.Element;
  +import org.apache.axis.wsdl.symbolTable.Parameter;
  +import org.apache.axis.wsdl.symbolTable.Parameters;
  +import org.apache.axis.wsdl.symbolTable.SymbolTable;
  +import org.apache.axis.wsdl.symbolTable.TypeEntry;
   
   /**
   * This is Wsdl2java's skeleton writer.  It writes the <BindingName>Skeleton.java
   * file which contains the <bindingName>Skeleton class.
   */
  -public class JavaSkelWriter extends JavaWriter {
  +public class JavaSkelWriter extends JavaClassWriter {
       private BindingEntry bEntry;
       private Binding binding;
       private SymbolTable symbolTable;
  @@ -92,32 +97,30 @@
               Emitter emitter,
               BindingEntry bEntry,
               SymbolTable symbolTable) {
  -        super(emitter, bEntry, "Skeleton", "java",
  -                JavaUtils.getMessage("genSkel00"), "skeleton");
  +        super(emitter, bEntry.getName() + "Skeleton", "skeleton");
           this.bEntry = bEntry;
           this.binding = bEntry.getBinding();
           this.symbolTable = symbolTable;
       } // ctor
   
       /**
  -     * Write the body of the binding's stub file.
  +     * Returns "implements <SEI>, org.apache.axis.wsdl.Skeleton ".
        */
  -    protected void writeFileBody() throws IOException {
  -//        PortType portType = binding.getPortType();
  -//        PortTypeEntry ptEntry =
  -//                symbolTable.getPortTypeEntry(portType.getQName());
  +    protected String getImplementsText() {
  +        return "implements " + 
bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME)
  +                + ", org.apache.axis.wsdl.Skeleton ";
  +    } // getImplementsText
   
  +    /**
  +     * Write the body of the binding's stub file.
  +     */
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           String portTypeName = (String) 
bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME);
  +        String implType = portTypeName + " impl";
           boolean isRPC = true;
           if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) {
               isRPC = false;
           }
  -
  -        // The skeleton implements the portType and the WSDL2Java emitter skeleton
  -        String implType = portTypeName + " impl";
  -        pw.println("public class " + className + " implements " + portTypeName + 
",");
  -        pw.println("    org.apache.axis.wsdl.Skeleton {"); 
  -
           // Declare private impl and skeleton base delegates
           pw.println("    private " + implType + ";");
           pw.println("    private static java.util.Map _myOperations = new 
java.util.Hashtable();");
  @@ -304,18 +307,17 @@
                   pw.println();
               }
               else {
  -                writeOperation(
  +                writeOperation(pw,
                           operation, parameters, soapAction, namespace, isRPC);
               }
           }
  -        pw.println("}");
  -        pw.close();
       } // writeFileBody
   
       /**
        * Write the skeleton code for the given operation.
        */
       private void writeOperation(
  +            PrintWriter pw,
               BindingOperation operation,
               Parameters parms,
               String soapAction,
  @@ -357,6 +359,5 @@
           pw.println("    }");
           pw.println();
       } // writeSkeletonOperation
  -
   
   } // class JavaSkelWriter
  
  
  
  1.66      +31 -21    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- JavaStubWriter.java       31 May 2002 20:34:32 -0000      1.65
  +++ JavaStubWriter.java       7 Jun 2002 12:45:08 -0000       1.66
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Collection;
   import java.util.HashSet;
  @@ -92,7 +93,7 @@
   * This is Wsdl2java's stub writer.  It writes the <BindingName>Stub.java
   * file which contains the <bindingName>Stub class.
   */
  -public class JavaStubWriter extends JavaWriter {
  +public class JavaStubWriter extends JavaClassWriter {
       private BindingEntry bEntry;
       private Binding binding;
       private SymbolTable symbolTable;
  @@ -104,17 +105,30 @@
               Emitter emitter,
               BindingEntry bEntry,
               SymbolTable symbolTable) {
  -        super(emitter, bEntry, "Stub", "java",
  -                JavaUtils.getMessage("genStub00"), "stub");
  +        super(emitter, bEntry.getName() + "Stub", "stub");
           this.bEntry = bEntry;
           this.binding = bEntry.getBinding();
           this.symbolTable = symbolTable;
       } // ctor
   
       /**
  +     * Returns "extends org.apache.axis.client.Stub ".
  +     */
  +    protected String getExtendsText() {
  +        return "extends org.apache.axis.client.Stub ";
  +    } // getExtendsText
  +
  +    /**
  +     * Returns "implements <SEI> ".
  +     */
  +    protected String getImplementsText() {
  +        return "implements " + 
bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME) + " ";
  +    } // getImplementsText
  +
  +    /**
        * Write the body of the binding's stub file.
        */
  -    protected void writeFileBody() throws IOException {
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
           PortType portType = binding.getPortType();
   
           String portTypeName = 
  @@ -123,9 +137,6 @@
           if (bEntry.getBindingStyle() == BindingEntry.STYLE_DOCUMENT) {
               isRPC = false;
           }
  -
  -        pw.println("public class " + className + " extends 
org.apache.axis.client.Stub implements " + portTypeName + " {");
  -
           HashSet types = getTypesInPortType(portType);
           if (types.size() > 0) {
               pw.println("    private java.util.Vector cachedSerClasses = new 
java.util.Vector();");
  @@ -156,7 +167,7 @@
   
           Iterator it = types.iterator();
           while (it.hasNext()) {
  -            writeSerializationInit((TypeEntry) it.next());
  +            writeSerializationInit(pw, (TypeEntry) it.next());
           }
   
           pw.println("        }");
  @@ -289,12 +300,10 @@
                   pw.println();
               }
               else {
  -                writeOperation(
  +                writeOperation(pw,
                           operation, parameters, soapAction, namespace, isRPC);
               }
           }
  -        pw.println("}");
  -        pw.close();
       } // writeFileBody
   
       /**
  @@ -394,7 +403,7 @@
        */
       private boolean firstSer = true ;
   
  -    private void writeSerializationInit(TypeEntry type) throws IOException {
  +    private void writeSerializationInit(PrintWriter pw, TypeEntry type) throws 
IOException {
   
           // Note this same check is repeated in JavaDeployWriter.
           boolean process = true;
  @@ -473,6 +482,7 @@
        * Write the stub code for the given operation.
        */
       private void writeOperation(
  +            PrintWriter pw,
               BindingOperation operation,
               Parameters parms,
               String soapAction,
  @@ -493,9 +503,9 @@
   
               // We need to use the Qname of the actual type, not the QName of the 
element
               TypeEntry type = p.getType();
  -            if (type instanceof DefinedElement) {
  -                if (type.getRefType() != null)
  -                    type = type.getRefType();
  +            if (type instanceof DefinedElement
  +                    && type.getRefType() != null) {
  +                type = type.getRefType();
               }
               QName qn = type.getQName();
               String javaType = type.getName();
  @@ -535,7 +545,7 @@
               // We need to use the Qname of the actual type, not the QName of the 
element
               QName qn = parms.returnType.getQName();
               if (parms.returnType instanceof DefinedElement) {
  -                TypeEntry type = ((DefinedElement)parms.returnType).getRefType();
  +                TypeEntry type = ((DefinedElement) parms.returnType).getRefType();
                   if (type != null && type.getQName() != null) {
                       qn = type.getQName();
                   }
  @@ -647,14 +657,14 @@
                                  
                       pw.println("            java.util.Map output;");
                       pw.println("            output = call.getOutputParams();");
  -                    writeOutputAssign(javifiedName + ".value =",
  +                    writeOutputAssign(pw, javifiedName + ".value =",
                                         p.getType(),
                                         "output.get(" + qnameName + ")");
                   }
                   else {
                       // (parms.outputs == 1)
                       // There is only one output and it is the return value.
  -                    writeOutputAssign("return ",
  +                    writeOutputAssign(pw, "return ",
                                         parms.returnType, "resp");
                   }
               }
  @@ -668,13 +678,13 @@
                       String qnameName = Utils.getNewQName(
                               Utils.getAxisQName(p.getQName()));
                       if (p.getMode() != Parameter.IN) {
  -                        writeOutputAssign(javifiedName + ".value =",
  +                        writeOutputAssign(pw, javifiedName + ".value =",
                                             p.getType(),
                                             "output.get(" + qnameName + ")");
                       }
                   }
                   if (parms.outputs > 0) {
  -                    writeOutputAssign("return ",
  +                    writeOutputAssign(pw, "return ",
                                         parms.returnType,
                                         "resp");
                   }
  @@ -693,7 +703,7 @@
        * @param source (source String)   
        *
        */
  -    private void writeOutputAssign(String target,
  +    private void writeOutputAssign(PrintWriter pw, String target,
                                      TypeEntry type, 
                                      String source) {
           if (type != null && type.getName() != null) {
  
  
  
  1.28      +17 -28    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java
  
  Index: JavaTestCaseWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaTestCaseWriter.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- JavaTestCaseWriter.java   20 May 2002 20:07:29 -0000      1.27
  +++ JavaTestCaseWriter.java   7 Jun 2002 12:45:08 -0000       1.28
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Iterator;
   import java.util.Map;
  @@ -81,7 +82,7 @@
   /**
   * This is Wsdl2java's TestCase writer.  It writes the <serviceName>TestCase.java 
file.
   */
  -public class JavaTestCaseWriter extends JavaWriter {
  +public class JavaTestCaseWriter extends JavaClassWriter {
       private ServiceEntry sEntry;
       private SymbolTable symbolTable;
   
  @@ -92,33 +93,29 @@
               Emitter emitter,
               ServiceEntry sEntry,
               SymbolTable symbolTable) {
  -        super(emitter, sEntry, "TestCase", "java",
  -                JavaUtils.getMessage("genTest00"), "testCase");
  +        super(emitter, sEntry.getName() + "TestCase", "testCase");
           this.sEntry = sEntry;
           this.symbolTable = symbolTable;
       } // ctor
   
       /**
  -     * Write the common header plus the ctors.
  +     * Returns "extends junit.framework.TestCase ".
        */
  -    protected void writeFileHeader() throws IOException {
  -        super.writeFileHeader();
  -
  -        pw.print("public class ");
  -        pw.print(this.className);
  -        pw.println(" extends junit.framework.TestCase {");
  +    protected String getExtendsText() {
  +        return "extends junit.framework.TestCase ";
  +    } // getExtendsText
   
  +    /**
  +     * Write the body of the TestCase file.
  +     */
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
  +        // Write the constructor
           pw.print("    public ");
  -        pw.print(this.className);
  +        pw.print(getClassName());
           pw.println("(String name) {");
           pw.println("        super(name);");
           pw.println("    }");
  -    } // writeFileHeader
   
  -    /**
  -     * Write the body of the TestCase file.
  -     */
  -    protected void writeFileBody() throws IOException {
           // get ports
           Map portMap = sEntry.getService().getPorts();
           Iterator portIterator = portMap.values().iterator();
  @@ -140,25 +137,17 @@
                       symbolTable.getPortTypeEntry(portType.getQName());
   
               writeComment(pw, p.getDocumentationElement());
  -            writeServiceTestCode(portName, portType, ptEntry, binding, bEntry);
  +            writeServiceTestCode(pw, portName, portType, ptEntry, binding, bEntry);
           }
  -        finish();
       } // writeFileBody
   
  -    public final void finish() {
  -        pw.println("}");
  -        pw.println();
  -        pw.flush();
  -        pw.close();
  -    } // finish
  -
       // Methods may be overloaded.  If we just grab the method name
       // for the test method names, we could end up with duplicates.
       // The quick-and-easy solution is to have a test counter so that
       // each test method has a number.
       private int counter = 1;
   
  -    private final void writeServiceTestCode(
  +    private final void writeServiceTestCode(PrintWriter pw,
               String portName, PortType portType, PortTypeEntry ptEntry,
               Binding binding, BindingEntry bEntry) throws IOException {
           Iterator ops = portType.getOperations().iterator();
  @@ -180,7 +169,7 @@
               pw.println("    public void " + testMethodName + "() {");
   
               String bindingType = (String) 
bEntry.getDynamicVar(JavaBindingWriter.INTERFACE_NAME);
  -            writeBindingAssignment(bindingType, portName);
  +            writeBindingAssignment(pw, bindingType, portName);
   
               pw.println("        try {");
               if (params.returnType != null) {
  @@ -321,7 +310,7 @@
           }
       } // writeServiceTestCode
   
  -    public final void writeBindingAssignment(
  +    public final void writeBindingAssignment(PrintWriter pw,
               String bindingType, String portName) throws IOException {
           pw.println("        " + bindingType + " binding;");
           pw.println("        try {");
  
  
  
  1.7       +37 -18    
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaUndeployWriter.java
  
  Index: JavaUndeployWriter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaUndeployWriter.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JavaUndeployWriter.java   17 May 2002 19:09:33 -0000      1.6
  +++ JavaUndeployWriter.java   7 Jun 2002 12:45:08 -0000       1.7
  @@ -55,6 +55,7 @@
   package org.apache.axis.wsdl.toJava;
   
   import java.io.IOException;
  +import java.io.PrintWriter;
   
   import java.util.Iterator;
   import java.util.Map;
  @@ -65,6 +66,8 @@
   import javax.wsdl.QName;
   import javax.wsdl.Service;
   
  +import org.apache.axis.deployment.wsdd.WSDDConstants;
  +
   import org.apache.axis.utils.JavaUtils;
   
   import org.apache.axis.wsdl.symbolTable.BindingEntry;
  @@ -74,22 +77,20 @@
   * This is Wsdl2java's deploy Writer.  It writes the deploy.java file.
   */
   public class JavaUndeployWriter extends JavaWriter {
  -    private Definition definition;
  -    private SymbolTable symbolTable;
  +    protected Definition definition;
   
       /**
        * Constructor.
        */
  -    public JavaUndeployWriter(Emitter emitter, Definition definition, SymbolTable 
symbolTable) {
  -        super(emitter,
  -                new QName(definition.getTargetNamespace(), "undeploy"),
  -                "",
  -                "wsdd",
  -                JavaUtils.getMessage("genUndeploy00"), "undeploy");
  +    public JavaUndeployWriter(Emitter emitter, Definition definition, SymbolTable 
notUsed) {
  +        super(emitter, "undeploy");
           this.definition = definition;
  -        this.symbolTable = symbolTable;
       } // ctor
   
  +    /**
  +     * Generate undeploy.wsdd.  Only generate it if the emitter
  +     * is generating server-side mappings.
  +     */
       public void generate() throws IOException {
           if (emitter.isServerSide()) {
               super.generate();
  @@ -97,25 +98,43 @@
       } // generate
   
       /**
  +     * Return the fully-qualified name of the undeploy.wsdd file
  +     * to be generated.
  +     */
  +    protected String getFileName() {
  +        String dir = emitter.getNamespaces().getAsDir(
  +                definition.getTargetNamespace());
  +        return dir + "undeploy.wsdd";
  +    } // getFileName
  +
  +    /**
        * Replace the default file header with the deployment doc file header.
        */
  -    protected void writeFileHeader() throws IOException {
  -        initializeDeploymentDoc("undeploy");
  +    protected void writeFileHeader(PrintWriter pw) throws IOException {
  +        pw.println(JavaUtils.getMessage("deploy01"));
  +        pw.println(JavaUtils.getMessage("deploy02"));
  +        pw.println(JavaUtils.getMessage("deploy04"));
  +        pw.println(JavaUtils.getMessage("deploy05"));
  +        pw.println(JavaUtils.getMessage("deploy06"));
  +        pw.println(JavaUtils.getMessage("deploy08"));
  +        pw.println(JavaUtils.getMessage("deploy09"));
  +        pw.println();
  +        pw.println("<undeployment");
  +        pw.println("    xmlns=\"" + WSDDConstants.URI_WSDD +"\">");
       } // writeFileHeader
   
       /**
  -     * Write the body of the deploy.xml file.
  +     * Write the body of the deploy.wsdd file.
        */
  -    protected void writeFileBody() throws IOException {
  -        writeDeployServices();
  +    protected void writeFileBody(PrintWriter pw) throws IOException {
  +        writeDeployServices(pw);
           pw.println("</undeployment>");
  -        pw.close();
       } // writeFileBody
   
       /**
        * Write out deployment and undeployment instructions for each WSDL service
        */
  -    private void writeDeployServices() throws IOException {
  +    private void writeDeployServices(PrintWriter pw) throws IOException {
           //deploy the ports on each service
           Map serviceMap = definition.getServices();
           for (Iterator mapIterator = serviceMap.values().iterator(); 
mapIterator.hasNext();) {
  @@ -128,7 +147,7 @@
   
               for (Iterator portIterator = myService.getPorts().values().iterator(); 
portIterator.hasNext();) {
                   Port myPort = (Port) portIterator.next();
  -                writeDeployPort(myPort);
  +                writeDeployPort(pw, myPort);
               }
           }
       } //writeDeployServices
  @@ -136,7 +155,7 @@
       /**
        * Write out deployment and undeployment instructions for given WSDL port
        */
  -    private void writeDeployPort(Port port) throws IOException {
  +    private void writeDeployPort(PrintWriter pw, Port port) throws IOException {
           String serviceName = port.getName();
   
           pw.println("  <service name=\"" + serviceName + "\"/>");
  
  
  
  1.16      +123 -163  xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaWriter.java
  
  Index: JavaWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaWriter.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JavaWriter.java   31 May 2002 19:08:10 -0000      1.15
  +++ JavaWriter.java   7 Jun 2002 12:45:08 -0000       1.16
  @@ -59,24 +59,14 @@
   import java.io.IOException;
   import java.io.PrintWriter;
   
  -import javax.wsdl.QName;
  -
   import org.apache.axis.utils.JavaUtils;
  -import org.apache.axis.deployment.wsdd.WSDDConstants;
   
   import org.apache.axis.wsdl.gen.Generator;
   
  -import org.apache.axis.wsdl.symbolTable.SymTabEntry;
  -import org.apache.axis.wsdl.symbolTable.TypeEntry;
  -
   import org.w3c.dom.Element;
   import org.w3c.dom.Node;
   
   /**
  -* All of Wsdl2java's Writer implementations do some common stuff.  All this
  -* common stuff resides in this abstract base class.  All that extensions to
  -* this class have to do is implement writeFileBody.
  -*
   * Emitter knows about WSDL writers, one each for PortType, Binding, Service,
   * Definition, Type.  But for some of these WSDL types, Wsdl2java generates
   * multiple files.  Each of these files has a corresponding writer that extends
  @@ -84,139 +74,155 @@
   * etc.) each calls a file writer (JavaStubWriter, JavaSkelWriter, etc.) for
   * each file that that WSDL generates.
   *
  -* For example, when Emitter calls JavaWriterFactory for a Binding Writer, it
  +* <p>For example, when Emitter calls JavaWriterFactory for a Binding Writer, it
   * returns a JavaBindingWriter.  JavaBindingWriter, in turn, contains a
   * JavaStubWriter, JavaSkelWriter, and JavaImplWriter since a Binding may cause
   * a stub, skeleton, and impl template to be generated.
   *
  -* Note that the writers that are given to Emitter by JavaWriterFactory DO NOT
  +* <p>Note that the writers that are given to Emitter by JavaWriterFactory DO NOT
   * extend JavaWriter.  They simply implement Writer and delegate the actual
   * task of writing to extensions of JavaWriter.
  +*
  +* <p>All of Wsdl2java's Writer implementations follow a common behaviour.
  +* JavaWriter is the abstract base class that dictates this common behaviour.
  +* This behaviour is primarily placed within the generate method.  The generate
  +* method calls, in succession (note:  the starred methods are the ones you are
  +* probably most interested in):
  +* <dl>
  +*   <dt> * getFileName
  +*   <dd> This is an abstract method that must be implemented by the subclass.
  +*        It returns the fully-qualified file name.
  +*   <dt> isFileGenerated(file)
  +*   <dd> You should not need to override this method.  It checks to see whether
  +*        this file is in the List returned by emitter.getGeneratedFileNames.
  +*   <dt> registerFile(file)
  +*   <dd> You should not need to override this method.  It registers this file by
  +*        calling emitter.getGeneratedFileInfo().add(...).
  +*   <dt> * verboseMessage(file)
  +*   <dd> You may override this method if you want to provide more information.
  +*        The generate method only calls verboseMessage if verbose is turned on.
  +*   <dt> getPrintWriter(file)
  +*   <dd> You should not need to override this method.  Given the file name, it
  +*        creates a PrintWriter for it.
  +*   <dt> * writeFileHeader(pw)
  +*   <dd> You may want to override this method.  The default implementation
  +*        generates nothing.
  +*   <dt> * writeFileBody(pw)
  +*   <dd> This is an abstract method that must be implemented by the subclass.
  +*        This is where the body of a file is generated.
  +*   <dt> * writeFileFooter(pw)
  +*   <dd> You may want to override this method.  The default implementation
  +*        generates nothing.
  +*   <dt> closePrintWriter(pw)
  +*   <dd> You should not need to override this method.  It simply closes the
  +*        PrintWriter.
  +* </dl>
   */
  -
   public abstract class JavaWriter implements Generator {
  -    protected Emitter     emitter;
  -    protected QName       qname;
  -    protected Namespaces  namespaces;
  -    protected String      rootName; // No suffix...
  -    protected String      className;
  -    protected String      fileName;
  -    protected String      packageName;
  -    protected PrintWriter pw;
  -    protected String      message;
  -    protected String      type;
  -    protected boolean     embeddedCode = false;
  -
  -    /**
  -     * Constructor.  Use this one to pass in a Type.  Type contains QName and java 
name.
  -     */
  -    protected JavaWriter(
  -            Emitter emitter,
  -            SymTabEntry entry,
  -            String suffix,
  -            String extension,
  -            String message, 
  -            String type) {
  -        this.emitter     = emitter;
  -        this.qname       = entry.getQName();
  -        this.namespaces  = emitter.getNamespaces();
  -        this.rootName    = Utils.getJavaLocalName(entry.getName());
  -        this.className   = rootName + (suffix == null ? "" : suffix);
  -        this.fileName    = className + '.' + extension;
  -        this.packageName = Utils.getJavaPackageName(entry.getName());
  -        this.message     = message;
  -        this.type        = type;
  -    } // ctor
  -
  +    protected Emitter emitter;
  +    protected String  type;
   
       /**
  -     * Constructor.  Use Set up all the variables needed to write a file.
  +     * Constructor.
        */
  -    protected JavaWriter(
  -            Emitter emitter,
  -            QName qname,
  -            String suffix,
  -            String extension,
  -            String message, 
  -            String type) {
  -        this.emitter     = emitter;
  -        this.qname       = qname;
  -        this.namespaces  = emitter.getNamespaces();
  -        this.className   = qname.getLocalPart() + (suffix == null ? "" : suffix);
  -        this.fileName    = className + '.' + extension;
  -        this.packageName = namespaces.getCreate(qname.getNamespaceURI());
  -        this.message     = message;
  -        this.type        = type;
  +    protected JavaWriter(Emitter emitter, String type) {
  +        this.emitter = emitter;
  +        this.type    = type;
       } // ctor
   
       /**
  -     * Generate into an existing class with PrinterWriter pw
  -     */
  -    public void generate(PrintWriter pw) throws IOException {
  -        embeddedCode = true;  // Indicated embedded
  -        String packageDirName = namespaces.toDir(packageName);
  -        String path = packageDirName + fileName;
  -        String fqClass = packageName + "." + className;
  -        
  -        // Check for duplicates, probably the result of namespace mapping
  -        if (emitter.getGeneratedClassNames().contains(fqClass)) {
  -            throw new IOException(JavaUtils.getMessage("duplicateClass00", 
fqClass));
  -        }
  -        if (emitter.getGeneratedFileNames().contains(path)) {
  -            throw new IOException(JavaUtils.getMessage("duplicateFile00", path));
  -        }
  -        
  -        emitter.getGeneratedFileInfo().add(path, fqClass, type);
  -        this.pw = pw;
  -        writeFileBody();
  -    }
  -
  -    /**
  -     * Create the file, write the header, write the body.
  +     * Generate a file.
        */
       public void generate() throws IOException {
  -        String packageDirName = namespaces.toDir(packageName);
  -        String path = packageDirName + fileName;
  -        String fqClass = packageName + "." + className;
  -
  -        // Check for duplicates, probably the result of namespace mapping
  -        if (emitter.getGeneratedClassNames().contains(fqClass)) {
  -            throw new IOException(JavaUtils.getMessage("duplicateClass00", 
fqClass));
  -        }
  -        if (emitter.getGeneratedFileNames().contains(path)) {
  -            throw new IOException(JavaUtils.getMessage("duplicateFile00", path));
  +        String file = getFileName();
  +        if (isFileGenerated(file)) {
  +            throw new IOException(JavaUtils.getMessage("duplicateFile00", file));
           }
  -        
  -        emitter.getGeneratedFileInfo().add(path, fqClass, type);
  -        namespaces.mkdir(packageName);
  -        File file = new File(packageDirName, fileName);
  +        registerFile(file);
           if (emitter.isVerbose()) {
  -            System.out.println(message + ":  " + file.getPath());
  +            System.out.println(verboseMessage(file));
           }
  -        pw = new PrintWriter(new FileWriter(file));
  -        writeFileHeader();
  -        writeFileBody();
  +        PrintWriter pw = getPrintWriter(file);
  +        writeFileHeader(pw);
  +        writeFileBody(pw);
  +        writeFileFooter(pw);
  +        closePrintWriter(pw);
       } // generate
   
       /**
  -     * Write a common header, including the package name.
  +     * This method must be implemented by a subclass.  It
  +     * returns the fully-qualified name of the file to be
  +     * generated.
        */
  -    protected void writeFileHeader() throws IOException {
  -        pw.println("/**");
  -        pw.println(" * " + fileName);
  -        pw.println(" *");
  -        pw.println(" * " + JavaUtils.getMessage("wsdlGenLine00"));
  -        pw.println(" * " + JavaUtils.getMessage("wsdlGenLine01"));
  -        pw.println(" */");
  -        pw.println();
  -
  -        // print package declaration
  -        pw.println("package " + packageName + ";");
  -        pw.println();
  +    protected abstract String getFileName();
  +
  +    /**
  +     * You should not need to override this method. It checks
  +     * to see whether the given file is in the List returned
  +     * by emitter.getGeneratedFileNames.
  +     */
  +    protected boolean isFileGenerated(String file) {
  +        return emitter.getGeneratedFileNames().contains(file);
  +    } // isFileGenerated
  +
  +    /**
  +     * You should not need to override this method.
  +     * It registers the given file by calling
  +     * emitter.getGeneratedFileInfo().add(...).
  +     */
  +    protected void registerFile(String file) {
  +        emitter.getGeneratedFileInfo().add(file, null, type);
  +    } // registerFile
  +
  +    /**
  +     * Return the string:  "Generating <file>".  Override this
  +     * method if you want to provide more information.
  +     */
  +    protected String verboseMessage(String file) {
  +        return JavaUtils.getMessage("generating", file);
  +    } // verboseMessage
  +
  +    /**
  +     * You should not need to override this method.
  +     * Given the file name, it creates a PrintWriter for it.
  +     */
  +    protected PrintWriter getPrintWriter(String filename) throws IOException {
  +        File file = new File(filename);
  +        File parent = new File(file.getParent());
  +        parent.mkdirs();
  +        return new PrintWriter(new FileWriter(file));
  +    } // getPrintWriter
  +
  +    /**
  +     * This method is intended to be overridden as necessary
  +     * to generate file header information.  This default
  +     * implementation does nothing.
  +     */
  +    protected void writeFileHeader(PrintWriter pw) throws IOException {
       } // writeFileHeader
   
       /**
  -     * output documentation element as a Java comment.
  +     * This method must be implemented by a subclass.  This
  +     * is where the body of a file is generated.
  +     */
  +    protected abstract void writeFileBody(PrintWriter pw) throws IOException;
  +
  +    /**
  +     * You may want to override this method.  This default
  +     * implementation generates nothing.
  +     */
  +    protected void writeFileFooter(PrintWriter pw) throws IOException {
  +    } // writeFileFooter
  +
  +    /**
  +     * Close the print writer.
  +     */
  +    protected void closePrintWriter(PrintWriter pw) {
  +        pw.close();
  +    } // closePrintWriter
  +
  +    /**
  +     * Output a documentation element as a Java comment.
        */
       protected void writeComment(PrintWriter pw, Element element) {
           // This controls how many characters per line
  @@ -259,51 +265,5 @@
               pw.println("     */");
           }
       } // writeComment
  -
  -    /**
  -     * Initialize the deployment document, spit out preamble comments
  -     * and opening tag.
  -     */
  -    protected void initializeDeploymentDoc(String deploymentOpName) throws 
IOException {
  -        if ("deploy".equals(deploymentOpName)) {
  -            pw.println(JavaUtils.getMessage("deploy00"));
  -        }
  -        else {
  -            pw.println(JavaUtils.getMessage("deploy01"));
  -        }
  -        pw.println(JavaUtils.getMessage("deploy02"));
  -        if ("deploy".equals(deploymentOpName)) {
  -            pw.println(JavaUtils.getMessage("deploy03"));
  -        }
  -        else {
  -            pw.println(JavaUtils.getMessage("deploy04"));
  -        }
  -        pw.println(JavaUtils.getMessage("deploy05"));
  -        pw.println(JavaUtils.getMessage("deploy06"));
  -        if ("deploy".equals(deploymentOpName)) {
  -            pw.println(JavaUtils.getMessage("deploy07"));
  -        }
  -        else {
  -            pw.println(JavaUtils.getMessage("deploy08"));
  -        }
  -        pw.println(JavaUtils.getMessage("deploy09"));
  -        pw.println();
  -        if ("deploy".equals(deploymentOpName)) {
  -            pw.println("<deployment");
  -            pw.println("    xmlns=\"" + WSDDConstants.URI_WSDD +"\"");
  -            pw.println("    xmlns:" + WSDDConstants.NS_PREFIX_WSDD_JAVA + "=\"" +
  -                       WSDDConstants.URI_WSDD_JAVA +"\">");
  -        }
  -        else {
  -            pw.println("<undeployment");
  -            pw.println("    xmlns=\"" + WSDDConstants.URI_WSDD +"\">");
  -        }
  -    } // initializeDeploymentDoc
  -
  -    /**
  -     * Write the body of the file.  This is what extenders of this class must
  -     * implement
  -     */
  -    protected abstract void writeFileBody() throws IOException;
   
   } // abstract class JavaWriter
  
  
  
  1.1                  
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaClassWriter.java
  
  Index: JavaClassWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.axis.wsdl.toJava;
  
  import java.io.File;
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import javax.wsdl.QName;
  
  import org.apache.axis.utils.JavaUtils;
  
  import org.apache.axis.wsdl.symbolTable.SymTabEntry;
  
  /**
  * Emitter knows about WSDL writers, one each for PortType, Binding, Service,
  * Definition, Type.  But for some of these WSDL types, Wsdl2java generates
  * multiple files.  Each of these files has a corresponding writer that extends
  * JavaWriter.  So the Java WSDL writers (JavaPortTypeWriter, JavaBindingWriter,
  * etc.) each calls a file writer (JavaStubWriter, JavaSkelWriter, etc.) for
  * each file that that WSDL generates.
  *
  * <p>For example, when Emitter calls JavaWriterFactory for a Binding Writer, it
  * returns a JavaBindingWriter.  JavaBindingWriter, in turn, contains a
  * JavaStubWriter, JavaSkelWriter, and JavaImplWriter since a Binding may cause
  * a stub, skeleton, and impl template to be generated.
  *
  * <p>Note that the writers that are given to Emitter by JavaWriterFactory DO NOT
  * extend JavaWriter.  They simply implement Writer and delegate the actual
  * task of writing to extensions of JavaWriter.
  *
  * <p>All of Wsdl2java's Writer implementations follow a common behaviour.
  * JavaWriter is the abstract base class that dictates this common behaviour.
  * Many of the files generated are .java files, so this abstract class -
  * JavaClassWriter - exists.  It extends JavaWriter and adds a bit of Java-
  * relative behaviour.  This behaviour is primarily placed within the generate
  * method.  The generate method calls, in succession (note:  the starred methods
  * are the ones you are probably most interested in):
  * <dl>
  *   <dt> getFileName
  *   <dd> This method is abstract in JavaWriter, but JavaClassWriter implements
  *        this method.  Subclasses should have no need to override it.  It
  *        returns the fully-qualified file name based on the fully-qualified
  *        classname + ".java".
  *   <dt> isFileGenerated(file)
  *   <dd> You should not need to override this method.  It checks to see whether
  *        this file is in the List returned by emitter.getGeneratedFileNames.
  *   <dt> registerFile(file)
  *   <dd> You should not need to override this method.  It registers this file by
  *        calling emitter.getGeneratedFileInfo().add(...).
  *   <dt> * verboseMessage(file)
  *   <dd> You may override this method if you want to provide more information.
  *        The generate method only calls verboseMessage if verbose is turned on.
  *   <dt> getPrintWriter(file)
  *   <dd> You should not need to override this method.  Given the file name, it
  *        creates a PrintWriter for it.
  *   <dt> writeFileHeader(pw)
  *   <dd> JavaClassWriter implements this method, so you should not need to
  *        override it.  This method generates a javadoc giving the filename and
  *        a comment stating that this file is generated by WSDL2Java, and it
  *        generates the class definition including the opening curly brace..
  *   <dt> * writeFileBody(pw)
  *   <dd> This is an abstract method that must be implemented by the subclass.
  *        This is where the body of a file is generated.
  *   <dt> * writeFileFooter(pw)
  *   <dd> JavaClassWriter implements this method, so you should not need to
  *        override it.  It generates the closing curly brace for the class.
  *   <dt> closePrintWriter(pw)
  *   <dd> You should not need to override this method.  It simply closes the
  *        PrintWriter.
  * </dl>
  *
  * Additional behaviour that JavaClassWriter introduces beyond JavaWriter is
  * related to the class header and definition:
  * <dl>
  *   <dt> writeHeaderComments
  *   <dd> Write the header comments, such as the file name and that the file was
  *        generated by WSDL2Java.  You need not override this method unless you
  *        want a tailored comment.
  *   <dt> writePackage
  *   <dd> Write the package statement, if necessary.  You should not need to
  *        override this method.
  *   <dt> getClassModifiers
  *   <dd> Modifiers, such as "public", "final", "abstract" would be returned by
  *        this method.  The default implementation only generates "public ", so
  *        any subclass that needs more must override this method.
  *   <dt> getClassText
  *   <dd> This simply returns "class ".  If anything else is desired, for
  *        instance, JavaInterfaceWriter prefers "interface ", then this method
  *        must be overridden.
  *   <dt> getExtendsText
  *   <dd> The default implementation returns "".  If a subclass desires to list
  *        a set of classes this one extends, then this method must be overridden.
  *   <dt> getImplementsText
  *   <dd> Same as getExtendsText except for the implements clause.
  * </dl>
  */
  public abstract class JavaClassWriter extends JavaWriter {
      protected Namespaces namespaces;
      protected String     className;
      protected String     packageName;
  
      /**
       * Constructor.
       * @param emitter The emitter instance
       * @param fulClassName The fully qualified class name of the class
       *        to be generated.
       */
      protected JavaClassWriter(
              Emitter emitter,
              String fullClassName,
              String type) {
          super(emitter, type);
          this.namespaces = emitter.getNamespaces();
          this.packageName = Utils.getJavaPackageName(fullClassName);
          this.className = Utils.getJavaLocalName(fullClassName);
      } // ctor
  
      /**
       * Return the file name as a string of the form:
       * "<directory-ized fully-qualified classname>.java"
       */
      protected String getFileName() {
          return namespaces.toDir(packageName) + className + ".java";
      } // getFileName
  
      /**
       * You should not need to override this method.
       * It registers the given file by calling
       * emitter.getGeneratedFileInfo().add(...).
       * JavaClassWriter overrides this method from JavaWriter because
       * it add class name to the registration information.
       */
      protected void registerFile(String file) {
          String fqClass = getPackage() + '.' + getClassName();
          emitter.getGeneratedFileInfo().add(file, fqClass, type);
      } // registerFile
  
      /**
       * Write a common header, including the package name, the class
       * declaration, and the opening curly brace.
       */
      protected void writeFileHeader(PrintWriter pw) throws IOException {
          writeHeaderComments(pw);
          writePackage(pw);
  
          // print class declaration
          pw.println(getClassModifiers() + getClassText() + getClassName() + ' ' + 
getExtendsText() + getImplementsText() + "{");
      } // writeFileHeader
  
      /**
       * Write the header comments.
       */
      protected void writeHeaderComments(PrintWriter pw) throws IOException {
          String localFile = getFileName();
          int lastSepChar = localFile.lastIndexOf(File.separatorChar);
          if (lastSepChar >= 0) {
              localFile = localFile.substring(lastSepChar + 1);
          }
          pw.println("/**");
          pw.println(" * " + localFile);
          pw.println(" *");
          pw.println(" * " + JavaUtils.getMessage("wsdlGenLine00"));
          pw.println(" * " + JavaUtils.getMessage("wsdlGenLine01"));
          pw.println(" */");
          pw.println();
      } // writeHeaderComments
  
      /**
       * Write the package declaration statement.
       */
      protected void writePackage(PrintWriter pw) throws IOException {
          if (getPackage() != null) {
              pw.println("package " + getPackage() + ";");
              pw.println();
          }
  
      } // writePackage
  
      /**
       * Return "public ".  If more modifiers are needed, this method must be
       * overridden.
       */
      protected String getClassModifiers() {
          return "public ";
      } // getClassModifiers
  
      /**
       * Return "class ".  If "interface " is needed instead, this method must be
       * overridden.
       */
      protected String getClassText() {
          return "class ";
      } // getClassString
  
      /**
       * Returns the appropriate extends clause.  This default implementation
       * simply returns "", but if you want "extends <class/interface list> "
       * then you must override this method.
       * @return ""
       */
      protected String getExtendsText() {
          return "";
      } // getExtendsText
  
      /**
       * Returns the appropriate implements clause.  This default implementation
       * simply returns "", but if you want "implements <interface list> " then
       * you must override this method.
       * @return ""
       */
      protected String getImplementsText() {
          return "";
      } // getImplementsText
  
      /**
       * Returns the package name.
       */
      protected String getPackage() {
          return packageName;
      } // getPackage
  
      /**
       * Returns the class name.
       */
      protected String getClassName() {
          return className;
      } // getClassName
  
      /**
       * Generate the closing curly brace.
       */
      protected void writeFileFooter(PrintWriter pw) throws IOException {
          super.writeFileFooter(pw);
          pw.println('}');
      } // writeFileFooter
  
  } // abstract class JavaClassWriter
  
  
  


Reply via email to