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/05/11 10:06:20 UTC

svn commit: r169599 - in /webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl: codegen/XSLTConstants.java codegen/emitter/JavaEmitter.java codegen/emitter/MultiLanguageClientEmitter.java codegen/writer/BeanWriter.java databinding/JavaTypeMapper.java template/java/BeanTemplate.xsl

Author: ajith
Date: Wed May 11 01:06:19 2005
New Revision: 169599

URL: http://svn.apache.org/viewcvs?rev=169599&view=rev
Log:
Adding a bean writer and the relevant changes. Still not functional

Added:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/writer/BeanWriter.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/BeanTemplate.xsl
Modified:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/XSLTConstants.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/databinding/JavaTypeMapper.java

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/XSLTConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/XSLTConstants.java?rev=169599&r1=169598&r2=169599&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/XSLTConstants.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/XSLTConstants.java Wed May 11 01:06:19 2005
@@ -44,4 +44,12 @@
         public static final String JAVA_TEMPLATE = "/org/apache/axis/wsdl/template/java/InterfaceImplementationTemplate.xsl";
         public static final String CSHARP_TEMPLATE = "/org/apache/axis/wsdl/template/csharp/InterfaceImplementationTemplate.xsl";
     }
+
+    /**
+     * Interface bean templates
+     */
+    public interface XSLTBeanTemplates{
+        public static final String JAVA_TEMPLATE = "/org/apache/axis/wsdl/template/java/BeanTemplate.xsl";
+        public static final String CSHARP_TEMPLATE = "/org/apache/axis/wsdl/template/csharp/BeanTemplate.xsl";
+    }
 }

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java?rev=169599&r1=169598&r2=169599&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java Wed May 11 01:06:19 2005
@@ -2,17 +2,23 @@
 
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.HashMap;
+import java.util.Enumeration;
 
 import org.apache.axis.wsdl.databinding.JavaTypeMapper;
 import org.apache.axis.wsdl.databinding.TypeMapper;
 import org.apache.axis.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis.wsdl.codegen.CodeGenerationException;
 import org.apache.crimson.tree.XmlDocument;
 import org.apache.wsdl.WSDLBinding;
 import org.apache.wsdl.WSDLInterface;
 import org.apache.wsdl.WSDLOperation;
+import org.apache.wsdl.WSDLExtensibilityElement;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 
+import javax.wsdl.extensions.UnknownExtensibilityElement;
+
 /*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
@@ -53,6 +59,10 @@
 
     }
 
+    public void emitStub() throws CodeGenerationException {
+        //todo need to out the type mapper code here
+        super.emitStub();
+    }
 
     /**
      * @see org.apache.axis.wsdl.codegen.emitter.MultiLanguageClientEmitter#createDOMDocuementForInterface(org.apache.wsdl.WSDLBinding)

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=169599&r1=169598&r2=169599&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/MultiLanguageClientEmitter.java Wed May 11 01:06:19 2005
@@ -4,6 +4,9 @@
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Collection;
+import java.util.Iterator;
 
 import org.apache.axis.wsdl.databinding.TypeMapper;
 import org.apache.axis.wsdl.codegen.CodeGenConfiguration;
@@ -15,9 +18,11 @@
 import org.apache.axis.wsdl.codegen.writer.ClassWriter;
 import org.apache.axis.wsdl.codegen.writer.InterfaceWriter;
 import org.apache.axis.wsdl.codegen.writer.InterfaceImplementationWriter;
+import org.apache.axis.wsdl.codegen.writer.BeanWriter;
 import org.apache.crimson.tree.XmlDocument;
 import org.apache.wsdl.WSDLBinding;
 import org.apache.wsdl.WSDLOperation;
+import org.apache.wsdl.WSDLTypes;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 
@@ -40,17 +45,17 @@
 * the XML will look like the following
 * todo escape the following
 * <pre>
-    <interface package="">
-    <method name="">
-    <input>
-        <param name="" type=""/>*
-    </input> ?
-    <output>
-        <param name="" type=""/>?
-    </output>?
-    </method>
-    </interface>
-  </pre>
+<interface package="">
+<method name="">
+<input>
+<param name="" type=""/>*
+</input> ?
+<output>
+<param name="" type=""/>?
+</output>?
+</method>
+</interface>
+</pre>
 */
 
 
