axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r367468 - in /webservices/axis2/trunk/java/modules: adb/src/org/apache/axis2/databinding/utils/ codegen/src/org/apache/axis2/schema/template/ codegen/src/org/apache/axis2/schema/writer/ codegen/src/org/apache/axis2/wsdl/template/java/ tool/...
Date Tue, 10 Jan 2006 02:56:02 GMT
Author: ajith
Date: Mon Jan  9 18:55:45 2006
New Revision: 367468

URL: http://svn.apache.org/viewcvs?rev=367468&view=rev
Log:
1. Fixed the minoccurs=0 problem by putting the relevant checks in the generated code.
2. Fixed the qualifying attribute ignoring problem for the generated code.
3. Added code to ignore header parameters if they are null
4. Updated the ant codegen task to suit the latest changes in the codegen engine.
5. Fixed a few bugs here and ther in codegen.

Modified:
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.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/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java?rev=367468&r1=367467&r2=367468&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/utils/ADBPullParser.java
Mon Jan  9 18:55:45 2006
@@ -107,6 +107,7 @@
      * remove them from the namespace map, after the end element.
      */
     private HashMap namespaceMap;
+    private static final QName NIL_QNAME = new QName("nil");
 
 
     private ADBPullParser(QName adbBeansQName, Object[] properties, Object[] attributes)
{
@@ -146,24 +147,24 @@
      *                  ---------------------------------------------------------------------------------------------------
      *                  This DependentObject can either be an ADBBean, OMElement or a POJO.
If its an ADBBean
      *                  We directly get the pull parser from that. If not we create a reflection
based
-                        pull parser for that java bean.
+    pull parser for that java bean.
 
-                        <p/>
+    <p/>
      *                   <p/>
-                        This is the how the passed array should look like
+    This is the how the passed array should look like
      *                           Key             Value
      *                         String          String
      *                         QName           ADBBean, OMElement, Bean, String
-                               String          String[]
-                               QName           Object[] - this contains only one type of
objects
+    String          String[]
+    QName           Object[] - this contains only one type of objects
      *                   <p/>
      *                   <p/>
-                       This is how the passed attribute array should look like
-                                Key             Value
-                               null            OMAttribute[]
-                               QName           String
-                               String          String
-                  </pre>
+    This is how the passed attribute array should look like
+    Key             Value
+    null            OMAttribute[]
+    QName           String
+    String          String
+    </pre>
      * @return XMLStreamReader
      */
     public static XMLStreamReader createPullParser(QName adbBeansQName, Object[] properties,
Object[] attributes) {
@@ -302,6 +303,24 @@
                     }
                     processingADBNameValuePair = true;
                     return processADBNameValuePair(new QName(simplePropertyName), simplePropertyValue);
+                }else if (property == null){
+                    // a null value has a special resolution, it should produce an element
with nil="true" attribute and
+                    // no content
+                    //add to the attributes nil="true" to the list
+                    if (attributesList==null || attributesList.size()==0){
+                        attributesList = new ArrayList();
+                        attributesList.add(NIL_QNAME);
+                        attributesList.add("true");
+                    }else{
+                        //since we append the nil attribute at the end, check the nil attrib
at the end
+                        //if it's already there, move on
+                        if (!attributesList.contains(NIL_QNAME)){
+                            attributesList.add(NIL_QNAME);
+                            attributesList.add("true");
+                        }
+                    }
+                    processingADBNameValuePair = true;
+                    return processADBNameValuePair(new QName(simplePropertyName), null);
                 }
                 throw new XMLStreamException("Only String and String[] are accepted as the
values when the key is a String");
             } else {
@@ -313,11 +332,11 @@
 
     private void removeDeclaredNamespaces() {
         if(declaredNamespaces != null){
-        Iterator declaredNamespacesURIIter = declaredNamespaces.keySet().iterator();
-        while (declaredNamespacesURIIter.hasNext()) {
-            String s = (String) declaredNamespacesURIIter.next();
-            namespaceMap.remove(s);
-        }
+            Iterator declaredNamespacesURIIter = declaredNamespaces.keySet().iterator();
+            while (declaredNamespacesURIIter.hasNext()) {
+                String s = (String) declaredNamespacesURIIter.next();
+                namespaceMap.remove(s);
+            }
         }
     }
 
@@ -695,6 +714,10 @@
             parserInformation = new ParserInformation(simplePropertyName, simplePropertyValue);
             nameValuePairStartElementProcessed = true;
             finishedProcessingNameValuePair = false;
+            //Forcibly set nameValuePairTextProcessed to avoid a character event
+            if (simplePropertyValue==null){
+                nameValuePairTextProcessed=true;
+            }
         } else if (nameValuePairStartElementProcessed && !nameValuePairTextProcessed)
{
             event = XMLStreamConstants.CHARACTERS;
             nameValuePairTextProcessed = true;

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?rev=367468&r1=367467&r2=367468&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
Mon Jan  9 18:55:45 2006
@@ -70,21 +70,31 @@
             <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>
             <xsl:variable name="javaName"><xsl:value-of select="@javaname"></xsl:value-of></xsl:variable>
+            <xsl:variable name="min"><xsl:value-of select="@minOccurs"/></xsl:variable>
             <xsl:variable name="varName">local<xsl:value-of select="$javaName"/></xsl:variable>
+            <xsl:variable name="settingTracker">local<xsl:value-of select="$javaName"/>Tracker</xsl:variable>
             /**
             * field for <xsl:value-of select="$javaName"/>
             <xsl:if test="@attribute">* This was an Attribute!</xsl:if>
             <xsl:if test="@array">* This was an Array!</xsl:if>
-
             */
             private <xsl:value-of select="$propertyType"/><xsl:text> </xsl:text><xsl:value-of
select="$varName" /> ;
+            <!-- Generate a tracker only if the min occurs is zero, which means if the
user does
+                 not bother to set that value, we do not send it -->
+            <xsl:if test="$min=0">
+            /*  This tracker boolean wil be used to detect whether the user called the set
method
+                for this attribute. It will be used to determine whether to include this
field
+                in the serialized XML
+            */
+            private boolean <xsl:value-of select="$settingTracker"/> = false ;
+            </xsl:if>
 
             /**
             * 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="$javaName"/>(){
-            return <xsl:value-of select="$varName"/>;
+                return <xsl:value-of select="$varName"/>;
             }
 
             /**
@@ -105,6 +115,10 @@
                     }
                 </xsl:if>
             </xsl:if>
+             <xsl:if test="$min=0">
+             //update the setting tracker
+             <xsl:value-of select="$settingTracker"/> = true;
+             </xsl:if>
             this.<xsl:value-of select="$varName"/>=param;
             }
         </xsl:for-each>
@@ -114,46 +128,59 @@
         *
         */
         public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName){
+
+
         <xsl:choose>
             <xsl:when test="@type|@anon">
-                Object[] elementList = new Object[]{
+                 java.util.ArrayList elementList = new java.util.ArrayList();
+                 java.util.ArrayList attribList = new java.util.ArrayList();
+
                 <xsl:for-each select="property[not(@attribute)]">
                     <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
                     <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
+                    <xsl:variable name="min"><xsl:value-of select="@minOccurs"/></xsl:variable>
+                    <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
+                    <xsl:variable name="settingTracker">local<xsl:value-of select="@javaname"/>Tracker</xsl:variable>
 
-                    <xsl:if test="position()>1">,</xsl:if>
+
+                    <xsl:if test="$min=0"> if (<xsl:value-of select="$settingTracker"/>){</xsl:if>
                     <xsl:choose>
-                        <xsl:when test="@ours">
-                            new javax.xml.namespace.QName("<xsl:value-of select="$propertyName"/>"),<xsl:value-of
select="$varName"/>
-                        </xsl:when>
-                        <xsl:when test="@any">
-                            new javax.xml.namespace.QName("<xsl:value-of select="$propertyName"/>"),<xsl:value-of
select="$varName"/>
+                        <xsl:when test="@ours or @any">
+                            elementList.add(new javax.xml.namespace.QName("<xsl:value-of
select="$namespace"/>",
+                                                                      "<xsl:value-of select="$propertyName"/>"));
+                            elementList.add(<xsl:value-of select="$varName"/>);
                         </xsl:when>
                         <xsl:when test="@array">
-                            "<xsl:value-of select="$propertyName"/>",<xsl:value-of
select="$varName"/>
+                            elementList.add("<xsl:value-of select="$propertyName"/>");
+                            elementList.add(<xsl:value-of select="$varName"/>);
                         </xsl:when>
                         <xsl:otherwise>
-                            "<xsl:value-of select="$propertyName"/>",org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of
select="$varName"/>)
+                             elementList.add(new javax.xml.namespace.QName("<xsl:value-of
select="$namespace"/>",
+                                                                      "<xsl:value-of select="$propertyName"/>"));
+                             elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of
select="$varName"/>));
                         </xsl:otherwise>
                     </xsl:choose>
