axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r360252 - in /webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl: codegen/ codegen/emitter/ template/java/ util/
Date Sat, 31 Dec 2005 05:59:52 GMT
Author: ajith
Date: Fri Dec 30 21:59:39 2005
New Revision: 360252

URL: http://svn.apache.org/viewcvs?rev=360252&view=rev
Log:
1. Added test object creation support and fixed the test class generation problem
  I.Added a new template (TestObjectCreationTemplate.xsl) to include the framework specific
test object creation methods
  II. Updated the constants, URIreslover, TestClassTemplate.xsl and other necessary classes
to cater for that change
  III. Added the codegen-config.properties file to include the new template (and the property
loader)


Added:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
Modified:
    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/XSLTIncludeResolver.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/emitter/MultiLanguageClientEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
    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/TestClassTemplate.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/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=360252&r1=360251&r2=360252&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
Fri Dec 30 21:59:39 2005
@@ -24,9 +24,10 @@
     QName XMIME_CONTENT_TYPE_QNAME = new QName("http://www.w3.org/2004/06/xmlmime", "contentType");
 
     String BASE_64_PROPERTY_KEY = "base64map";
-    String EXTERNAL_TEMPLATE_PROPERTY_KEY = "externalTemplate";
 
-    String XSLT_INCLUDE_DATABIND_SUPPORTER_HREF = "databindsupporter"; 
+    String EXTERNAL_TEMPLATE_PROPERTY_KEY = "externalTemplate";
+    String XSLT_INCLUDE_DATABIND_SUPPORTER_HREF_KEY = "databindsupporter";
+    String XSLT_INCLUDE_TEST_OBJECT_HREF_KEY = "testObject"; 
 
 
     public interface CodegenStyle {

Modified: 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=360252&r1=360251&r2=360252&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTIncludeResolver.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/XSLTIncludeResolver.java
Fri Dec 30 21:59:39 2005
@@ -8,7 +8,6 @@
 import javax.xml.transform.stream.StreamSource;
 import java.io.InputStream;
 import java.io.ByteArrayInputStream;
-import java.util.Properties;
 import java.util.Map;
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
@@ -44,14 +43,12 @@
     public Source resolve(String href, String base) throws TransformerException {
         String templateName;
         InputStream supporterTemplateStream;
-        if (XSLT_INCLUDE_DATABIND_SUPPORTER_HREF.equals(href)){
-            templateName = ConfigPropertyFileLoader.getDbSupporterTemplateName();
-            if(templateName!=null){
-                supporterTemplateStream = getClass().getResourceAsStream(templateName);
-                return new StreamSource(supporterTemplateStream);
-            } else{
-                throw new TransformerException("Databinding template not found!");
-            }
+        if (XSLT_INCLUDE_DATABIND_SUPPORTER_HREF_KEY.equals(href)){
+            return getSourceFromTemplateName(ConfigPropertyFileLoader.getDbSupporterTemplateName());
+        }
+
+        if (XSLT_INCLUDE_TEST_OBJECT_HREF_KEY.equals((href))){
+              return getSourceFromTemplateName(ConfigPropertyFileLoader.getTestObjectTemplateName());
         }
 
         if (externalPropertyMap.get(href)!=null){
@@ -63,6 +60,16 @@
         }
         //if nothing could be found return an empty source
         return getEmptySource();
+    }
+
+    private Source getSourceFromTemplateName(String templateName) throws TransformerException
{
+        InputStream supporterTemplateStream;
+        if(templateName!=null){
+            supporterTemplateStream = getClass().getResourceAsStream(templateName);
+            return new StreamSource(supporterTemplateStream);
+        } else{
+            throw new TransformerException(templateName + " template not found!");
+        }
     }
 
     private Source getEmptySource(){

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=360252&r1=360251&r2=360252&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
Fri Dec 30 21:59:39 2005
@@ -27,6 +27,8 @@
 # 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
+
+codegen.databinding.testobject.template=/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.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/emitter/MultiLanguageClientEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java?rev=360252&r1=360251&r2=360252&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
Fri Dec 30 21:59:39 2005
@@ -663,7 +663,7 @@
             }
 
             addAttribute(doc, "value", getParamInitializer(typeMapping), param);
-            
+
             //add this as a body parameter
             addAttribute(doc, "location", "body", param);
             Iterator iter = inputMessage.getExtensibilityAttributes().iterator();
@@ -1081,6 +1081,13 @@
                 rootElement);
         fillSyncAttributes(doc, rootElement);
         loadOperations(boundInterface, doc, rootElement);
+
+        //add the databind supporters. Now the databind supporters are completly contained
inside
+        //the stubs implementation and not visible outside
+        rootElement.appendChild(
+                createDOMElementforDatabinders(doc, binding));
+
+
         doc.appendChild(rootElement);
         return doc;
 
@@ -1445,7 +1452,7 @@
         constructorMap.put(
                 "javax.xml.namespace.QName",
                 "new javax.xml.namespace.QName(\"http://double-double\", \"toil-and-trouble\")");
-    }    
+    }
 
     String getParamInitializer(String paramType) {
         // Look up paramType in the table
@@ -1454,6 +1461,6 @@
             out = "null";
         }
         return out;