@@ -60,11 +65,11 @@
     protected CodeGenConfiguration configuration;
     protected TypeMapper mapper;
 
-   /**
-    * Sets the mapper
-    * @see org.apache.axis.wsdl.databinding.TypeMapper
-    * @param mapper
-    */
+    /**
+     * Sets the mapper
+     * @see org.apache.axis.wsdl.databinding.TypeMapper
+     * @param mapper
+     */
     public void setMapper(TypeMapper mapper) {
         this.mapper = mapper;
     }
@@ -77,10 +82,10 @@
         this.configuration = configuration;
     }
 
-   /**
-    *
-    * @see org.apache.axis.wsdl.codegen.emitter.Emitter#emitStub()
-    */
+    /**
+     *
+     * @see org.apache.axis.wsdl.codegen.emitter.Emitter#emitStub()
+     */
     public void emitStub() throws CodeGenerationException {
         try {
             //get the binding
@@ -100,13 +105,13 @@
      * @param axisBinding
      * @throws Exception
      */
-    private void writeInterfaces(WSDLBinding axisBinding) throws Exception {
+    protected void writeInterfaces(WSDLBinding axisBinding) throws Exception {
         XmlDocument interfaceModel = createDOMDocuementForInterface(axisBinding);
         InterfaceWriter interfaceWriter =
                 new InterfaceWriter(this.configuration.getOutputLocation(),
                         this.configuration.getOutputLanguage()
                 );
-       writeClasses(interfaceModel,interfaceWriter);
+        writeClasses(interfaceModel,interfaceWriter);
     }
 
     /**
@@ -114,7 +119,7 @@
      * @param axisBinding
      * @throws Exception
      */
-    private void writeInterfaceImplementations(WSDLBinding axisBinding) throws Exception {
+    protected void writeInterfaceImplementations(WSDLBinding axisBinding) throws Exception {
         XmlDocument interfaceImplModel = createDOMDocuementForInterfaceImplementation(axisBinding);
         InterfaceImplementationWriter interfaceImplWriter =
                 new InterfaceImplementationWriter(this.configuration.getOutputLocation(),
@@ -124,6 +129,26 @@
     }
 
     /**
+     *
+     * @param wsdlType
+     * @throws Exception
+     */
+    protected void writeBeans(WSDLTypes wsdlType) throws Exception {
+        HashMap typesMap = wsdlType.getTypes();
+        if (typesMap!=null){
+            Collection collection = typesMap.values();
+            for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
+                XmlDocument interfaceModel = createDOMDocuementForBean();
+                BeanWriter beanWriter =
+                        new BeanWriter(this.configuration.getOutputLocation(),
+                                this.configuration.getOutputLanguage()
+                        );
+                writeClasses(interfaceModel,beanWriter);
+            }
+        }
+
+    }
+    /**
      * A resusable method for the implementation of interface and implementation writing
      * @param model
      * @param writer
@@ -203,6 +228,14 @@
         outputElt.appendChild(param);
 
         return outputElt;
+    }
+
+    /**
+     * Todo Finish this
+     * @return
+     */
+    protected XmlDocument createDOMDocuementForBean(){
+        return null;
     }
 }
 

Added: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/writer/BeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/writer/BeanWriter.java?rev=169599&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/writer/BeanWriter.java (added)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/writer/BeanWriter.java Wed May 11 01:06:19 2005
@@ -0,0 +1,54 @@
+package org.apache.axis.wsdl.codegen.writer;
+
+import org.apache.axis.wsdl.codegen.XSLTConstants;
+
+import java.io.File;
+
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * 
+ */
+public class BeanWriter extends ClassWriter{
+
+    public BeanWriter(String outputFileLocation) {
+        this.outputFileLocation = new File(outputFileLocation);
+    }
+
+    public BeanWriter(File outputFileLocation,int language) {
+        this.outputFileLocation = outputFileLocation;
+        this.language = language;
+    }
+
+    /**
+     * @see org.apache.axis.wsdl.codegen.writer.ClassWriter#loadTemplate()
+     */
+     public void loadTemplate(){
+        Class clazz = this.getClass();
+        switch (language){
+            case XSLTConstants.LanguageTypes.JAVA:
+                this.xsltStream = clazz.getResourceAsStream(XSLTConstants.XSLTBeanTemplates.JAVA_TEMPLATE);
+                break;
+            case XSLTConstants.LanguageTypes.C_SHARP:
+                this.xsltStream = clazz.getResourceAsStream(XSLTConstants.XSLTBeanTemplates.CSHARP_TEMPLATE);
+                break;
+            case XSLTConstants.LanguageTypes.C_PLUS_PLUS:
+            case XSLTConstants.LanguageTypes.VB_DOT_NET:
+            default:
+                throw new UnsupportedOperationException();
+        }
+
+    }
+}

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/databinding/JavaTypeMapper.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/databinding/JavaTypeMapper.java?rev=169599&r1=169598&r2=169599&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/databinding/JavaTypeMapper.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/databinding/JavaTypeMapper.java Wed May 11 01:06:19 2005
@@ -1,6 +1,8 @@
 package org.apache.axis.wsdl.databinding;
 
 import javax.xml.namespace.QName;
+import java.math.BigDecimal;
+import java.util.Date;
 
 
 /*
@@ -43,10 +45,18 @@
 public class JavaTypeMapper extends TypeMappingAdapter{
 
     public JavaTypeMapper() {
+       //add the basic types to the table 
        this.map.put(new QName(XSD_SCHEMA_URL,"string"),String.class);
        this.map.put(new QName(XSD_SCHEMA_URL,"boolean"),Boolean.class);
-
-       //add the rest todo the key should be a QName
+       this.map.put(new QName(XSD_SCHEMA_URL,"double"),Double.class);
+       this.map.put(new QName(XSD_SCHEMA_URL,"long"),Long.class);
+       this.map.put(new QName(XSD_SCHEMA_URL,"float"),Float.class);
+       this.map.put(new QName(XSD_SCHEMA_URL,"int"),Integer.class);
+       this.map.put(new QName(XSD_SCHEMA_URL,"short"),Short.class);
+       this.map.put(new QName(XSD_SCHEMA_URL,"byte"),Byte.class);
+       this.map.put(new QName(XSD_SCHEMA_URL,"decimal"),BigDecimal.class);
+       this.map.put(new QName(XSD_SCHEMA_URL,"date"),Date.class);
+       this.map.put(new QName(XSD_SCHEMA_URL,"QName"),QName.class);
     }
 
 }

Added: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/BeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/BeanTemplate.xsl?rev=169599&view=auto
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/BeanTemplate.xsl (added)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/template/java/BeanTemplate.xsl Wed May 11 01:06:19 2005
@@ -0,0 +1,39 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:output method="text"/>
+    <xsl:template match="/bean">
+    package <xsl:value-of select="@package"/>;
+
+    /**
+     *  Auto generated bean class by the Axis code generator
+     */
+
+    public class <xsl:value-of select="@name"/> {
+
+
+     <xsl:for-each select="property">
+         <xsl:variable name="propertyType"><xsl:value-of select="@type"></xsl:value-of></xsl:variable>
+         <xsl:variable name="propertyName"><xsl:value-of select="@name"></xsl:value-of></xsl:variable>
+        /**
+         * field for <xsl:value-of select="$propertyName"/>
+         */
+         private <xsl:value-of select="$propertyType"/> local<xsl:value-of select="$propertyName"/>
+
+        /**
+         * Auto generated getter method
+         * @return <xsl:value-of select="$propertyType"/>
+         */
+        public  <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text>get<xsl:value-of select="$propertyName"/>(){
+             return local<xsl:value-of select="$propertyName"/>;
+        }
+
+        /**
+         * Auto generated setter method
+         * @param param<xsl:value-of select="$propertyName"/>
+         */
+        public void set<xsl:value-of select="$propertyName"/>(<xsl:value-of select="$propertyType"/> param<xsl:value-of select="$propertyName"/>){
+             this.local<xsl:value-of select="$propertyName"/>=param<xsl:value-of select="$propertyName"/>;
+        }
+     </xsl:for-each>
+    }
+    </xsl:template>
+ </xsl:stylesheet>
\ No newline at end of file