-                </xsl:for-each>};
+                    <xsl:if test="$min=0">}</xsl:if>
+                </xsl:for-each>
 
-                Object[] attribList = new Object[]{
                 <xsl:for-each select="property[@attribute]">
                     <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
                     <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
+                     <xsl:variable name="namespace"><xsl:value-of select="@nsuri"/></xsl:variable>
                     <xsl:if test="position()>1">,</xsl:if>
                     <xsl:choose>
                         <xsl:when test="@anyAtt">
-                            null,<xsl:value-of select="$varName"/>
+                            attribList.add(null);
+                            attribList.add(<xsl:value-of select="$varName"/>);
                         </xsl:when>
                         <xsl:otherwise>
-                            new javax.xml.namespace.QName("<xsl:value-of select="$propertyName"/>"),org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of
select="$varName"/>)
+                            attribList.add(new javax.xml.namespace.QName("<xsl:value-of
select="$namespace"/>","<xsl:value-of select="$propertyName"/>"));
+                            attribList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of
select="$varName"/>));
                         </xsl:otherwise>
                     </xsl:choose>
                 </xsl:for-each>
-                };
-                return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName,
elementList, attribList);
+
+                return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(qName,
elementList.toArray(), attribList.toArray());
             </xsl:when>
             <xsl:otherwise>
                 <!-- if the element is associated with a type, then its gonna be only
