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 2006/03/16 06:34:21 UTC

svn commit: r386267 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2: schema/ wsdl/codegen/ wsdl/codegen/emitter/ wsdl/template/html/

Author: ajith
Date: Wed Mar 15 21:34:21 2006
New Revision: 386267

URL: http://svn.apache.org/viewcvs?rev=386267&view=rev
Log:
1. Checking in an experimental html/javascript based dynamic client
   I. Added a new template
   II. Added a modified emitter based on the multilanguage client emitter
   III. modified the codegen config properties

Added:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/HtmlClientEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/html/
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/html/HtmlClientTemplate.xsl
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/SchemaCompiler.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties

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=386267&r1=386266&r2=386267&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 Wed Mar 15 21:34:21 2006
@@ -927,7 +927,7 @@
 
                 if (elt.getQName()!=null){
                     clazzName = (String) processedElementTypeMap.get(elt.getQName());
-                    referencedQName = elt.getQName();
+                    referencedQName = elt.getQName();                                
                     metainfHolder.registerMapping(referencedQName,
                             elt.getSchemaType()!=null?elt.getSchemaType().getQName():elt.getSchemaTypeName(), //always get the schema type name from the schema it-self
                             clazzName,

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties?rev=386267&r1=386266&r2=386267&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties Wed Mar 15 21:34:21 2006
@@ -34,12 +34,12 @@
 # Language types - these are the language types that the code generator understands. Again this is the name of the
 # language that should be passed from the tool as well
 #
-codegen.languages=java,c-sharp
+codegen.languages=java,c-sharp,html
 # Emitter class is the  major code generator class that should be changed according to the language.
 # The emiiters need to implement the org.apache.axis2.wsdl.codegen.emitter.Emitter interface
 # Note - The emitters should appear in the lexical order of the languages. So the language java in the above
 # list corresponds to the org.apache.axis2.wsdl.codegen.emitter.JavaEmitter
-codegen.emitters=org.apache.axis2.wsdl.codegen.emitter.JavaEmitter,org.apache.axis2.wsdl.codegen.emitter.CSharpEmitter
+codegen.emitters=org.apache.axis2.wsdl.codegen.emitter.JavaEmitter,org.apache.axis2.wsdl.codegen.emitter.CSharpEmitter,org.apache.axis2.wsdl.codegen.emitter.HtmlClientEmitter
 # Default language, this is the default language that would be picked when no language is specified. it should be
 # one of the languages specified above
 codegen.languages.default=java
@@ -80,3 +80,6 @@
 c-sharp.service.template=org.apache.axis2.wsdl.codegen.writer.ServiceXMLWriter,/org/apache/axis2/wsdl/template/general/ServiceXMLTemplate.xsl
 c-sharp.message.receiver.template=org.apache.axis2.wsdl.codegen.writer.MessageReceiverWriter,/org/apache/axis2/wsdl/template/csharp/MessageReceiverTemplate.xsl
 c-sharp.filename.extension=cs
+
+html.interface.impl.template=org.apache.axis2.wsdl.codegen.writer.InterfaceImplementationWriter,/org/apache/axis2/wsdl/template/html/HtmlClientTemplate.xsl
+html.filename.extension=html
\ No newline at end of file

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/HtmlClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/HtmlClientEmitter.java?rev=386267&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/HtmlClientEmitter.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/HtmlClientEmitter.java Wed Mar 15 21:34:21 2006
@@ -0,0 +1,67 @@
+package org.apache.axis2.wsdl.codegen.emitter;
+
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.codegen.writer.ClassWriter;
+import org.w3c.dom.Document;
+
+import java.io.IOException;
+/*
+ * 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 HtmlClientEmitter extends MultiLanguageClientEmitter {
+
+
+    /**
+     * emit stub been overwritten to write the interface implementation
+     * only
+     * @throws CodeGenerationException
+     */
+    public void emitStub() throws CodeGenerationException {
+        try {
+            //write interface implementations
+            //for the html clients we are only generating the
+            //the stub
+            writeInterfaceImplementation();
+        } catch (Exception e) {
+            throw new CodeGenerationException(e);
+        }
+    }
+
+    /**
+     * Skeletons are not supported in the html client case
+     * @throws CodeGenerationException
+     */
+    public void emitSkeleton() throws CodeGenerationException {
+        //we do not support emitting "skeltons" in html
+        throw new CodeGenerationException("Emitting skeletons is not supported for this language!");
+    }
+
+
+    /**
+     * Write class overidden to avoid the packaging
+     * @param model
+     * @param writer
+     * @throws IOException
+     * @throws Exception
+     */
+    protected void writeClass(Document model, ClassWriter writer) throws IOException, Exception {
+        writer.loadTemplate();
+        String className = model.getDocumentElement().getAttribute("name");
+        writer.createOutFile(null, className);  //pass in null as the package
+        // use the global resolver
+        writer.parse(model, resolver);
+    }
+}

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/html/HtmlClientTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/html/HtmlClientTemplate.xsl?rev=386267&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/html/HtmlClientTemplate.xsl (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/html/HtmlClientTemplate.xsl Wed Mar 15 21:34:21 2006
@@ -0,0 +1,27 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:output method="html"/>
+    <xsl:template match="/class">
+        <html>
+            <header>
+                <title>Auto generated access page for <xsl:value-of select="@name"/></title>
+
+                <!-- generate a javascript here -->
+
+            </header>
+            <body>
+                <xsl:variable name="endpoint"><xsl:value-of select="endpoint"/></xsl:variable>
+                <xsl:for-each select="method">
+                    <h2>Access Form for <xsl:value-of select="@name"/></h2>
+                    <form method="post" action="#dosomething">
+                        <xsl:attribute name="action"><xsl:value-of select="$endpoint"/></xsl:attribute>
+                    <xsl:for-each select="input/param[@location='body']">
+                        parameter(<xsl:value-of select="@name"/>[<xsl:value-of select="@type"/> ]) <input type="text"/>
+                    </xsl:for-each>
+                     <input type="submit" value="Send Request"></input>
+                     <input type="reset" value="Clear all"></input>
+                    </form>
+                </xsl:for-each>
+            </body>
+        </html>
+    </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file