axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r358578 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2: schema/ util/ wsdl/codegen/ wsdl/codegen/writer/ wsdl/template/java/ wsdl/util/
Date Thu, 22 Dec 2005 15:13:25 GMT
Author: ajith
Date: Thu Dec 22 07:13:05 2005
New Revision: 358578

URL: http://svn.apache.org/viewcvs?rev=358578&view=rev
Log:
1. Added a URIresolver for the template processor to handle xsl:includes. In the light of
that the following changes have been made
  I. Moved the databinding templates to DatabindingTemplate.xsl and put it as an include in
InterfaceImplementationTemplate.xsl and MessageReceiverTemplate.xsl. This makes it easier
to maintain and makes the templates cleaner.
  II Added the template name to the config property file. Changed the relevant property loaders
and config holders to cater for that.

Added:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTIncludeResolver.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/XSD2Java.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTTemplateProcessor.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java

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=358578&r1=358577&r2=358578&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
Thu Dec 22 07:13:05 2005
@@ -72,11 +72,12 @@
 
             CompilerOptions compilerOptions = new CompilerOptions();
             compilerOptions.setOutputLocation(outputFolder);
-            //##############################
-            // compilerOptions.setPackageName("adb");
+
+            //todo - this should come from the users preferences
              compilerOptions.setWrapClasses(false);
+
+            //there's no point in not writing the classes here.
              compilerOptions.setWriteOutput(true);
-            //##############################
 
             SchemaCompiler compiler = new SchemaCompiler(compilerOptions);
             compiler.compile(currentSchema);

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTTemplateProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTTemplateProcessor.java?rev=358578&r1=358577&r2=358578&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTTemplateProcessor.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/util/XSLTTemplateProcessor.java
Thu Dec 22 07:13:05 2005
@@ -25,6 +25,7 @@
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.TransformerFactoryConfigurationError;
+import javax.xml.transform.URIResolver;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
@@ -76,6 +77,8 @@
 
     }
 
+
+
     /**
      * @param out
      * @param document
@@ -91,6 +94,32 @@
         Source xsltSource = new StreamSource(xsltStream);
         Transformer transformer = TransformerFactory.newInstance()
                 .newTransformer(xsltSource);
+        parse(out, document, transformer);
+
+    }
+
+    /**
+     * @param out
+     * @param document
+     * @param xsltStream
+     * @throws TransformerFactoryConfigurationError
+     *
+     * @throws TransformerException
+     */
+    public static void parse(OutputStream out,
+                             Document document,
+                             InputStream xsltStream,
+                             URIResolver customResolver)
+            throws TransformerFactoryConfigurationError, TransformerException {
+        Source xsltSource = new StreamSource(xsltStream);
+        TransformerFactory transformerFactory = TransformerFactory.newInstance();
+        if (customResolver!=null){
+             transformerFactory.setURIResolver(customResolver);
+        }
+       
+        Transformer transformer = transformerFactory
+                .newTransformer(xsltSource);
+
         parse(out, document, transformer);
 
     }

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java?rev=358578&r1=358577&r2=358578&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTConstants.java
Thu Dec 22 07:13:05 2005
@@ -17,23 +17,15 @@
 package org.apache.axis2.wsdl.codegen;
 
 import javax.xml.namespace.QName;
