axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r510430 - in /webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema: ExtensionUtility.java template/ADBDatabindingTemplate.xsl
Date Thu, 22 Feb 2007 07:10:02 GMT
Author: amilas
Date: Wed Feb 21 23:10:02 2007
New Revision: 510430

URL: http://svn.apache.org/viewvc?view=rev&rev=510430
Log:
Add unwrapping support

Modified:
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
    webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java?view=diff&rev=510430&r1=510429&r2=510430
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/ExtensionUtility.java
Wed Feb 21 23:10:02 2007
@@ -137,7 +137,17 @@
                             WSDLConstants.MESSAGE_LABEL_IN_VALUE),
                             mapper,
                             schemaMap,
-                            op.getName().getLocalPart());
+                            op.getName().getLocalPart(),
+                            WSDLConstants.INPUT_PART_QNAME_SUFFIX);
+                }
+
+                if (WSDLUtil.isOutputPresentForMEP(op.getMessageExchangePattern())) {
+                    walkSchema(op.getMessage(
+                            WSDLConstants.MESSAGE_LABEL_OUT_VALUE),
+                            mapper,
+                            schemaMap,
+                            op.getName().getLocalPart(),
+                            WSDLConstants.OUTPUT_PART_QNAME_SUFFIX);
                 }
 
 
@@ -211,27 +221,36 @@
     private static void walkSchema(AxisMessage message,
                                    TypeMapper mapper,
                                    Map schemaMap,
-                                   String opName) {
+                                   String opName,
+                                   String qnameSuffix) {
 
         if (message.getParameter(Constants.UNWRAPPED_KEY) != null) {
             XmlSchemaType schemaType = message.getSchemaElement().getSchemaType();
             //create a type mapper
-            processXMLSchemaComplexType(schemaType, mapper, opName, schemaMap);
+            processXMLSchemaComplexType(schemaType, mapper, opName, schemaMap, qnameSuffix);
         }
     }
 