-    }        
+    }
 }
 

Modified: 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=360252&r1=360251&r2=360252&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/DatabindingTemplate.xsl
Fri Dec 30 21:59:39 2005
@@ -95,7 +95,7 @@
                     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(param.MY_QNAME));
+                            (org.apache.axis2.om.OMAbstractFactory.getOMFactory(), param.getPullParser(<xsl:value-of
select="@type"/>.MY_QNAME));
                             org.apache.axis2.om.OMElement documentElement = builder.getDocumentElement();
                             ((org.apache.axis2.om.impl.OMNodeEx) documentElement).setParent(null);
// remove the parent link
                             return documentElement;

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=360252&r1=360251&r2=360252&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
Fri Dec 30 21:59:39 2005
@@ -15,7 +15,6 @@
         <xsl:variable name="callbackname"><xsl:value-of select="@callbackname"/></xsl:variable>
         <xsl:variable name="isSync"><xsl:value-of select="@isSync"/></xsl:variable>
         <xsl:variable name="isAsync"><xsl:value-of select="@isAsync"/></xsl:variable>
-        <xsl:variable name="dbpackage"><xsl:value-of select="@dbsupportpackage"/></xsl:variable>
         <xsl:variable name="soapVersion"><xsl:value-of select="@soap-version"/></xsl:variable>
         /**
         * <xsl:value-of select="@name"/>.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl?rev=360252&r1=360251&r2=360252&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestClassTemplate.xsl
Fri Dec 30 21:59:39 2005
@@ -1,5 +1,9 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="text"/>
+
+    <!-- Incldue the test object creation template  -->
+    <xsl:include href="testObject"/>
+
     <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>
@@ -26,7 +30,6 @@
      <xsl:for-each select="method">
          <xsl:if test="@mep='http://www.w3.org/2004/08/wsdl/in-out'">
           <xsl:variable name="outputtype"><xsl:value-of select="output/param/@type"></xsl:value-of></xsl:variable>
-          <xsl:variable name="dbsupportclassname"><xsl:value-of select="@dbsupportname"></xsl:value-of></xsl:variable>
           <xsl:if test="$isSync='1'">
         /**
          * Auto generated test method
@@ -39,7 +42,8 @@
            <xsl:choose>
              <xsl:when test="count(input/param)>0">
                 <xsl:for-each select="input/param[@type!='']">
-                    <xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of
select="@name"/><xsl:text> = </xsl:text><xsl:value-of select="@value"/><xsl:text>;</xsl:text>
+                    <xsl:value-of select="@type"/><xsl:text> </xsl:text><xsl:value-of
select="@name"/><xsl:text>=
+                                                        </xsl:text>(<xsl:value-of
select="@type"/>)getTestObject(<xsl:value-of select="@type"/>.class);
                 </xsl:for-each>
                  
                 <xsl:choose>
@@ -86,13 +90,11 @@
         public  void testStart<xsl:value-of select="@name"/>() throws java.lang.Exception{
             <xsl:value-of select="$package"/>.<xsl:value-of select="$stubname"/>
stub = new <xsl:value-of select="$package"/>.<xsl:value-of select="$stubname"/>();
              //create a new databinder
-            <xsl:variable name="fullsupporterclassname"><xsl:value-of select="$dbpackage"/>.<xsl:value-of
select="$dbsupportclassname"/></xsl:variable>
-            <xsl:value-of select="$fullsupporterclassname"/> databindSupporter = new
<xsl:value-of select="$fullsupporterclassname"/>();
              <xsl:choose>
              <xsl:when test="count(input/param)>0">
                 stub.start<xsl:value-of select="@name"/>(
                          <xsl:for-each select="input/param">
-                             <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if>(<xsl:value-of
select="@type"/>)databindSupporter.getTestObject(<xsl:value-of select="@type"/>.class)
+                             <xsl:if test="@type!=''"><xsl:if test="position()>1">,</xsl:if>(<xsl:value-of
select="@type"/>)getTestObject(<xsl:value-of select="@type"/>.class)
                         </xsl:if>
                         </xsl:for-each>,
                     new <xsl:value-of select="$tempCallbackName"/>()
@@ -112,7 +114,7 @@
             public <xsl:value-of select="$tempCallbackName"/>(){ super(null);}
 
             public void receiveResult<xsl:value-of select="@name"/>(org.apache.axis2.client.async.AsyncResult
result) {
-			    assertNotNull(result.getResponseEnvelope().getBody().getFirstChild());
+			    assertNotNull(result.getResponseEnvelope().getBody().getFirstElement());
             }
 
             public void receiveError<xsl:value-of select="@name"/>(java.lang.Exception
e) {
@@ -124,6 +126,10 @@
       <!-- end of in-out mep -->
       </xsl:if>
      </xsl:for-each>
-	}
+
+       <!-- generate the test object -->
+        <xsl:apply-templates/>
+
+    }
     </xsl:template>
  </xsl:stylesheet>

Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl?rev=360252&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
(added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/TestObjectCreationTemplate.xsl
Fri Dec 30 21:59:39 2005
@@ -0,0 +1,43 @@
+<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']">
+        //Create an ADBBean and provide it as the test object
+        //todo Fill this properly
+        public  org.apache.xmlbeans.XmlObject getTestObject(java.lang.Class type) throws
Exception{
+           <!--Need to fix this-->
+           return null;
+        }
+
+    </xsl:template>
+    <!-- #################################################################################
 -->
+    <!-- ############################   ADB template   ###################################
 -->
+    <xsl:template match="databinders[@dbtype='adb']">
+        //Create an ADBBean and provide it as the test object
+        //todo Fill this properly
+        public org.apache.axis2.databinding.ADBBean getTestObject(java.lang.Class type) throws
Exception{
+           org.apache.axis2.databinding.ADBBean bean = (org.apache.axis2.databinding.ADBBean)type.newInstance();
+
+
+           return bean;
+        }
+
+    </xsl:template>
+    <!-- #################################################################################
 -->
+    <!-- ############################   none template!!!   ###############################
 -->
+    <xsl:template match="databinders[@dbtype='none']">
+        //Create an OMElement and provide it as the test object
+        //todo Fill this properly
+        public org.apache.axis2.om.OMElement getTestObject(java.lang.Object dummy){
+
+           org.apache.axis2.om.OMFactory factory = org.apache.axis2.om.OMAbstractFactory.getOMFactory();
+           org.apache.axis2.om.OMNamespace defNamespace = factory.createOMNamespace("",null);
+           return org.apache.axis2.om.OMAbstractFactory.getOMFactory().createOMElement("test",defNamespace);
+
+
+        }
+    </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file

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=360252&r1=360251&r2=360252&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
Fri Dec 30 21:59:39 2005
@@ -17,6 +17,7 @@
 
 
     private static String dbSupporterTemplateName;
+    private static String testObjectTemplateName;
     private static String[] extensionClassNames;
     private static String[] thirdPartySchemaNames;
     private static String[] languageTypes;
@@ -38,6 +39,9 @@
     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";
+    private static final String DATA_BINDING_TEST_OBJECT_TEMPLATE_NAME_KEY = "codegen.databinding.testobject.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 */
@@ -104,6 +108,8 @@
             //the db supporter template name
             dbSupporterTemplateName = props.getProperty(DATA_BINDING_TEMPLATE_NAME_KEY);
 
+            testObjectTemplateName = props.getProperty(DATA_BINDING_TEST_OBJECT_TEMPLATE_NAME_KEY);
+
 
 
             //load the language names
@@ -161,6 +167,21 @@
         }
 
     }
+
+    /**
+     * Get the test object support template. this is used in the
+     * generated test class
+     * @return
+     */
+    public static String getTestObjectTemplateName() {
+        return testObjectTemplateName;
+    }
+
+    /**
+     * The databinder template. This is the template that has the
+     * logic for creating the databind supporters
+     * @return
+     */
     public static String getDbSupporterTemplateName() {
         return dbSupporterTemplateName;
     }



Mime
View raw message