-
+ //todo rename this
 public interface XSLTConstants {
     String DEFAULT_PACKAGE_NAME = "codegen";
     QName BASE_64_CONTENT_QNAME = new QName("http://www.w3.org/2001/XMLSchema", "base64Binary");
     QName XMIME_CONTENT_TYPE_QNAME = new QName("http://www.w3.org/2004/06/xmlmime", "contentType");
     String BASE_64_PROPERTY_KEY = "base64map";
 
+    String XSLT_INCLUDE_DATABIND_SUPPORTER_HREF = "databindsupporter"; 
 
-    public interface DataBindingTypes {
-
-        public static final int NONE = 0;
-        public static final int XML_BEANS = 1;
-        public static final int JAXB = 2;
-        public static final int ADB = 3;
-        public static final int USER = 4;
-
-    }
 
     public interface CodegenStyle {
         public static final int AUTOMATIC = 0;

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTIncludeResolver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTIncludeResolver.java?rev=358578&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTIncludeResolver.java
(added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTIncludeResolver.java
Thu Dec 22 07:13:05 2005
@@ -0,0 +1,43 @@
+package org.apache.axis2.wsdl.codegen;
+
+import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
+
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.stream.StreamSource;
+import java.io.InputStream;
+/*
+ * 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 XSLTIncludeResolver implements URIResolver,XSLTConstants {
+
+
+    public Source resolve(String href, String base) throws TransformerException {
+        if (XSLT_INCLUDE_DATABIND_SUPPORTER_HREF.equals(href)){
+            String supporterTemplate = ConfigPropertyFileLoader.getDbSupporterTemplateName();
+            if(supporterTemplate!=null){
+                InputStream supporterTemplateStream = getClass().getResourceAsStream(supporterTemplate);
+                return new StreamSource(supporterTemplateStream);
+            } else{
+                throw new TransformerException("Databinding template not found!");
+            }
+
+        }
+
+        return null;
+    }
+}

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=358578&r1=358577&r2=358578&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
Thu Dec 22 07:13:05 2005
@@ -24,6 +24,9 @@
 codegen.databinding.extensions=org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension,org.apache.axis2.wsdl.codegen.extension.XMLBeansExtension,org.apache.axis2.wsdl.codegen.extension.DefaultDatabindingExtension
 # the default data binding framework name
 codegen.databinding.frameworks.default=adb
+# the databinding template - this should include all the necessary xslt templates for
+# creating the databindsupporters
+codegen.databinding.supporter.template=/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
 #####################################################################################################################
 #####################################################################################################################
 # Language types - these are the language types that the code generator understands. Again
this is the name of the

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java?rev=358578&r1=358577&r2=358578&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
Thu Dec 22 07:13:05 2005
@@ -20,6 +20,7 @@
 import org.apache.axis2.util.FileWriter;
 import org.apache.axis2.util.XSLTTemplateProcessor;
 import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.codegen.XSLTIncludeResolver;
 import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -162,7 +163,8 @@
         if (!fileExists) {
             XSLTTemplateProcessor.parse(this.stream,
                     doc,
-                    this.xsltStream);
+                    this.xsltStream,
+                    new XSLTIncludeResolver());
             this.stream.flush();
             this.stream.close();
             if ("java".equals(language) && outputFile != null) {

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl?rev=358578&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
(added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
Thu Dec 22 07:13:05 2005
@@ -0,0 +1,117 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+    <xsl:output method="text"/>
+
+    <!-- #################################################################################
 -->
+    <!-- ############################   xmlbeans template   ##############################
 -->
+    <xsl:template match="databinders[@dbtype='xmlbeans']">
+
+        <xsl:variable name="base64"><xsl:value-of select="base64Elements/name"/></xsl:variable>
+        <xsl:if test="$base64">
+            private static javax.xml.namespace.QName[] qNameArray = {
+            <xsl:for-each select="base64Elements/name">
+                <xsl:if test="position()>1">,</xsl:if>new javax.xml.namespace.QName("<xsl:value-of
select="@ns-url"/>","<xsl:value-of select="@localName"/>")
+            </xsl:for-each>
+            };
+        </xsl:if>
+
+        <xsl:for-each select="param">
+            <xsl:if test="@type!=''">
+                public  org.apache.axis2.om.OMElement  toOM(<xsl:value-of select="@type"/>
param){
+                org.apache.axis2.om.impl.llom.builder.StAXOMBuilder builder = new org.apache.axis2.om.impl.llom.builder.StAXOMBuilder
+                (org.apache.axis2.om.OMAbstractFactory.getOMFactory(),new org.apache.axis2.util.StreamWrapper(param.newXMLStreamReader()))
;
+
+                <xsl:choose>
+                    <xsl:when test="$base64">
+                         org.apache.axis2.om.OMElement documentElement = builder.getDocumentElement();
+                         optimizeContent(documentElement,qNameArray);
+                         return documentElement;
+                    </xsl:when>
+                    <xsl:otherwise>
+                        return  builder.getDocumentElement();
+                    </xsl:otherwise>
+                </xsl:choose>
+
+                }
+            </xsl:if>
+
+        </xsl:for-each>
+
+        public org.apache.xmlbeans.XmlObject fromOM(org.apache.axis2.om.OMElement param,
+        java.lang.Class type){
+        try{
+        <xsl:for-each select="param">
+            <xsl:if test="@type!=''">
+                if (<xsl:value-of select="@type"/>.class.equals(type)){
+                return <xsl:value-of select="@type"/>.Factory.parse(param.getXMLStreamReader())
;
+                }
+            </xsl:if>
+        </xsl:for-each>
+        }catch(java.lang.Exception e){
+        throw new RuntimeException("Data binding error",e);
+        }
+        return null;
+        }
+
+    </xsl:template>
+    <!-- #################################################################################
 -->
+       <!-- ############################   ADB template   ##############################
 -->
+       <xsl:template match="databinders[@dbtype='adb']">
+
+            <xsl:variable name="base64"><xsl:value-of select="base64Elements/name"/></xsl:variable>
+            <xsl:if test="$base64">
+                private static javax.xml.namespace.QName[] qNameArray = {
+                <xsl:for-each select="base64Elements/name">
+                    <xsl:if test="position()>1">,</xsl:if>new javax.xml.namespace.QName("<xsl:value-of
select="@ns-url"/>","<xsl:value-of select="@localName"/>")
+                </xsl:for-each>
+                };
+            </xsl:if>
+
+            <xsl:for-each select="param">
+                <xsl:if test="@type!=''">
+
+                    public  org.apache.axis2.om.OMElement  toOM(<xsl:value-of select="@type"/>
param){
+                        if (param instanceof org.apache.axis2.databinding.ADBBean){
+                            org.apache.axis2.om.impl.llom.builder.StAXOMBuilder builder =
new org.apache.axis2.om.impl.llom.builder.StAXOMBuilder
+                            (org.apache.axis2.om.OMAbstractFactory.getOMFactory(), param.getPullParser(null));
+                            return builder.getDocumentElement();
+                        }else{
+                           <!-- treat this as a plain bean. use the reflective bean converter
-->
+                           //todo finish this onece the bean serializer has the necessary
methods
+                            retrun null;
+                        }
+                    }
+                </xsl:if>
+            </xsl:for-each>
+
+            public  java.lang.Object fromOM(org.apache.axis2.om.OMElement param,
+            java.lang.Class type){
+                 Object obj;
+                try {
+                    java.lang.reflect.Method parseMethod = type.getMethod("parse",new Class[]{javax.xml.stream.XMLStreamReader.class});
+                    obj = null;
+                    if (parseMethod!=null){
+                        obj = parseMethod.invoke(null,new Object[]{param.getXMLStreamReader()});
+                    }else{
+                        //oops! we don't know how to deal with this. Perhaps the reflective
one is a good choice here
+                    }
+                } catch (Exception e) {
+                     throw new RuntimeException(e);
+                }
+
+                return obj;
+            }
+
+        </xsl:template>
+       <!-- #################################################################################
 -->
+       <!-- ############################   none template!!!   ##############################
 -->
+       <xsl:template match="databinders[@dbtype='none']">
+           public  org.apache.axis2.om.OMElement fromOM(org.apache.axis2.om.OMElement param,
java.lang.Class type){
+              return param;
+           }
+
+           public  org.apache.axis2.om.OMElement  toOM(org.apache.axis2.om.OMElement param){
+               return param;
+           }
+       </xsl:template>
+
+     </xsl:stylesheet>
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=358578&r1=358577&r2=358578&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
Thu Dec 22 07:13:05 2005
@@ -1,5 +1,8 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
+
+    <xsl:include href="databindsupporter"/>
+
     <xsl:template match="/class">
         <xsl:variable name="interfaceName"><xsl:value-of select="@interfaceName"/></xsl:variable>
         <xsl:variable name="package"><xsl:value-of select="@package"/></xsl:variable>
@@ -388,119 +391,5 @@
 
     </xsl:template>
 
-
-    <!-- #################################################################################
 -->
-    <!-- ############################   xmlbeans template   ##############################
 -->
-    <xsl:template match="databinders[@dbtype='xmlbeans']">
-
-        <xsl:variable name="base64"><xsl:value-of select="base64Elements/name"/></xsl:variable>
-        <xsl:if test="$base64">
-            private static javax.xml.namespace.QName[] qNameArray = {
-            <xsl:for-each select="base64Elements/name">
-                <xsl:if test="position()>1">,</xsl:if>new javax.xml.namespace.QName("<xsl:value-of
select="@ns-url"/>","<xsl:value-of select="@localName"/>")
-            </xsl:for-each>
-            };
-        </xsl:if>
-
-        <xsl:for-each select="param">
-            <xsl:if test="@type!=''">
-                public  org.apache.axis2.om.OMElement  toOM(<xsl:value-of select="@type"/>
param){
-                org.apache.axis2.om.impl.llom.builder.StAXOMBuilder builder = new org.apache.axis2.om.impl.llom.builder.StAXOMBuilder
-                (org.apache.axis2.om.OMAbstractFactory.getOMFactory(),new org.apache.axis2.util.StreamWrapper(param.newXMLStreamReader()))
;
-
-                <xsl:choose>
-                    <xsl:when test="$base64">
-                         org.apache.axis2.om.OMElement documentElement = builder.getDocumentElement();
-                         optimizeContent(documentElement,qNameArray);
-                         return documentElement;
-                    </xsl:when>
-                    <xsl:otherwise>
-                        return  builder.getDocumentElement();
-                    </xsl:otherwise>
-                </xsl:choose>
-
-                }
-            </xsl:if>
-
-        </xsl:for-each>
-
-        public org.apache.xmlbeans.XmlObject fromOM(org.apache.axis2.om.OMElement param,
-        java.lang.Class type){
-        try{
-        <xsl:for-each select="param">
-            <xsl:if test="@type!=''">
-                if (<xsl:value-of select="@type"/>.class.equals(type)){
-                return <xsl:value-of select="@type"/>.Factory.parse(param.getXMLStreamReader())
;
-                }
-            </xsl:if>
-        </xsl:for-each>
-        }catch(java.lang.Exception e){
-        throw new RuntimeException("Data binding error",e);
-        }
-        return null;
-        }
-
-    </xsl:template>
-
-    <!-- #################################################################################
 -->
-    <!-- ############################   ADB template   ##############################
 -->
-    <xsl:template match="databinders[@dbtype='adb']">
-
-         <xsl:variable name="base64"><xsl:value-of select="base64Elements/name"/></xsl:variable>
-         <xsl:if test="$base64">
-             private static javax.xml.namespace.QName[] qNameArray = {
-             <xsl:for-each select="base64Elements/name">
-                 <xsl:if test="position()>1">,</xsl:if>new javax.xml.namespace.QName("<xsl:value-of
select="@ns-url"/>","<xsl:value-of select="@localName"/>")
-             </xsl:for-each>
-             };
-         </xsl:if>
-
-         <xsl:for-each select="param">
-             <xsl:if test="@type!=''">
-
-                 public  org.apache.axis2.om.OMElement  toOM(<xsl:value-of select="@type"/>
param){
-                     if (param instanceof org.apache.axis2.databinding.ADBBean){
-                         org.apache.axis2.om.impl.llom.builder.StAXOMBuilder builder = new
org.apache.axis2.om.impl.llom.builder.StAXOMBuilder
-                         (org.apache.axis2.om.OMAbstractFactory.getOMFactory(), param.getPullParser(null));
-                         return builder.getDocumentElement();
-                     }else{
-                        <!-- treat this as a plain bean. use the reflective bean converter
-->
-                        //todo finish this onece the bean serializer has the necessary methods
-                         retrun null;
-                     }
-                 }
-             </xsl:if>
-         </xsl:for-each>
-
-         public  java.lang.Object fromOM(org.apache.axis2.om.OMElement param,
-         java.lang.Class type){
-              Object obj;
-             try {
-                 java.lang.reflect.Method parseMethod = type.getMethod("parse",new Class[]{javax.xml.stream.XMLStreamReader.class});
-                 obj = null;
-                 if (parseMethod!=null){
-                     obj = parseMethod.invoke(null,new Object[]{param.getXMLStreamReader()});
-                 }else{
-                     //oops! we don't know how to deal with this. Perhaps the reflective
one is a good choice here
-                 }
-             } catch (Exception e) {
-                  throw new RuntimeException(e);
-             }
-
-             return obj;
-         }
-
-     </xsl:template>
-    <!-- #################################################################################
 -->
-    <!-- ############################   none template!!!   ##############################
 -->
-    <xsl:template match="databinders[@dbtype='none']">
-        public  org.apache.axis2.om.OMElement fromOM(org.apache.axis2.om.OMElement param,
java.lang.Class type){
-           return param;
-        }
-
-        public  org.apache.axis2.om.OMElement  toOM(org.apache.axis2.om.OMElement param){
-            return param;
-        }
-    </xsl:template>
-
+   
 </xsl:stylesheet>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl?rev=358578&r1=358577&r2=358578&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/MessageReceiverTemplate.xsl
Thu Dec 22 07:13:05 2005
@@ -1,5 +1,8 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
+
+    <xsl:include href="databindsupporter"/>
+
     <xsl:template match="/interface">
         <xsl:variable name="skeletonname"><xsl:value-of select="@skeletonname"/></xsl:variable>
         <xsl:variable name="dbsupportpackage"><xsl:value-of select="@dbsupportpackage"/></xsl:variable>
@@ -118,119 +121,5 @@
         }
     </xsl:template>
 
-     <!-- #################################################################################
 -->
-    <!-- ############################   xmlbeans template   ##############################
 -->
-    <xsl:template match="databinders[@dbtype='xmlbeans']">
-
-        <xsl:variable name="base64"><xsl:value-of select="base64Elements/name"/></xsl:variable>
-        <xsl:if test="$base64">
-            private static javax.xml.namespace.QName[] qNameArray = {
-            <xsl:for-each select="base64Elements/name">
-                <xsl:if test="position()>1">,</xsl:if>new javax.xml.namespace.QName("<xsl:value-of
select="@ns-url"/>","<xsl:value-of select="@localName"/>")
-            </xsl:for-each>
-            };
-        </xsl:if>
-
-        <xsl:for-each select="param">
-            <xsl:if test="@type!=''">
-                public  org.apache.axis2.om.OMElement  toOM(<xsl:value-of select="@type"/>
param){
-                org.apache.axis2.om.impl.llom.builder.StAXOMBuilder builder = new org.apache.axis2.om.impl.llom.builder.StAXOMBuilder
-                (org.apache.axis2.om.OMAbstractFactory.getOMFactory(),new org.apache.axis2.util.StreamWrapper(param.newXMLStreamReader()))
;
-
-                <xsl:choose>
-                    <xsl:when test="$base64">
-                         org.apache.axis2.om.OMElement documentElement = builder.getDocumentElement();
-                         optimizeContent(documentElement,qNameArray);
-                         return documentElement;
-                    </xsl:when>
-                    <xsl:otherwise>
-                        return  builder.getDocumentElement();
-                    </xsl:otherwise>
-                </xsl:choose>
-
-                }
-            </xsl:if>
-
-        </xsl:for-each>
-
-        public org.apache.xmlbeans.XmlObject fromOM(org.apache.axis2.om.OMElement param,
-        java.lang.Class type){
-        try{
-        <xsl:for-each select="param">
-            <xsl:if test="@type!=''">
-                if (<xsl:value-of select="@type"/>.class.equals(type)){
-                return <xsl:value-of select="@type"/>.Factory.parse(param.getXMLStreamReader())
;
-                }
-            </xsl:if>
-        </xsl:for-each>
-        }catch(java.lang.Exception e){
-        throw new RuntimeException("Data binding error",e);
-        }
-        return null;
-        }
-
-    </xsl:template>
-
-    <!-- #################################################################################
 -->
-    <!-- ############################   ADB template   ##############################
 -->
-    <xsl:template match="databinders[@dbtype='adb']">
-
-         <xsl:variable name="base64"><xsl:value-of select="base64Elements/name"/></xsl:variable>
-         <xsl:if test="$base64">
-             private static javax.xml.namespace.QName[] qNameArray = {
-             <xsl:for-each select="base64Elements/name">
-                 <xsl:if test="position()>1">,</xsl:if>new javax.xml.namespace.QName("<xsl:value-of
select="@ns-url"/>","<xsl:value-of select="@localName"/>")
-             </xsl:for-each>
-             };
-         </xsl:if>
-
-        <xsl:for-each select="param">
-                    <xsl:if test="@type!=''">
-
-                        public  org.apache.axis2.om.OMElement  toOM(<xsl:value-of select="@type"/>
param){
-                            if (param instanceof org.apache.axis2.databinding.ADBBean){
-                                org.apache.axis2.om.impl.llom.builder.StAXOMBuilder builder
= new org.apache.axis2.om.impl.llom.builder.StAXOMBuilder
-                                (org.apache.axis2.om.OMAbstractFactory.getOMFactory(), param.getPullParser(null));
-                                return builder.getDocumentElement();
-                            }else{
-                               <!-- treat this as a plain bean. use the reflective bean
converter -->
-                               <!-- todo finish this once the bean serializer has the
necessary methods -->
-                                retrun null;
-                            }
-                        }
-                    </xsl:if>
-                </xsl:for-each>
-
-
-         public  java.lang.Object fromOM(org.apache.axis2.om.OMElement param,
-         java.lang.Class type){
-              Object obj;
-             try {
-                 java.lang.reflect.Method parseMethod = type.getMethod("parse",new Class[]{javax.xml.stream.XMLStreamReader.class});
-                 obj = null;
-                 if (parseMethod!=null){
-                     obj = parseMethod.invoke(null,new Object[]{param.getXMLStreamReader()});
-                 }else{
-                     //oops! we don't know how to deal with this. Perhaps the reflective
one is a good choice here
-                    <!-- todo finish this once the bean serializer has the necessary methods
-->
-                 }
-             } catch (Exception e) {
-                  throw new RuntimeException(e);
-             }
-
-             return obj;
-         }
-
-     </xsl:template>
-    <!-- #################################################################################
 -->
-    <!-- ############################   none template!!!   ##############################
 -->
-    <xsl:template match="databinders[@dbtype='none']">
-        public  org.apache.axis2.om.OMElement fromOM(org.apache.axis2.om.OMElement param,
java.lang.Class type){
-           return param;
-        }
 
-        public  org.apache.axis2.om.OMElement  toOM(org.apache.axis2.om.OMElement param){
-            return param;
-        }
-    </xsl:template>
 </xsl:stylesheet>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java?rev=358578&r1=358577&r2=358578&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/ConfigPropertyFileLoader.java
Thu Dec 22 07:13:05 2005
@@ -14,6 +14,9 @@
  */
 public class ConfigPropertyFileLoader {
 
+
+
+    private static String dbSupporterTemplateName;
     private static String[] extensionClassNames;
     private static String[] thirdPartySchemaNames;
     private static String[] languageTypes;
@@ -25,6 +28,7 @@
     private static String defaultLanguage;
     private static String defaultDBFrameworkName;
 
+
     private static final String CODE_GEN_KEY_PREFIX = "codegen.extension";
     private static final String THIRD_PARTY_SCHEMA_KEY_PREFIX = "codegen.thirdparty.schema";
     private static final String LANGUAGE_TYPE_KEY_PREFIX = "codegen.languages";
@@ -33,6 +37,7 @@
     private static final String DATA_BINDING_FRAMEWORK_NAME_KEY = "codegen.databinding.frameworks";
     private static final String DATA_BINDING_FRAMEWORK_DEFAULT_NAME_KEY = "codegen.databinding.frameworks.default";
     private static final String DATA_BINDING_FRAMEWORK_EXTENSION_NAME_KEY = "codegen.databinding.extensions";
+    private static final String DATA_BINDING_TEMPLATE_NAME_KEY = "codegen.databinding.supporter.template";
     public static final String CODEGEN_CONFIG_PROPERTIES = "/org/apache/axis2/wsdl/codegen/codegen-config.properties";
 
     /* Note - Should be a non regular expression character. If not it should be properly
escaped */
@@ -96,6 +101,10 @@
                 thirdPartySchemaNames = tempString.split(SEPERATOR_CHAR);
 
             }
+            //the db supporter template name
+            dbSupporterTemplateName = props.getProperty(DATA_BINDING_TEMPLATE_NAME_KEY);
+
+
 
             //load the language names
             tempString = props.getProperty(LANGUAGE_TYPE_KEY_PREFIX);
@@ -152,7 +161,9 @@
         }
 
     }
-
+    public static String getDbSupporterTemplateName() {
+        return dbSupporterTemplateName;
+    }
     /**
      * get the extension class names
      *



Mime
View raw message