-    private static void processXMLSchemaComplexType(XmlSchemaType schemaType, TypeMapper
mapper, String opName, Map schemaMap) {
+    private static void processXMLSchemaComplexType(XmlSchemaType schemaType,
+                                                    TypeMapper mapper,
+                                                    String opName,
+                                                    Map schemaMap,
+                                                    String qnameSuffix) {
         if (schemaType instanceof XmlSchemaComplexType) {
             XmlSchemaComplexType cmplxType = (XmlSchemaComplexType) schemaType;
             if (cmplxType.getContentModel() == null) {
-                processSchemaSequence(cmplxType.getParticle(), mapper, opName, schemaMap);
+                processSchemaSequence(cmplxType.getParticle(), mapper, opName, schemaMap,
qnameSuffix);
             } else {
-                processComplexContentModel(cmplxType, mapper, opName, schemaMap);
+                processComplexContentModel(cmplxType, mapper, opName, schemaMap, qnameSuffix);
             }
         }
     }
 
-    private static void processComplexContentModel(XmlSchemaComplexType cmplxType, TypeMapper
mapper, String opName, Map schemaMap) {
+    private static void processComplexContentModel(XmlSchemaComplexType cmplxType,
+                                                   TypeMapper mapper,
+                                                   String opName,
+                                                   Map schemaMap,
+                                                   String qnameSuffix) {
         XmlSchemaContentModel contentModel = cmplxType.getContentModel();
         if (contentModel instanceof XmlSchemaComplexContent) {
             XmlSchemaComplexContent xmlSchemaComplexContent = (XmlSchemaComplexContent) contentModel;
@@ -240,7 +259,7 @@
                 XmlSchemaComplexContentExtension schemaExtension = (XmlSchemaComplexContentExtension)
content;
 
                 // process particles inside this extension, if any
-                processSchemaSequence(schemaExtension.getParticle(), mapper, opName, schemaMap);
+                processSchemaSequence(schemaExtension.getParticle(), mapper, opName, schemaMap,
qnameSuffix);
 
                 // now we need to get the schema of the extension type from the parent schema.
For that let's first retrieve
                 // the parent schema
@@ -250,12 +269,16 @@
 
                 XmlSchemaType extensionSchemaType = parentSchema.getTypeByName(schemaExtension.getBaseTypeName());
 
-                processXMLSchemaComplexType(extensionSchemaType, mapper, opName, schemaMap);
+                processXMLSchemaComplexType(extensionSchemaType, mapper, opName, schemaMap,
qnameSuffix);
             }
         }
     }
 
-    private static void processSchemaSequence(XmlSchemaParticle particle, TypeMapper mapper,
String opName, Map schemaMap) {
+    private static void processSchemaSequence(XmlSchemaParticle particle,
+                                              TypeMapper mapper,
+                                              String opName,
+                                              Map schemaMap,
+                                              String qnameSuffix) {
         if (particle instanceof XmlSchemaSequence) {
             XmlSchemaObjectCollection items =
                     ((XmlSchemaSequence) particle).getItems();
@@ -270,7 +293,7 @@
                     XmlSchemaType eltSchemaType = xmlSchemaElement.getSchemaType();
                     if (eltSchemaType != null) {
                         //there is a schema type object.We can utilize that
-                        populateClassName(eltSchemaType, mapper, opName, xmlSchemaElement);
+                        populateClassName(eltSchemaType, mapper, opName, xmlSchemaElement,
qnameSuffix);
                     } else if (xmlSchemaElement.getSchemaTypeName() != null) {
                         //there is no schema type object but there is a
                         //schema type QName.  Use that Qname to look up the
@@ -278,10 +301,10 @@
                         eltSchemaType = findSchemaType(schemaMap,
                                 xmlSchemaElement.getSchemaTypeName());
                         if (eltSchemaType != null) {
-                            populateClassName(eltSchemaType, mapper, opName, xmlSchemaElement);
+                            populateClassName(eltSchemaType, mapper, opName, xmlSchemaElement,
qnameSuffix);
                         } else if (xmlSchemaElement.getSchemaTypeName().equals(SchemaConstants.XSD_ANYTYPE))
{
                             QName partQName = WSDLUtil.getPartQName(opName,
-                                    WSDLConstants.INPUT_PART_QNAME_SUFFIX,
+                                    qnameSuffix,
                                     xmlSchemaElement.getName());
 
                             if (xmlSchemaElement.getMaxOccurs() > 1) {
@@ -300,7 +323,7 @@
                     XmlSchemaAny xmlSchemaAny = (XmlSchemaAny) item;
 
                     QName partQName = WSDLUtil.getPartQName(opName,
-                            WSDLConstants.INPUT_PART_QNAME_SUFFIX,
+                            qnameSuffix,
                             Constants.ANY_ELEMENT_FIELD_NAME);
 
                     if (((XmlSchemaAny) item).getMaxOccurs() > 1) {
@@ -326,7 +349,8 @@
     private static void  populateClassName(XmlSchemaType eltSchemaType,
                                           TypeMapper typeMap,
                                           String opName,
-                                          XmlSchemaElement xmlSchemaElement) {
+                                          XmlSchemaElement xmlSchemaElement,
+                                          String qnameSuffix) {
 
         boolean isArray = xmlSchemaElement.getMaxOccurs() > 1;
 
@@ -348,7 +372,7 @@
 
 
             QName partQName = WSDLUtil.getPartQName(opName,
-                    WSDLConstants.INPUT_PART_QNAME_SUFFIX,
+                    qnameSuffix,
                     xmlSchemaElement.getName());
             typeMap.addTypeMappingName(partQName, className);
             if (Boolean.TRUE.equals(

Modified: webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl?view=diff&rev=510430&r1=510429&r2=510430
==============================================================================
--- webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBDatabindingTemplate.xsl
Wed Feb 21 23:10:02 2007
@@ -3,6 +3,7 @@
     <xsl:key name="paramsIn" match="//databinders/param[@direction='in']" use="@type"/>
     <xsl:key name="paramsOut" match="//databinders/param[@direction='out']" use="@type"/>
     <xsl:key name="innerParams" match="//databinders/param[@direction='in']/param" use="@partname"/>
+    <xsl:key name="innerOutParams" match="//databinders/param[@direction='out']/param"
use="@partname"/>
     <!--<xsl:key name="paramsType" match="//databinders/param[@direction='in']" use="@type"/>-->
 
     <!-- #################################################################################
 -->
@@ -126,6 +127,7 @@
                                 <xsl:value-of select="$inputElementType"/> wrappedType){
                                     return wrappedType.get<xsl:value-of select="$inputElementShortType"/>();
                                 }
+
                                 private <xsl:value-of select="$inputElementType"/>
wrap<xsl:value-of select="$opname"/>(
                                 <xsl:value-of select="$inputElementComplexType"/> innerType){
                                     <xsl:value-of select="$inputElementType"/> wrappedElement
= new <xsl:value-of select="$inputElementType"/>();
@@ -148,18 +150,45 @@
                         <xsl:variable name="outputElementShortType" select="../../param[@type!=''
and @direction='out' and @opname=$opname]/@shorttype"></xsl:variable>
                         <xsl:variable name="outputElementComplexType" select="../../param[@type!=''
and @direction='out' and @opname=$opname]/@complextype"></xsl:variable>
 
+                        <xsl:for-each select="../../param[@type!='' and @direction='out'
and @opname=$opname]/param">
+
+                            <xsl:variable name="paramElement" select="."></xsl:variable>
+                            <xsl:variable name="partName" select="@partname"></xsl:variable>
+
+                            <xsl:if test="(generate-id($paramElement) = generate-id(key('innerOutParams',
$partName)[1])) or
+                                (generate-id($outputElement) = generate-id(key('paramsOut',
$outputElementType)[1]))">
+
+                                <!-- we put the out element type to the method signature
to make it unique -->
+                                private <xsl:value-of select="@type"/> get<xsl:value-of
select="$outputElementShortType"/><xsl:value-of select="@partname"/>(
+                                <xsl:value-of select="$outputElementType"/> wrappedType){
+                                <xsl:choose>
+                                    <xsl:when test="string-length(normalize-space($outputElementComplexType))
> 0">
+                                        return wrappedType.get<xsl:value-of select="$outputElementShortType"/>().get<xsl:value-of
select="@partname"/>();
+                                    </xsl:when>
+                                    <xsl:otherwise>
+                                        return wrappedType.get<xsl:value-of select="@partname"/>();
+                                    </xsl:otherwise>
+                                </xsl:choose>
+                                }
+                             </xsl:if>
+                        </xsl:for-each>
+
                         <xsl:if test="generate-id($outputElement) = generate-id(key('paramsOut',
$outputElementType)[1])">
                             <xsl:if test="string-length(normalize-space($outputElementComplexType))
> 0">
+
                                 private <xsl:value-of select="$outputElementComplexType"/>
get<xsl:value-of select="$opname"/>(
                                 <xsl:value-of select="$outputElementType"/> wrappedType){
                                     return wrappedType.get<xsl:value-of select="$outputElementShortType"/>();
                                 }
+
+                                <!-- in client side we donot have to wrap the out put
messages -->
+                                <!--
                                 private <xsl:value-of select="$outputElementType"/>
wrap<xsl:value-of select="$opname"/>(
                                 <xsl:value-of select="$outputElementComplexType"/>
innerType){
                                     <xsl:value-of select="$outputElementType"/> wrappedElement
= new <xsl:value-of select="$outputElementType"/>();
                                     wrappedElement.set<xsl:value-of select="$outputElementShortType"/>(innerType);
                                     return wrappedElement;
-                                }
+                                } -->
                             </xsl:if>
                         </xsl:if>
                   </xsl:if>
@@ -227,12 +256,14 @@
                         <xsl:value-of select="$inputElementType"/> wrappedType){
                             return wrappedType.get<xsl:value-of select="$inputElementShortType"/>();
                         }
+                        <!-- in server side we do not want to wrap input elements -->
+                        <!--
                         private <xsl:value-of select="$inputElementType"/> wrap<xsl:value-of
select="$opname"/>(
                         <xsl:value-of select="$inputElementComplexType"/> innerType){
                             <xsl:value-of select="$inputElementType"/> wrappedElement
= new <xsl:value-of select="$inputElementType"/>();
                             wrappedElement.set<xsl:value-of select="$inputElementShortType"/>(innerType);
                             return wrappedElement;
-                        }
+                        } -->
                     </xsl:if>
                 </xsl:if>
             </xsl:if>