one -->
@@ -167,7 +194,6 @@
 
                 <!-- What do we do for the other case ???? -->
                 <xsl:for-each select="property[not(@ours)]">
-                    <xsl:variable name="propertyName"><xsl:value-of select="@name"/></xsl:variable>
                     <xsl:variable name="varName">local<xsl:value-of select="@javaname"/></xsl:variable>
                     return org.apache.axis2.databinding.utils.ADBPullParser.createPullParser(MY_QNAME,
                     new Object[]{

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=367468&r1=367467&r2=367468&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
(original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
Mon Jan  9 18:55:45 2006
@@ -137,7 +137,7 @@
 
         try {
             QName qName = element.getQName();
-           
+
             return process(qName, metainf, typeMap, true);
         } catch (Exception e) {
             throw new SchemaCompilationException(e);
@@ -179,7 +179,7 @@
             if (wrapClasses) {
                 String tempPackage ;
                 if (packageName==null){
-                   tempPackage = DEFAULT_PACKAGE;
+                    tempPackage = DEFAULT_PACKAGE;
                 }else{
                     tempPackage = packageName;
                 }
@@ -279,7 +279,9 @@
             }
 
             //add the model to the model map
-            modelMap.put(qName,model);
+            modelMap.put(
+                    new QName(qName.getNamespaceURI(),className)
+                    ,model);
 
 
         }
@@ -354,10 +356,10 @@
             name = qNames[i];
             String xmlName = name.getLocalPart();
             XSLTUtils.addAttribute(model, "name", xmlName, property);
-
+            XSLTUtils.addAttribute(model, "nsuri", name.getNamespaceURI(), property);
             String javaName = makeUniqueJavaClassName(propertyNames, xmlName);
-            XSLTUtils.addAttribute(model, "name", xmlName, property);
             XSLTUtils.addAttribute(model, "javaname", javaName, property);
+
             String javaClassNameForElement = metainf.getClassNameForQName(name);
 
             String shortTypeName = "";
@@ -386,6 +388,12 @@
             if (metainf.getAnyAttributeStatusForQName(name)) {
                 XSLTUtils.addAttribute(model, "anyAtt", "yes", property);
             }
+
+            //put the min occurs count irrespective of whether it's an array or not
+            long minOccurs = metainf.getMinOccurs(name);
+            XSLTUtils.addAttribute(model, "minOccurs", minOccurs + "", property);
+
+            
             if (metainf.getArrayStatusForQName(name)) {
 
                 XSLTUtils.addAttribute(model, "array", "yes", property);
@@ -395,13 +403,6 @@
                         javaClassNameForElement.substring(0, javaClassNameForElement.indexOf("[")),
                         property);
 
-
-                long minOccurs = metainf.getMinOccurs(name);
-
-                if (minOccurs > 0) {
-                    XSLTUtils.addAttribute(model, "minOccurs", minOccurs + "", property);
-                }
-
                 long maxOccurs = metainf.getMaxOccurs(name);
                 if (maxOccurs == Long.MAX_VALUE) {
                     XSLTUtils.addAttribute(model, "unbound", "yes", property);
@@ -411,6 +412,9 @@
             }
         }
 
+        /////////////////////////////////////
+//        System.out.println("rootElt = " + rootElt);
+        /////////////////////////////////////
         return rootElt;
     }
 

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=367468&r1=367467&r2=367468&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
Mon Jan  9 18:55:45 2006
@@ -110,7 +110,7 @@
                     private  org.apache.axis2.soap.SOAPEnvelope toEnvelope(org.apache.axis2.soap.SOAPFactory
factory, <xsl:value-of select="@type"/> param){
                         if (param instanceof org.apache.axis2.databinding.ADBBean){
                             org.apache.axis2.databinding.ADBSOAPModelBuilder builder = new
-                                    org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(param.MY_QNAME),
+                                    org.apache.axis2.databinding.ADBSOAPModelBuilder(param.getPullParser(<xsl:value-of
select="@type"/>.MY_QNAME),
                                                                                      factory);
                             return builder.getEnvelope();
                         }else{

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=367468&r1=367467&r2=367468&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
Mon Jan  9 18:55:45 2006
@@ -146,7 +146,10 @@
                                         env = toEnvelope(getFactory(_options.getSoapVersionURI()),
<xsl:value-of select="@name"/>);
                                     </xsl:for-each>
                                     <xsl:for-each select="input/param[@location='header']">
+                                        // add the children only if the parameter is not
null
+                                        if (<xsl:value-of select="@name"/>!=null){
                                         env.getHeader().addChild(toOM(<xsl:value-of select="@name"/>));
+                                        }
                                     </xsl:for-each>
                                 </xsl:when>
                                 <xsl:otherwise>
@@ -244,7 +247,10 @@
                                         env = toEnvelope(getFactory(_options.getSoapVersionURI()),
<xsl:value-of select="@name"/>);
                                     </xsl:for-each>
                                     <xsl:for-each select="input/param[@location='header']">
-                                        env.getHeader().addChild(toOM(<xsl:value-of select="@name"/>));
+                                         // add the headers only if they are not null
+                                        if (<xsl:value-of select="@name"/>!=null){
+                                           env.getHeader().addChild(toOM(<xsl:value-of
select="@name"/>));
+                                        }
                                     </xsl:for-each>
                                 </xsl:when>
                                 <xsl:otherwise>

Modified: webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java?rev=367468&r1=367467&r2=367468&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java
(original)
+++ webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/ant/AntCodegenTask.java
Mon Jan  9 18:55:45 2006
@@ -37,6 +37,8 @@
     private String packageName = URLProcessor.DEFAULT_PACKAGE;
     private String language = ConfigPropertyFileLoader.getDefaultLanguage();
     private String databindingName=ConfigPropertyFileLoader.getDefaultDBFrameworkName();
+    private String portName=null;
+    private String serviceName=null;
 
     private boolean asyncOnly = false;
     private boolean syncOnly = false;
@@ -44,7 +46,7 @@
     private boolean testcase = false;
     private boolean generateServiceXml = false;
     private boolean generateAllClasses = false;
-    private boolean unwrapClasses = false;
+    private boolean unpackClasses = false;
 
     private Path classpath;
 
@@ -170,7 +172,7 @@
 
         //Unwrap classes option - this determines whether the generated classes are inside
the stub/MR
         //or gets generates as seperate classes
-        if (unwrapClasses) {
+        if (unpackClasses) {
             optionMap.put(
                     CommandLineOptionConstants.UNPACK_CLASSES_OPTION,
                     new CommandLineOption(
@@ -178,7 +180,17 @@
                             new String[0]));
         }
 
+        optionMap.put(
+                CommandLineOptionConstants.SERVICE_NAME_OPTION,
+                new CommandLineOption(
+                        CommandLineOptionConstants.SERVICE_NAME_OPTION,
+                        new String[]{serviceName}));
 
+        optionMap.put(
+                CommandLineOptionConstants.PORT_NAME_OPTION,
+                new CommandLineOption(
+                        CommandLineOptionConstants.PORT_NAME_OPTION,
+                        new String[]{portName}));
         return optionMap;
     }
 
@@ -220,6 +232,22 @@
             throw new BuildException(e);
         }
 
+    }
+
+    public void setPortName(String portName) {
+        this.portName = portName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public void setGenerateAllClasses(boolean generateAllClasses) {
+        this.generateAllClasses = generateAllClasses;
+    }
+
+    public void setUnpackClasses(boolean unpackClasses) {
+        this.unpackClasses = unpackClasses;
     }
 
     public void setWSDLFileName(String WSDLFileName) {



Mime
View raw message