You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2005/12/20 15:08:03 UTC

svn commit: r357991 - in /webservices/axis2/trunk/java/modules/codegen: other/ src/org/apache/axis2/schema/ src/org/apache/axis2/schema/template/ src/org/apache/axis2/schema/typemap/ src/org/apache/axis2/schema/util/ src/org/apache/axis2/schema/writer/...

Author: ajith
Date: Tue Dec 20 06:07:34 2005
New Revision: 357991

URL: http://svn.apache.org/viewcvs?rev=357991&view=rev
Log:
1. Refactored the Extensions to have proper protected methods
2. Added support to generate the databinding classes in wrapped mode (one file)
  I . Updated the options
  II. Updated the beanWriter (both the interface and the impl)
  III. slightly modified the Schema compiler
  IV. Updated the templates
3. Fixed a bug in the schema compiler to solve the Jira issue AXIS2-343

Modified:
    webservices/axis2/trunk/java/modules/codegen/other/beanGenerationSchema.xsd
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/XSD2Java.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/schema-compile.properties
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/PlainBeanTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/typemap/JavaTypeMap.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/ConverterUtil.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/SchemaPropertyLoader.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/BeanWriter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTUtils.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java

Modified: webservices/axis2/trunk/java/modules/codegen/other/beanGenerationSchema.xsd
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/other/beanGenerationSchema.xsd?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/other/beanGenerationSchema.xsd (original)
+++ webservices/axis2/trunk/java/modules/codegen/other/beanGenerationSchema.xsd Tue Dec 20 06:07:34 2005
@@ -1,9 +1,30 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- edited with XMLSpy v2005 rel. 3 U (http://www.altova.com) by Ajith Harshana Ranabahu (WSO2/Development) -->
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
-	<xs:element name="bean">
+
+     <xs:element name="beans">
 		<xs:annotation>
-			<xs:documentation>This schema represents the XML docuement structure java bean writer generates</xs:documentation>
+			<xs:documentation>
+                This element represents the XML docuement structure java bean writer generates for
+                a multiple classes
+            </xs:documentation>
+		</xs:annotation>
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="bean" maxOccurs="unbounded"/>
+			</xs:sequence>
+            <xs:attribute name="name" type="xs:string" use="required"/>
+			<xs:attribute name="originalName" type="xs:string" use="required"/>
+			<xs:attribute name="package" type="xs:string" use="required"/>
+       </xs:complexType>
+	</xs:element>
+
+    <xs:element name="bean">
+		<xs:annotation>
+			<xs:documentation>
+                This element represents the XML docuement structure java bean writer generates for
+                a single class
+            </xs:documentation>
 		</xs:annotation>
 		<xs:complexType>
 			<xs:sequence>
@@ -17,6 +38,7 @@
 			<xs:attribute name="type" type="xs:string" use="optional" fixed="yes"/>
 			<xs:attribute name="extension" type="xs:string" use="optional"/>
 			<xs:attribute name="anon" type="xs:string" use="optional" fixed="yes"/>
+			<xs:attribute name="unwrapped" type="xs:string" use="optional" fixed="yes"/>
 		</xs:complexType>
 	</xs:element>
 	<xs:complexType name="propertyType">

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java Tue Dec 20 06:07:34 2005
@@ -1,11 +1,7 @@
 package org.apache.axis2.schema;
 
 import javax.xml.namespace.QName;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/CompilerOptions.java Tue Dec 20 06:07:34 2005
@@ -30,8 +30,37 @@
     /**
      * Generated output file
      */
-    File outputLocation;
-    String packageName=null;
+    private File outputLocation;
+    private String packageName=null;
+
+    /**
+     * This flag tells the databinder to either write the output or
+     * not. if this is set to true it will write the output at once.
+     * if not  ???
+     */
+    private boolean writeOutput = false;
+
+    /**
+     * This flag determines whether the generated classes are wrapped or not
+     * if the wrapper flag is true, then only a single file will be generated
+     */
+    private boolean wrapClasses = false;
+
+    public boolean isWriteOutput() {
+        return writeOutput;
+    }
+
+    public void setWriteOutput(boolean writeOutput) {
+        this.writeOutput = writeOutput;
+    }
+
+    public boolean isWrapClasses() {
+        return wrapClasses;
+    }
+
+    public void setWrapClasses(boolean wrapClasses) {
+        this.wrapClasses = wrapClasses;
+    }
 
     public String getPackageName() {
         return packageName;

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java Tue Dec 20 06:07:34 2005
@@ -3,36 +3,10 @@
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.schema.util.SchemaPropertyLoader;
 import org.apache.axis2.schema.writer.BeanWriter;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaAll;
-import org.apache.ws.commons.schema.XmlSchemaAny;
-import org.apache.ws.commons.schema.XmlSchemaAnyAttribute;
-import org.apache.ws.commons.schema.XmlSchemaAttribute;
-import org.apache.ws.commons.schema.XmlSchemaChoice;
-import org.apache.ws.commons.schema.XmlSchemaComplexContent;
-import org.apache.ws.commons.schema.XmlSchemaComplexContentExtension;
-import org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction;
-import org.apache.ws.commons.schema.XmlSchemaComplexType;
-import org.apache.ws.commons.schema.XmlSchemaContent;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaImport;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
-import org.apache.ws.commons.schema.XmlSchemaObjectTable;
-import org.apache.ws.commons.schema.XmlSchemaParticle;
-import org.apache.ws.commons.schema.XmlSchemaSequence;
-import org.apache.ws.commons.schema.XmlSchemaSimpleType;
-import org.apache.ws.commons.schema.XmlSchemaSimpleTypeContent;
-import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
-import org.apache.ws.commons.schema.XmlSchemaType;
+import org.apache.ws.commons.schema.*;
 
 import javax.xml.namespace.QName;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *
@@ -54,6 +28,7 @@
  */
 public class SchemaCompiler {
 
+
     private CompilerOptions options;
     private HashMap processedTypemap;
 
@@ -83,31 +58,29 @@
      * @param options
      */
     public SchemaCompiler(CompilerOptions options) throws SchemaCompilationException {
-        try {
-            if (options==null){
-                //create an empty options object
-                this.options = new CompilerOptions();
-            }else{
-                this.options = options;
-            }
 
-            this.processedTypemap = new HashMap();
-            this.processedElementMap = new HashMap();
-            this.simpleTypesMap = new HashMap();
-            this.processedElementList = new ArrayList();
-            this.processedAnonymousComplexTypesMap = new HashMap();
-            this.changedTypeMap = new HashMap();
-
-            //load the writer
-            this.writer = SchemaPropertyLoader.getBeanWriterInstance();
-            this.writer.init(this.options);
+        if (options==null){
+            //create an empty options object
+            this.options = new CompilerOptions();
+        }else{
+            this.options = options;
+        }
+
+        this.processedTypemap = new HashMap();
+        this.processedElementMap = new HashMap();
+        this.simpleTypesMap = new HashMap();
+        this.processedElementList = new ArrayList();
+        this.processedAnonymousComplexTypesMap = new HashMap();
+        this.changedTypeMap = new HashMap();
+
+        //load the writer a nd initiliaze the base type
+        this.writer = SchemaPropertyLoader.getBeanWriterInstance();
+        this.writer.init(this.options);
+
+        //load the base types
+        baseSchemaTypeMap =SchemaPropertyLoader.getTypeMapperInstance().getTypeMap();
 
-            //laod the base types
-            baseSchemaTypeMap =SchemaPropertyLoader.getTypeMapperInstance().getTypeMap();
 
-        } catch (IOException e) {
-            throw new SchemaCompilationException(e);
-        }
     }
 
     /**
@@ -164,21 +137,31 @@
             processElement((XmlSchemaElement)xmlSchemaElement1Iterator.next(),true);
         }
 
-        //Now re-iterate through the elements and write them
+
         Iterator xmlSchemaElement2Iterator = elements.getValues();
+
+        // re-iterate through the elements and write them one by one
+        // if the mode is unwrap this process will not really write the
+        // classes but will accumilate the models for a final single shot
+        // write
         while (xmlSchemaElement2Iterator.hasNext()) {
             //this is the set of outer elements so we need to generate classes
             writeElement((XmlSchemaElement)xmlSchemaElement2Iterator.next());
         }
 
+        if (options.isWrapClasses()){
+            writer.writeBatch();
+        }
     }
 
+
     /**
      *  Writes the element
      * @param xsElt
      * @throws SchemaCompilationException
      */
     private void writeElement(XmlSchemaElement xsElt) throws SchemaCompilationException{
+
         if (this.processedElementMap.containsKey(xsElt.getQName())){
             return;
         }
@@ -195,12 +178,12 @@
                 //this means the schema type actually returns a different QName
                 if (changedTypeMap.containsKey(qName)){
                     metainf.registerMapping(xsElt.getQName(),
-                        (QName)changedTypeMap.get(qName),
-                        className);
+                            (QName)changedTypeMap.get(qName),
+                            className);
                 }else{
-                     metainf.registerMapping(xsElt.getQName(),
-                        qName,
-                        className);
+                    metainf.registerMapping(xsElt.getQName(),
+                            qName,
+                            className);
                 }
 
 
@@ -212,6 +195,8 @@
                 metainf = (BeanWriterMetaInfoHolder)this.processedAnonymousComplexTypesMap.get(xsElt);
                 metainf.setAnonymous(true);
             }
+
+
             String writtenClassName = writer.write(xsElt,processedTypemap,metainf);
             processedElementMap.put(xsElt.getQName(),writtenClassName);
         }
@@ -241,7 +226,7 @@
         //The processing element logic seems to be quite simple. Look at the relevant schema type
         //for each and every element and process that accordingly.
         //this means that any unused type definitions would not be generated!
-        if (processedElementList.contains(xsElt.getQName())){
+        if (isOuter && processedElementList.contains(xsElt.getQName())){
             return;
         }
 
@@ -257,7 +242,7 @@
         //There can be instances where the SchemaType is null but the schemaTypeName is not
         //this specifically happens with xsd:anyType.
         if (!isOuter){
-            String className = findClassName(xsElt.getSchemaTypeName(),isArray);
+            String className = findClassName(xsElt.getSchemaTypeName(),isArray(xsElt));
             this.processedElementMap.put(xsElt.getQName(),className);
         }
         this.processedElementList.add(xsElt.getQName());
@@ -270,6 +255,7 @@
      * @return
      */
     private String findClassName(QName qName,boolean isArray) {
+
         //find the class name
         String className;
         if (processedTypemap.containsKey(qName)) {
@@ -281,6 +267,8 @@
         }else{
             // We seem to have failed in finding a class name for the
             //contained schema type. We better set the default then
+            //however it's better if the default can be set through the
+            //property file
             className = OMElement.class.getName();
         }
         if (isArray){
@@ -588,6 +576,7 @@
     private boolean isArray(XmlSchemaParticle particle) throws SchemaCompilationException{
         long minOccurs = particle.getMinOccurs();
         long maxOccurs = particle.getMaxOccurs();
+
         if (maxOccurs < minOccurs){
             throw new SchemaCompilationException();
         }else{

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaConstants.java Tue Dec 20 06:07:34 2005
@@ -83,7 +83,7 @@
     public static final Integer ANY_TYPE = new Integer(1);
     public static final Integer ELEMENT_TYPE = new Integer(2);
     public static final Integer ANY_ATTRIBUTE_TYPE = new Integer(3);
-    public static final Integer ANY_ARRAY_TYPE = new Integer(4); 
+    public static final Integer ANY_ARRAY_TYPE = new Integer(4);
 
+   
 }
-

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/XSD2Java.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/XSD2Java.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/XSD2Java.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/XSD2Java.java Tue Dec 20 06:07:34 2005
@@ -70,8 +70,13 @@
                 outputFolder.mkdirs();
             }
 
-            SchemaCompiler compiler = new SchemaCompiler(new CompilerOptions().setOutputLocation(
-                    outputFolder));
+            CompilerOptions compilerOptions = new CompilerOptions();
+            compilerOptions.setOutputLocation(outputFolder);
+            //##############################
+             compilerOptions.setWrapClasses(true);
+            //##############################
+
+            SchemaCompiler compiler = new SchemaCompiler(compilerOptions);
             compiler.compile(currentSchema);
 
         } catch (Exception e) {

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/schema-compile.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/schema-compile.properties?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/schema-compile.properties (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/schema-compile.properties Tue Dec 20 06:07:34 2005
@@ -1,18 +1,24 @@
 ###############################################################################
 ##########################Schema Compiler properties   ########################
 ###############################################################################
+#
 # The bean writer class
 # The bean writer is the class used by the schema compiler to write the beans
 # and should implement the org.apache.axis2.schema.writer.BeanWriter
 # inteface
+#
 schema.bean.writer.class=org.apache.axis2.schema.writer.JavaBeanWriter
 #
 # bean writer template
 # The bean writers template is it's own responsibilty. (A bean writer provider
 # may choose not to use a template at all!) However the property loader will
-# load the followiing template (reference) and provide it and in the case when the
+# load the following templates (reference) and provide it and in the case when the
 # bean writer is not statically bound to a template, this'll be useful.
-schema.bean.writer.template=/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
-#schema.bean.writer.template=/org/apache/axis2/schema/template/PlainBeanTemplate.xsl
+#
+schema.bean.writer.template.wrapped=/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
+# schema.bean.writer.template=/org/apache/axis2/schema/template/PlainBeanTemplate.xsl
+
+#
 # The type map to be used by the schema compiler
-schema.bean.typemap=org.apache.axis2.schema.typemap.JavaTypeMap
\ No newline at end of file
+#
+schema.bean.typemap=org.apache.axis2.schema.typemap.JavaTypeMap

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Tue Dec 20 06:07:34 2005
@@ -1,20 +1,52 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
-    <xsl:template match="/bean">
+
+    <!-- cater for the multiple classes - wrappped mode -->
+    <xsl:template match="/beans">
+        <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
         /**
-         * <xsl:value-of select="@name"/>.java
-         *
-         * This file was auto-generated from WSDL
-         * by the Apache Axis2 version: #axisVersion# #today#
-         */
+        * <xsl:value-of select="$name"/>.java
+        *
+        * This file was auto-generated from WSDL
+        * by the Apache Axis2 version: #axisVersion# #today#
+        */
+
         package <xsl:value-of select="@package"/>;
-        <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
 
         /**
-         *  <xsl:value-of select="$name"/> bean class 
-         */
+        *  <xsl:value-of select="$name"/> wrapped bean classes
+        */
+        public class <xsl:value-of select="$name"/>{
+
+        <xsl:apply-templates/>
+
+        }
+    </xsl:template>
+
+    <!--cater for the multiple classes - unwrappped mode -->
+    <xsl:template match="/">
+        <xsl:apply-templates/>
+    </xsl:template>
+
+    <!-- this is the common template -->
+    <xsl:template match="bean">
+        <!-- write the class header. this should be done only when unwrapped -->
+        <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
 
-        public class <xsl:value-of select="$name"/> <xsl:if test="@extension"> extends <xsl:value-of select="@extension"/></xsl:if>
+        <xsl:if test="@unwrapped">
+            /**
+            * <xsl:value-of select="$name"/>.java
+            *
+            * This file was auto-generated from WSDL
+            * by the Apache Axis2 version: #axisVersion# #today#
+            */
+
+            package <xsl:value-of select="@package"/>;
+            /**
+            *  <xsl:value-of select="$name"/> bean class
+            */
+        </xsl:if>
+        public <xsl:if test="not(@unwrapped)">static</xsl:if> class <xsl:value-of select="$name"/> <xsl:if test="@extension"> extends <xsl:value-of select="@extension"/></xsl:if>
         implements org.apache.axis2.databinding.ADBBean{
         <xsl:choose>
             <xsl:when test="@type">/* This type was generated from the piece of schema that had
@@ -60,91 +92,91 @@
             */
             public void set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$propertyType"/> param){
             <!--Add the validation code. For now we only add the validation code for arrays-->
-             <xsl:if test="@array">
-                 <xsl:if test="not(@unbound)">
-                     if (param.length &gt; <xsl:value-of select="@maxOccurs"></xsl:value-of>){
-                        throw new java.lang.RuntimeException();
-                     }
-                 </xsl:if>
-                 <xsl:if test="@minOccurs">
-                     if (param.length &lt; <xsl:value-of select="@minOccurs"></xsl:value-of>){
-                        throw new java.lang.RuntimeException();
-                     }
-                 </xsl:if>
-             </xsl:if>
+            <xsl:if test="@array">
+                <xsl:if test="not(@unbound)">
+                    if (param.length &gt; <xsl:value-of select="@maxOccurs"></xsl:value-of>){
+                    throw new java.lang.RuntimeException();
+                    }
+                </xsl:if>
+                <xsl:if test="@minOccurs">
+                    if (param.length &lt; <xsl:value-of select="@minOccurs"></xsl:value-of>){
+                    throw new java.lang.RuntimeException();
+                    }
+                </xsl:if>
+            </xsl:if>
             this.<xsl:value-of select="$varName"/>=param;
             }
         </xsl:for-each>
 
         /**
         * databinding method to get an XML representation of this object
-        * Note - this is not complete
+        *
         */
         public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName){
         <xsl:choose>
             <xsl:when test="@type|@anon">
-                  Object[] elementList = new Object[]{
-        <xsl:for-each select="property[not(@attribute)]">
-            <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
-            <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
-
-            <xsl:if test="position()>1">,</xsl:if>
-            <xsl:choose>
-                <xsl:when test="@ours">
+                Object[] elementList = new Object[]{
+                <xsl:for-each select="property[not(@attribute)]">
+                    <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+                    <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
+
+                    <xsl:if test="position()>1">,</xsl:if>
+                    <xsl:choose>
+                        <xsl:when test="@ours">
                             new javax.xml.namespace.QName("<xsl:value-of select="$propertyName"/>"),<xsl:value-of select="$varName"/>
-                </xsl:when>
-                <xsl:when test="@any">
+                        </xsl:when>
+                        <xsl:when test="@any">
                             new javax.xml.namespace.QName("<xsl:value-of select="$propertyName"/>"),<xsl:value-of select="$varName"/>
-                </xsl:when>
-                <xsl:when test="@array">
+                        </xsl:when>
+                        <xsl:when test="@array">
                             "<xsl:value-of select="$propertyName"/>",<xsl:value-of select="$varName"/>
-                </xsl:when>
-                <xsl:otherwise>
+                        </xsl:when>
+                        <xsl:otherwise>
                             "<xsl:value-of select="$propertyName"/>",org.apache.axis2.schema.util.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
-                </xsl:otherwise>
-            </xsl:choose>
-            </xsl:for-each>};
+                        </xsl:otherwise>
+                    </xsl:choose>
+                </xsl:for-each>};
 
-        Object[] attribList = new Object[]{
-        <xsl:for-each select="property[@attribute]">
-            <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
-            <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
-              <xsl:if test="position()>1">,</xsl:if>
-               <xsl:choose>
-                   <xsl:when test="@anyAtt">
-                       null,<xsl:value-of select="$varName"/>
-                   </xsl:when>
-                   <xsl:otherwise>
-                      new javax.xml.namespace.QName("<xsl:value-of select="$propertyName"/>"),org.apache.axis2.schema.util.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
-                   </xsl:otherwise>
-               </xsl:choose>
-             </xsl:for-each>
-         };
-         return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName, elementList, attribList);
+                Object[] attribList = new Object[]{
+                <xsl:for-each select="property[@attribute]">
+                    <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+                    <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
+                    <xsl:if test="position()>1">,</xsl:if>
+                    <xsl:choose>
+                        <xsl:when test="@anyAtt">
+                            null,<xsl:value-of select="$varName"/>
+                        </xsl:when>
+                        <xsl:otherwise>
+                            new javax.xml.namespace.QName("<xsl:value-of select="$propertyName"/>"),org.apache.axis2.schema.util.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
+                        </xsl:otherwise>
+                    </xsl:choose>
+                </xsl:for-each>
+                };
+                return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName, elementList, attribList);
             </xsl:when>
             <xsl:otherwise>
+                <!-- if the element is associated with a type, then its gonna be only one -->
+                //We can safely assume an element has only one type associated with it
+                <!-- This better be only one!!-->
+                <xsl:for-each select="property[@ours]">
+                    <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+                    <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
+                    return <xsl:value-of select="$varName"/>.getPullParser(MY_QNAME);
+                </xsl:for-each>
+
+                <!-- What do we do for the other case ???? -->
+                <xsl:for-each select="property[not(@ours)]">
+                    <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
+                    <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
+                    return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(MY_QNAME,
+                    new Object[]{
+                    org.apache.axis2.databinding.utils.ADBPullParser.ELEMENT_TEXT,
+                    org.apache.axis2.schema.util.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
+                    },
+                    new Object[]{});
 
-            //We can safely assume an element has only one type associated with it
-             <!-- This better be only one!!-->
-            <xsl:for-each select="property[@ours]">
-                <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
-                <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
-           return <xsl:value-of select="$varName"/>.getPullParser(MY_QNAME);
-            </xsl:for-each>
-
-            <!-- What do we do for the other case ???? -->
-             <xsl:for-each select="property[not(@ours)]">
-                <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
-                <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
-            return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(MY_QNAME,
-                  new Object[]{
-                   org.apache.axis2.databinding.utils.ADBPullParser.ELEMENT_TEXT,
-                   org.apache.axis2.schema.util.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>)
-                 },
-                  new Object[]{});
 
-
-            </xsl:for-each>
+                </xsl:for-each>
             </xsl:otherwise>
         </xsl:choose>
 
@@ -157,18 +189,18 @@
         public static <xsl:value-of select="$name"/> parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
         <xsl:value-of select="$name"/> object = new <xsl:value-of select="$name"/>();
         try {
-           int event = reader.getEventType();
-           int count = 0;
-           int argumentCount = <xsl:value-of select="count(property)"/> ;
-           boolean done =false;
-           //event better be a START_ELEMENT. if not we should go up to the start element here
-           while (!reader.isStartElement()){
-              event = reader.next();
-           }
+        int event = reader.getEventType();
+        int count = 0;
+        int argumentCount = <xsl:value-of select="count(property)"/> ;
+        boolean done =false;
+        //event better be a START_ELEMENT. if not we should go up to the start element here
+        while (!reader.isStartElement()){
+        event = reader.next();
+        }
         <!-- First loop creates arrayLists for handling arrays -->
         <xsl:for-each select="property">
             <xsl:if test="@array">
-        java.util.ArrayList list<xsl:value-of select="position()"></xsl:value-of> = new java.util.ArrayList();
+                java.util.ArrayList list<xsl:value-of select="position()"></xsl:value-of> = new java.util.ArrayList();
             </xsl:if>
         </xsl:for-each>
         while(!done){
@@ -186,77 +218,77 @@
             <xsl:choose>
                 <xsl:when test="@array">
                     <xsl:variable name="basePropertyType"><xsl:value-of select="@arrayBaseType"/></xsl:variable>
-                   <xsl:choose>
-                    <xsl:when test="@ours">
-                        <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$basePropertyType"/>.parse(reader));
-                   //loop until we find a start element that is not part of this array
-                   boolean <xsl:value-of select="$loopBoolName"/> = false;
-                   while(!<xsl:value-of select="$loopBoolName"/>){
-                      //loop to the end element
-                      while (!reader.isEndElement()){
+                    <xsl:choose>
+                        <xsl:when test="@ours">
+                            <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$basePropertyType"/>.parse(reader));
+                            //loop until we find a start element that is not part of this array
+                            boolean <xsl:value-of select="$loopBoolName"/> = false;
+                            while(!<xsl:value-of select="$loopBoolName"/>){
+                            //loop to the end element
+                            while (!reader.isEndElement()){
                             event = reader.next();
-                      }
-                      //step one event
-                      event = reader.next();
-                      if (reader.isEndElement()){
-                           //two continuous end elements means we are exiting the xml structure
-                           <xsl:value-of select="$loopBoolName"/> = true;
-                      }else if (reader.isStartElement()){
-                           if ("<xsl:value-of select="$propertyName"/>".equals(reader.getLocalName())){
-                             <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$basePropertyType"/>.parse(reader));
-                           }else{
-                             <xsl:value-of select="$loopBoolName"/> = true;
-                           }
-                      }
-                     }
-
-
-                     // call the converter utility  to convert and set the array
-                      object.set<xsl:value-of select="$javaName"/>(
-                        (<xsl:value-of select="$propertyType"/>)
-                        org.apache.axis2.schema.util.ConverterUtil.convertToArray(
-                         <xsl:value-of select="$basePropertyType"/>.class,
-                         <xsl:value-of select="$listName"/>));
-
-                     count++;
-                       </xsl:when>
-                       <xsl:otherwise>
-                   <xsl:value-of select="$listName"/>.add(reader.getElementText());
-                   //loop until we find a start element that is not part of this array
-                   boolean <xsl:value-of select="$loopBoolName"/> = false;
-                   while(!<xsl:value-of select="$loopBoolName"/>){
-                      //loop to the end element
-                      while (!reader.isEndElement()){
+                            }
+                            //step one event
                             event = reader.next();
-                      }
-                      //step one event
-                      event = reader.next();
-                      if (reader.isEndElement()){
-                           //two continuous end elements means we are exiting the xml structure
-                           <xsl:value-of select="$loopBoolName"/> = true;
-                      }else if (reader.isStartElement()){
-                           if ("<xsl:value-of select="$propertyName"/>".equals(reader.getLocalName())){
-                              <xsl:value-of select="$listName"/>.add(reader.getElementText());
-                           }else{
-                                <xsl:value-of select="$loopBoolName"/> = true;
-                           }
-                      }
-                     }
-
-                   // call the converter utility  to convert and set the array
-                   object.set<xsl:value-of select="$javaName"/>(
-                      (<xsl:value-of select="$propertyType"/>)
-                      org.apache.axis2.schema.util.ConverterUtil.convertToArray(
-                      <xsl:value-of select="$basePropertyType"/>.class,
-                      <xsl:value-of select="$listName"/>));
-                     count++;
-                       </xsl:otherwise>
+                            if (reader.isEndElement()){
+                            //two continuous end elements means we are exiting the xml structure
+                            <xsl:value-of select="$loopBoolName"/> = true;
+                            }else if (reader.isStartElement()){
+                            if ("<xsl:value-of select="$propertyName"/>".equals(reader.getLocalName())){
+                            <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$basePropertyType"/>.parse(reader));
+                            }else{
+                            <xsl:value-of select="$loopBoolName"/> = true;
+                            }
+                            }
+                            }
+
+
+                            // call the converter utility  to convert and set the array
+                            object.set<xsl:value-of select="$javaName"/>(
+                            (<xsl:value-of select="$propertyType"/>)
+                            org.apache.axis2.schema.util.ConverterUtil.convertToArray(
+                            <xsl:value-of select="$basePropertyType"/>.class,
+                            <xsl:value-of select="$listName"/>));
+
+                            count++;
+                        </xsl:when>
+                        <xsl:otherwise>
+                            <xsl:value-of select="$listName"/>.add(reader.getElementText());
+                            //loop until we find a start element that is not part of this array
+                            boolean <xsl:value-of select="$loopBoolName"/> = false;
+                            while(!<xsl:value-of select="$loopBoolName"/>){
+                            //loop to the end element
+                            while (!reader.isEndElement()){
+                            event = reader.next();
+                            }
+                            //step one event
+                            event = reader.next();
+                            if (reader.isEndElement()){
+                            //two continuous end elements means we are exiting the xml structure
+                            <xsl:value-of select="$loopBoolName"/> = true;
+                            }else if (reader.isStartElement()){
+                            if ("<xsl:value-of select="$propertyName"/>".equals(reader.getLocalName())){
+                            <xsl:value-of select="$listName"/>.add(reader.getElementText());
+                            }else{
+                            <xsl:value-of select="$loopBoolName"/> = true;
+                            }
+                            }
+                            }
+
+                            // call the converter utility  to convert and set the array
+                            object.set<xsl:value-of select="$javaName"/>(
+                            (<xsl:value-of select="$propertyType"/>)
+                            org.apache.axis2.schema.util.ConverterUtil.convertToArray(
+                            <xsl:value-of select="$basePropertyType"/>.class,
+                            <xsl:value-of select="$listName"/>));
+                            count++;
+                        </xsl:otherwise>
                     </xsl:choose>
                 </xsl:when>
                 <xsl:when test="@ours">
                     object.set<xsl:value-of select="$javaName"/>(
                     <xsl:value-of select="$propertyType"/>.parse(reader));
-                     count++;
+                    count++;
                 </xsl:when>
                 <xsl:when test="@any">
                     //do nothing yet!!!!
@@ -275,17 +307,17 @@
         }
 
         if (argumentCount==count){
-            done=true;
+        done=true;
         }
 
-         if (!done){
-            event = reader.next();
-         }
+        if (!done){
+        event = reader.next();
+        }
 
         }
 
         } catch (javax.xml.stream.XMLStreamException e) {
-            throw new java.lang.Exception(e);
+        throw new java.lang.Exception(e);
         }
 
         return object;

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/PlainBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/PlainBeanTemplate.xsl?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/PlainBeanTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/PlainBeanTemplate.xsl Tue Dec 20 06:07:34 2005
@@ -1,6 +1,35 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
-    <xsl:template match="/bean">
+
+     <!-- cater for the multiple classes - wrappped mode -->
+    <xsl:template match="/beans">
+        <xsl:variable name="name"><xsl:value-of select="@name"/></xsl:variable>
+        /**
+        * <xsl:value-of select="$name"/>.java
+        *
+        * This file was auto-generated from WSDL
+        * by the Apache Axis2 version: #axisVersion# #today#
+        */
+
+        package <xsl:value-of select="@package"/>;
+
+        /**
+        *  <xsl:value-of select="$name"/> wrapped bean classes
+        */
+        public class <xsl:value-of select="$name"/>{
+
+        <xsl:apply-templates/>
+
+        }
+    </xsl:template>
+
+    <!--cater for the multiple classes - unwrappped mode -->
+    <xsl:template match="/">
+        <xsl:apply-templates/>
+    </xsl:template>
+
+
+    <xsl:template match="bean">
         /**
         * <xsl:value-of select="@name"/>.java
         *

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/typemap/JavaTypeMap.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/typemap/JavaTypeMap.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/typemap/JavaTypeMap.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/typemap/JavaTypeMap.java Tue Dec 20 06:07:34 2005
@@ -2,36 +2,7 @@
 
 import org.apache.axis2.om.OMElement;
 import org.apache.axis2.schema.SchemaConstants;
-import org.apache.axis2.schema.types.Day;
-import org.apache.axis2.schema.types.Duration;
-import org.apache.axis2.schema.types.Entities;
-import org.apache.axis2.schema.types.Entity;
-import org.apache.axis2.schema.types.HexBinary;
-import org.apache.axis2.schema.types.IDRef;
-import org.apache.axis2.schema.types.IDRefs;
-import org.apache.axis2.schema.types.Id;
-import org.apache.axis2.schema.types.Language;
-import org.apache.axis2.schema.types.Month;
-import org.apache.axis2.schema.types.MonthDay;
-import org.apache.axis2.schema.types.NCName;
-import org.apache.axis2.schema.types.NMToken;
-import org.apache.axis2.schema.types.NMTokens;
-import org.apache.axis2.schema.types.Name;
-import org.apache.axis2.schema.types.NegativeInteger;
-import org.apache.axis2.schema.types.NonNegativeInteger;
-import org.apache.axis2.schema.types.NonPositiveInteger;
-import org.apache.axis2.schema.types.NormalizedString;
-import org.apache.axis2.schema.types.Notation;
-import org.apache.axis2.schema.types.PositiveInteger;
-import org.apache.axis2.schema.types.Time;
-import org.apache.axis2.schema.types.Token;
-import org.apache.axis2.schema.types.URI;
-import org.apache.axis2.schema.types.UnsignedByte;
-import org.apache.axis2.schema.types.UnsignedInt;
-import org.apache.axis2.schema.types.UnsignedLong;
-import org.apache.axis2.schema.types.UnsignedShort;
-import org.apache.axis2.schema.types.Year;
-import org.apache.axis2.schema.types.YearMonth;
+import org.apache.axis2.schema.types.*;
 
 import javax.xml.namespace.QName;
 import java.math.BigDecimal;

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/ConverterUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/ConverterUtil.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/ConverterUtil.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/ConverterUtil.java Tue Dec 20 06:07:34 2005
@@ -1,35 +1,6 @@
 package org.apache.axis2.schema.util;
 
-import org.apache.axis2.schema.types.Day;
-import org.apache.axis2.schema.types.Duration;
-import org.apache.axis2.schema.types.Entities;
-import org.apache.axis2.schema.types.Entity;
-import org.apache.axis2.schema.types.HexBinary;
-import org.apache.axis2.schema.types.IDRef;
-import org.apache.axis2.schema.types.IDRefs;
-import org.apache.axis2.schema.types.Id;
-import org.apache.axis2.schema.types.Language;
-import org.apache.axis2.schema.types.Month;
-import org.apache.axis2.schema.types.MonthDay;
-import org.apache.axis2.schema.types.NCName;
-import org.apache.axis2.schema.types.NMToken;
-import org.apache.axis2.schema.types.NMTokens;
-import org.apache.axis2.schema.types.Name;
-import org.apache.axis2.schema.types.NegativeInteger;
-import org.apache.axis2.schema.types.NonNegativeInteger;
-import org.apache.axis2.schema.types.NonPositiveInteger;
-import org.apache.axis2.schema.types.NormalizedString;
-import org.apache.axis2.schema.types.Notation;
-import org.apache.axis2.schema.types.PositiveInteger;
-import org.apache.axis2.schema.types.Time;
-import org.apache.axis2.schema.types.Token;
-import org.apache.axis2.schema.types.URI;
-import org.apache.axis2.schema.types.UnsignedByte;
-import org.apache.axis2.schema.types.UnsignedInt;
-import org.apache.axis2.schema.types.UnsignedLong;
-import org.apache.axis2.schema.types.UnsignedShort;
-import org.apache.axis2.schema.types.Year;
-import org.apache.axis2.schema.types.YearMonth;
+import org.apache.axis2.schema.types.*;
 import sun.misc.BASE64Decoder;
 
 import javax.xml.namespace.QName;
@@ -37,11 +8,7 @@
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.List;
-import java.util.TimeZone;
+import java.util.*;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
  *

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/SchemaPropertyLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/SchemaPropertyLoader.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/SchemaPropertyLoader.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/util/SchemaPropertyLoader.java Tue Dec 20 06:07:34 2005
@@ -24,13 +24,13 @@
  * Loads the properties  for the schema compiler
  */
 public class SchemaPropertyLoader {
-    private  static  String beanTemplate = null;
+    private  static  String unwrappedBeanTemplate = null;
     private  static  BeanWriter beanWriterInstance = null;
     private  static  TypeMap typeMapperInstance = null;
 
     private static final String SCHEMA_COMPILER_PROPERTIES = "/org/apache/axis2/schema/schema-compile.properties";
     private static final String BEAN_WRITER_KEY = "schema.bean.writer.class";
-    private static final String BEAN_WRITER_TEMPLATE_KEY = "schema.bean.writer.template";
+    private static final String BEAN_WRITER_UNWRAPPED_TEMPLATE_KEY = "schema.bean.writer.template.wrapped";
     private static final String BEAN_WRITER_TYPEMAP_KEY = "schema.bean.typemap";
 
     static{
@@ -49,7 +49,7 @@
                  typeMapperInstance = (TypeMap)Class.forName(typeMapperClassName).newInstance();
             }
 
-            beanTemplate = props.getProperty(BEAN_WRITER_TEMPLATE_KEY);
+            unwrappedBeanTemplate = props.getProperty(BEAN_WRITER_UNWRAPPED_TEMPLATE_KEY);
             
         } catch (Exception e) {
            throw new RuntimeException(e);
@@ -58,8 +58,8 @@
 
     }
 
-    public static String getBeanTemplate() {
-        return beanTemplate;
+    public static String getUnwrappedBeanTemplate() {
+        return unwrappedBeanTemplate;
     }
 
     public static BeanWriter getBeanWriterInstance() {

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/BeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/BeanWriter.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/BeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/BeanWriter.java Tue Dec 20 06:07:34 2005
@@ -7,7 +7,6 @@
 import org.apache.ws.commons.schema.XmlSchemaElement;
 import org.apache.ws.commons.schema.XmlSchemaSimpleType;
 
-import java.io.File;
 import java.io.IOException;
 import java.util.Map;
 /*
@@ -32,21 +31,19 @@
  */
 public interface BeanWriter {
 
-    /**
-     * Initialize this writer
-     * @param rootDir  - The directory to be written into
-     * @throws IOException
-     */
-    public void init(File rootDir) throws IOException ;
 
     /**
      *  Init the write with compiler options
      * @param options
      * @throws IOException
      */
-    public void init(CompilerOptions options) throws IOException ;
-
+    public void init(CompilerOptions options) throws SchemaCompilationException;
 
+    /**
+     * Writes a wrapped class. This will have effect only if the CompilerOptions wrapclassses
+     * returns true
+     */
+     public void writeBatch() throws SchemaCompilationException;
 
     /**
      * Write a complex type
@@ -67,6 +64,8 @@
      * @throws SchemaCompilationException
      */
     public String write(XmlSchemaElement element, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException;
+
+
 
     /**
      * Write a simple type

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Tue Dec 20 06:07:34 2005
@@ -15,15 +15,12 @@
 import org.w3c.dom.Element;
 
 import javax.xml.namespace.QName;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.Templates;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamSource;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -49,46 +46,66 @@
  */
 public class JavaBeanWriter implements BeanWriter{
 
+    public static final String WRAPPED_DATABINDING_CLASS_NAME="WrappedDatabinder";
+
     private String javaBeanTemplateName = null;
     private boolean templateLoaded = false;
     private Templates templateCache;
 
     private List namesList;
     private static int count = 0;
+    private boolean wrapClasses;
 
     private String packageName=null;
-
-
-
     private File rootDir;
 
+    private Document globalWrappedDocument;
     /**
      * Default constructor
      */
     public JavaBeanWriter(){
     }
 
-    public void init(CompilerOptions options) throws IOException {
-        init(options.getOutputLocation());
-        this.packageName = options.getPackageName();
+    public void init(CompilerOptions options) throws SchemaCompilationException {
+        try {
+            initWithFile(options.getOutputLocation());
+            this.packageName = options.getPackageName();
+            this.wrapClasses = options.isWrapClasses();
+
+            //if the wrap mode is set then create a global document to keep the wrapped
+            //element models
+            if (options.isWrapClasses()){
+                globalWrappedDocument = XSLTUtils.getDocument();
+                Element rootElement = XSLTUtils.getElement(globalWrappedDocument,"beans");
+                globalWrappedDocument.appendChild(rootElement);
+                XSLTUtils.addAttribute(globalWrappedDocument,"name",WRAPPED_DATABINDING_CLASS_NAME,rootElement);
+                XSLTUtils.addAttribute(globalWrappedDocument,"package",packageName,rootElement);
+            }
+        } catch (IOException e) {
+            throw new SchemaCompilationException(e);
+        } catch (ParserConfigurationException e) {
+            throw new SchemaCompilationException(e); //todo need to put correct error messages
+        }
     }
 
     /**
-     * @see BeanWriter#init(java.io.File)
-     * @param rootDir
-     * @throws IOException
+     *
+     * @param element
+     * @param typeMap
+     * @param metainf
+     * @return
+     * @throws SchemaCompilationException
      */
-    public void init(File rootDir) throws IOException{
-        if (rootDir ==null){
-            this.rootDir = new File(".");
-        }else if (!rootDir.isDirectory()){
-            throw new IOException("Root location needs to be a directory!");
-        } else{
-            this.rootDir = rootDir;
+    public String write(XmlSchemaElement element, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException{
+
+        try {
+            QName qName = element.getQName();
+            return process(qName, metainf, typeMap, true);
+        } catch (Exception e) {
+            throw new SchemaCompilationException(e);
         }
 
-        namesList = new ArrayList();
-        javaBeanTemplateName = SchemaPropertyLoader.getBeanTemplate();
+
     }
     /**
      * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaComplexType, java.util.Map, org.apache.axis2.schema.BeanWriterMetaInfoHolder)
@@ -114,6 +131,54 @@
     }
 
     /**
+     * @see org.apache.axis2.schema.writer.BeanWriter#writeBatch()
+     * @throws Exception
+     */
+    public void writeBatch() throws SchemaCompilationException{
+        try {
+            if (wrapClasses){
+
+                OutputStream out = createOutFile(packageName,WRAPPED_DATABINDING_CLASS_NAME);
+                //parse with the template and create the files
+                parse(globalWrappedDocument,out);
+            }
+        } catch (Exception e) {
+            throw new SchemaCompilationException(e);
+        }
+    }
+
+    /**
+     * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaSimpleType, java.util.Map, org.apache.axis2.schema.BeanWriterMetaInfoHolder)
+     * @param simpleType
+     * @param typeMap
+     * @param metainf
+     * @return
+     * @throws SchemaCompilationException
+     */
+    public String write(XmlSchemaSimpleType simpleType, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException {
+        throw new SchemaCompilationException("Not implemented yet");
+    }
+    /**
+     * @see BeanWriter#init(java.io.File)
+     * @param rootDir
+     * @throws IOException
+     */
+    private void initWithFile(File rootDir) throws IOException{
+        if (rootDir ==null){
+            this.rootDir = new File(".");
+        }else if (!rootDir.isDirectory()){
+            throw new IOException("Root location needs to be a directory!");
+        } else{
+            this.rootDir = rootDir;
+        }
+
+        namesList = new ArrayList();
+        javaBeanTemplateName = SchemaPropertyLoader.getUnwrappedBeanTemplate();
+    }
+
+
+
+    /**
      * A util method that holds common code
      * for the complete schema that the generated XML complies to
      * look under other/beanGenerationSchema.xsd
@@ -127,31 +192,77 @@
     private String process(QName qName, BeanWriterMetaInfoHolder metainf, Map typeMap, boolean isElement) throws Exception {
 
         String nameSpaceFromURL = URLProcessor.getNameSpaceFromURL(qName.getNamespaceURI());
-        String packageName = this.packageName==null?
-                     nameSpaceFromURL :
-                     this.packageName +nameSpaceFromURL;
 
-        
+        String packageName = this.packageName==null?
+                nameSpaceFromURL :
+                this.packageName +nameSpaceFromURL;
 
         String originalName = qName.getLocalPart();
         String className = getNonConflictingName(this.namesList,originalName);
-
+        String fullyqualifiedClassName = null;
         ArrayList propertyNames = new ArrayList();
 
         if (!templateLoaded){
             loadTemplate();
         }
 
-        //create the model
-        Document model= XSLTUtils.getDocument();
+        if (wrapClasses){
+            globalWrappedDocument.getDocumentElement().appendChild(
+                    getBeanElement(globalWrappedDocument, className, originalName, packageName, qName, isElement, metainf, propertyNames, typeMap)
+            );
+            //now the fully qualified class name needs to have the name of the including class as well
+            fullyqualifiedClassName = packageName + "."+ WRAPPED_DATABINDING_CLASS_NAME +"." + className;
+        }else{
+            //create the model
+            Document model= XSLTUtils.getDocument();
+            //make the XML
+            model.appendChild(getBeanElement(model, className, originalName, packageName, qName, isElement, metainf, propertyNames, typeMap));
+            //create the file
+            OutputStream out = createOutFile(packageName,className);
+            //parse with the template and create the files
+            parse(model,out);
+            fullyqualifiedClassName = packageName + "." + className;
+        }
+
+        //return the fully qualified class name
+        return fullyqualifiedClassName;
+
+    }
+
+
+
 
-        //make the XML
-        Element rootElt = XSLTUtils.addChildElement(model,"bean",model);
+    /**
+     *
+     * @param model
+     * @param className
+     * @param originalName
+     * @param packageName
+     * @param qName
+     * @param isElement
+     * @param metainf
+     * @param propertyNames
+     * @param typeMap
+     * @return
+     * @throws SchemaCompilationException
+     */
+    private Element getBeanElement(
+            Document model, String className, String originalName,
+            String packageName, QName qName, boolean isElement,
+            BeanWriterMetaInfoHolder metainf, ArrayList propertyNames, Map typeMap
+    ) throws SchemaCompilationException {
+
+        Element rootElt = XSLTUtils.getElement(model,"bean");
         XSLTUtils.addAttribute(model,"name",className,rootElt);
         XSLTUtils.addAttribute(model,"originalName",originalName,rootElt);
         XSLTUtils.addAttribute(model,"package",packageName,rootElt);
         XSLTUtils.addAttribute(model,"nsuri",qName.getNamespaceURI(),rootElt);
         XSLTUtils.addAttribute(model,"nsprefix",qName.getPrefix(),rootElt);
+
+        if (!wrapClasses){
+            XSLTUtils.addAttribute(model,"unwrapped","yes",rootElt);
+        }
+
         if (!isElement){
             XSLTUtils.addAttribute(model,"type","yes",rootElt);
         }
@@ -164,7 +275,7 @@
             XSLTUtils.addAttribute(model,"extension",metainf.getExtensionClassName(),rootElt);
         }
         // go in the loop and add the part elements
-        QName[] qNames = null;
+        QName[] qNames;
         if (metainf.isOrdered()){
             qNames = metainf.getOrderedQNameArray();
         }else{
@@ -178,7 +289,7 @@
             String xmlName = name.getLocalPart();
             XSLTUtils.addAttribute(model,"name",xmlName,property);
 
-            String javaName = "";
+            String javaName;
             if (JavaUtils.isJavaKeyword(xmlName)){
                 javaName = JavaUtils.makeNonJavaKeyword(xmlName);
             }else{
@@ -217,6 +328,7 @@
                 XSLTUtils.addAttribute(model,"anyAtt","yes",property);
             }
             if (metainf.getArrayStatusForQName(name)){
+
                 XSLTUtils.addAttribute(model,"array","yes",property);
                 XSLTUtils.addAttribute(
                         model,
@@ -240,26 +352,10 @@
             }
         }
 
-        //create the file
-        OutputStream out = createOutFile(packageName,className);
-        //parse with the template and create the files
-        parse(model,out);
-        //return the fully qualified class name
-        return packageName+"."+className;
-
+        return rootElt;
     }
 
-    /**
-     * @see BeanWriter#write(org.apache.ws.commons.schema.XmlSchemaSimpleType, java.util.Map, org.apache.axis2.schema.BeanWriterMetaInfoHolder)
-     * @param simpleType
-     * @param typeMap
-     * @param metainf
-     * @return
-     * @throws SchemaCompilationException
-     */
-    public String write(XmlSchemaSimpleType simpleType, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException {
-        throw new SchemaCompilationException("Not implemented yet");
-    }
+
 
     /**
      * gets a non conflicting java name
@@ -280,25 +376,6 @@
         return nameToReturn;
     }
 
-    /**
-     *
-     * @param element
-     * @param typeMap
-     * @param metainf
-     * @return
-     * @throws SchemaCompilationException
-     */
-    public String write(XmlSchemaElement element, Map typeMap, BeanWriterMetaInfoHolder metainf) throws SchemaCompilationException{
-
-        try {
-            QName qName = element.getQName();
-            return process(qName, metainf, typeMap, true);
-        } catch (Exception e) {
-            throw new SchemaCompilationException(e);
-        }
-
-
-    }
 
 
 
@@ -360,4 +437,6 @@
         outStream.close();
 
     }
+
+
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTUtils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTUtils.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTUtils.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTUtils.java Tue Dec 20 06:07:34 2005
@@ -47,6 +47,13 @@
         element.setAttributeNode(attribute);
     }
 
+    public static Element getElement(Document document,
+                                      String elementName) {
+         return document.createElement(elementName);
+          
+      }
+
+
     /**
      * Utility method to add an attribute to a given element
      * @param document

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java Tue Dec 20 06:07:34 2005
@@ -21,8 +21,14 @@
 import org.apache.commons.logging.LogFactory;
 
 public abstract class AbstractCodeGenerationExtension implements CodeGenExtension {
+
     protected Log log = LogFactory.getLog(this.getClass());
+    
     protected CodeGenConfiguration configuration;
 
-    
+    public void init(CodeGenConfiguration configuration) {
+        this.configuration = configuration;
+    }
+
+
 }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java Tue Dec 20 06:07:34 2005
@@ -44,9 +44,6 @@
     public AxisBindingBuilder() {
     }
 
-    public void init(CodeGenConfiguration configuration) {
-        this.configuration = configuration;
-    }
 
     public void engage() {
         WSDLDescription wom = this.configuration.getWom();

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java Tue Dec 20 06:07:34 2005
@@ -23,11 +23,8 @@
 import org.apache.axis2.wsdl.databinding.TypeMapper;
 
 public class DefaultDatabindingExtension extends AbstractDBProcessingExtension{
-    private CodeGenConfiguration configuration;
-    public void init(CodeGenConfiguration configuration) {
-        this.configuration = configuration;
-    }
 
+  
     public void engage() throws CodeGenerationException {
         TypeMapper mappper = configuration.getTypeMapper();
         if (testFallthrough(configuration.getDatabindingType())){

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java Tue Dec 20 06:07:34 2005
@@ -22,11 +22,7 @@
 
 public class PackageFinder extends AbstractCodeGenerationExtension {
 
-    public void init(CodeGenConfiguration configuration) {
-        this.configuration = configuration;
-
-    }
-
+  
     public void engage() {
         String packageName = this.configuration.getPackageName();
         if (packageName == null) {

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java Tue Dec 20 06:07:34 2005
@@ -41,11 +41,8 @@
  *
  */
 public class SimpleDBExtension extends AbstractDBProcessingExtension {
-    public static final String ADB_PACKAGE_NAME_PREFIX = "adb.";
 
-    public void init(CodeGenConfiguration configuration) {
-        this.configuration = configuration;
-    }
+    public static final String ADB_PACKAGE_NAME_PREFIX = "adb.";
 
     public void engage() {
         //test the databinding type. If not just fall through

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java Tue Dec 20 06:07:34 2005
@@ -31,10 +31,7 @@
 public class WSDLValidatorExtension extends AbstractCodeGenerationExtension {
     private static String TARGETNAMESPACE_STRING = "targetNamespace";
 
-    public void init(CodeGenConfiguration configuration) {
-        this.configuration = configuration;
-    }
-
+  
     public void engage() throws CodeGenerationException {
         //WSDLDescription wom = this.configuration.getWom();
         WSDLTypes typesList = configuration.getWom().getTypes();

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java?rev=357991&r1=357990&r2=357991&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java Tue Dec 20 06:07:34 2005
@@ -78,10 +78,6 @@
     public static final String MAPPER_FILE_NAME = "mapper";
 
 
-    public void init(CodeGenConfiguration configuration) {
-        this.configuration = configuration;
-    }
-
     public void engage() {
 
         //test the databinding type. If not just fall through