@@ -244,12 +275,42 @@
             <xsl:variable name="outputElementShortType" select="../../param[@type!=''
and @direction='out' and @opname=$opname]/@shorttype"></xsl:variable>
             <xsl:variable name="outputElementComplexType" select="../../param[@type!=''
and @direction='out' and @opname=$opname]/@complextype"></xsl:variable>
 
+            <xsl:for-each select="../../param[@type!='' and @direction='out' and @opname=$opname]/param">
+
+                    <xsl:variable name="paramElement" select="."></xsl:variable>
+                    <xsl:variable name="partName" select="@partname"></xsl:variable>
+
+                    <xsl:if test="(generate-id($paramElement) = generate-id(key('innerOutParams',
$partName)[1])) or
+                        (generate-id($outputElement) = generate-id(key('paramsOut', $outputElementType)[1]))">
+
+                        <!-- we put the out element type to the method signature to make
it unique -->
+                        private <xsl:value-of select="$outputElementType"/> wrap<xsl:value-of
select="$outputElementShortType"/><xsl:value-of select="@partname"/>(
+                        <xsl:value-of select="@type"/> param){
+                        <xsl:value-of select="$outputElementType"/> wrappedElement
= new <xsl:value-of select="$outputElementType"/>();
+                        <xsl:choose>
+                            <xsl:when test="string-length(normalize-space($outputElementComplexType))
> 0">
+                                <xsl:value-of select="$outputElementComplexType"/>
innerType = new <xsl:value-of
+                                    select="$outputElementComplexType"/>();
+                                innerType.set<xsl:value-of select="@partname"/>(param);
+                                wrappedElement.set<xsl:value-of select="$outputElementShortType"/>(innerType);
+                            </xsl:when>
+                            <xsl:otherwise>
+                                wrappedElement.set<xsl:value-of select="@partname"/>(param);
+                            </xsl:otherwise>
+                        </xsl:choose>
+                            return wrappedElement;
+                        }
+                     </xsl:if>
+                </xsl:for-each>
+
             <xsl:if test="generate-id($outputElement) = generate-id(key('paramsOut', $outputElementType)[1])">
                 <xsl:if test="string-length(normalize-space($outputElementComplexType))
> 0">
+                    <!-- in server side we do not want to unwrap the output type -->
+                    <!--
                     private <xsl:value-of select="$outputElementComplexType"/> get<xsl:value-of
select="$opname"/>(
                     <xsl:value-of select="$outputElementType"/> wrappedType){
                         return wrappedType.get<xsl:value-of select="$outputElementShortType"/>();
-                    }
+                    } -->
                     private <xsl:value-of select="$outputElementType"/> wrap<xsl:value-of
select="$opname"/>(
                     <xsl:value-of select="$outputElementComplexType"/> innerType){
                         <xsl:value-of select="$outputElementType"/> wrappedElement
= new <xsl:value-of select="$outputElementType"/>();



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message