axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/wsdl/fromJava Emitter.java Types.java
Date Sun, 13 Jul 2003 15:07:11 GMT
gdaniels    2003/07/13 08:07:11

  Modified:    java/src/org/apache/axis/encoding/ser MapSerializer.java
                        SimpleSerializer.java VectorSerializer.java
               java/src/org/apache/axis/wsdl/fromJava Emitter.java
                        Types.java
  Log:
  Fix build.  Refactor writeSchemaElement() into writeSchemaTypeDecl()
  and writeSchemaElementDecl(), which know the difference between
  types and elements.  Oh yeah, and stop writing top-level element
  declarations every time we write a type - why were we doing that?
  
  As I was looking through the code I noticed that
  we're actually already keeping track of element declarations, but we
  weren't in any way checking for duplicates - add to that the fact that
  the code in here is complex and twisted, and that's why I added the new
  Set to take care of the immediate problem.  This system desperately
  needs major cleaning up and refactoring, and will be MUCH nicer
  once we have some kind of schema manipulation API.  Anyway,
  this works for now.
  
  Revision  Changes    Path
  1.23      +2 -1      xml-axis/java/src/org/apache/axis/encoding/ser/MapSerializer.java
  
  Index: MapSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/MapSerializer.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- MapSerializer.java	22 Apr 2003 19:34:30 -0000	1.22
  +++ MapSerializer.java	13 Jul 2003 15:07:11 -0000	1.23
  @@ -89,6 +89,7 @@
       private static final QName QNAME_KEY = new QName("","key");
       private static final QName QNAME_ITEM = new QName("", "item");
       private static final QName QNAME_VALUE = new QName("", "value");
  +    private static final QName QNAME_ITEMTYPE = new QName(Constants.NS_URI_XMLSOAP, "item");
   
   
       /** Serialize a Map
        *
  @@ -178,7 +179,7 @@
           element3.setAttribute("nillable", "true");
           element3.setAttribute("type", "xsd:string");
           seq2.appendChild(element3);
  -        types.writeSchemaElement(Constants.SOAP_MAP, itemType);
  +        types.writeSchemaTypeDecl(QNAME_ITEMTYPE, itemType);
   
           return complexType;
       }
  
  
  
  1.33      +1 -1      xml-axis/java/src/org/apache/axis/encoding/ser/SimpleSerializer.java
  
  Index: SimpleSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/SimpleSerializer.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- SimpleSerializer.java	22 Apr 2003 19:34:30 -0000	1.32
  +++ SimpleSerializer.java	13 Jul 2003 15:07:11 -0000	1.33
  @@ -251,7 +251,7 @@
   
           // ComplexType representation of SimpleType bean class
           Element complexType = types.createElement("complexType");
  -        types.writeSchemaElement(xmlType, complexType);
  +        types.writeSchemaTypeDecl(xmlType, complexType);
           complexType.setAttribute("name", xmlType.getLocalPart());
   
           // Produce simpleContent extending base type.
  
  
  
  1.19      +1 -1      xml-axis/java/src/org/apache/axis/encoding/ser/VectorSerializer.java
  
  Index: VectorSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/VectorSerializer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- VectorSerializer.java	22 Apr 2003 19:34:31 -0000	1.18
  +++ VectorSerializer.java	13 Jul 2003 15:07:11 -0000	1.19
  @@ -154,7 +154,7 @@
       public Element writeSchema(Class javaType, Types types) throws Exception {
           Element complexType = types.createElement("complexType");
           complexType.setAttribute("name", "Vector");
  -        types.writeSchemaElement(Constants.SOAP_VECTOR, complexType);
  +        types.writeSchemaTypeDecl(Constants.SOAP_VECTOR, complexType);
           Element seq = types.createElement("sequence");
           complexType.appendChild(seq);
   
  
  
  
  1.96      +2 -2      xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
  retrieving revision 1.95
  retrieving revision 1.96
  diff -u -r1.95 -r1.96
  --- Emitter.java	11 Jul 2003 12:59:19 -0000	1.95
  +++ Emitter.java	13 Jul 2003 15:07:11 -0000	1.96
  @@ -1121,7 +1121,7 @@
                                                    Object.class,
                                                    Constants.XSD_ANYTYPE,
                                                    false, false);
  -            types.writeSchemaElement(qname, el);
  +            types.writeSchemaTypeDecl(qname, el);
               
               Part part = def.createPart();
               part.setName("part");
  @@ -1401,7 +1401,7 @@
                                                    param.getJavaType(),
                                                    param.getTypeQName(),
                                                    false, false);
  -            types.writeSchemaElement(qname, el);
  +            types.writeSchemaElementDecl(qname, el);
               
               part.setName(param.getName());
               part.setElementName(qname);
  
  
  
  1.79      +45 -32    xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
  
  Index: Types.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
  retrieving revision 1.78
  retrieving revision 1.79
  diff -u -r1.78 -r1.79
  --- Types.java	13 Jul 2003 06:28:57 -0000	1.78
  +++ Types.java	13 Jul 2003 15:07:11 -0000	1.79
  @@ -128,7 +128,7 @@
       ServiceDesc serviceDesc = null;
       
       /** Keep track of the element QNames we've written to avoid dups */
  -    private Set writtenQNames = new HashSet();
  +    private Set writtenElementQNames = new HashSet();
   
       /**
        * This class serailizes a <code>Class</code> to XML Schema. The constructor
  @@ -435,11 +435,11 @@
           }
   
           // Write the namespace definition for the wrapper
  -        writeTypeNamespace(qname);
  +        writeTypeNamespace(qname.getNamespaceURI());
           
           // Create an <element> for the wrapper
           Element wrapperElement = docHolder.createElement("element");
  -        writeSchemaElement(qname, wrapperElement);
  +        writeSchemaElementDecl(qname, wrapperElement);
           wrapperElement.setAttribute("name", qname.getLocalPart());
   
           // Create an anonymous <complexType> for the wrapper
  @@ -515,9 +515,9 @@
   
           String elementType = writeType(type, qName);
           if (elementType != null) {
  -            Element element = createElementDecl(qName.getLocalPart(), type, qName, isNullable(type),
false);
  -            if (element != null)
  -                writeSchemaElement(typeQName,element);
  +//            Element element = createElementDecl(qName.getLocalPart(), type, qName, isNullable(type),
false);
  +//            if (element != null)
  +//                writeSchemaElement(typeQName,element);
               return qName;
           }
           return null;
  @@ -535,21 +535,21 @@
           if (qName == null) {
               qName = getTypeQName(type);
           }
  -        writeTypeNamespace(qName);
  +        writeTypeNamespace(qName.getNamespaceURI());
           return qName;
       }
   
       /**
        * write out the namespace declaration.
        *
  -     * @param qName qname of the type
  +     * @param namespaceURI qname of the type
        */
  -    private void writeTypeNamespace(QName qName) {
  -        if (qName != null && !qName.getNamespaceURI().equals("")) {
  -            String pref = def.getPrefix(qName.getNamespaceURI());
  +    private void writeTypeNamespace(String namespaceURI) {
  +        if (namespaceURI != null && !namespaceURI.equals("")) {
  +            String pref = def.getPrefix(namespaceURI);
               if (pref == null)
  -                def.addNamespace(namespaces.getCreatePrefix(qName.getNamespaceURI()),
  -                                 qName.getNamespaceURI());
  +                def.addNamespace(namespaces.getCreatePrefix(namespaceURI),
  +                                 namespaceURI);
   
           }
       }
  @@ -664,22 +664,35 @@
           else
               return full.substring(full.lastIndexOf('.')+1) + end;
       }
  +    
  +    public void writeSchemaTypeDecl(QName qname, Element element)
  +            throws AxisFault
  +    {
  +        writeSchemaElement(qname.getNamespaceURI(), element);        
  +    }
  +    
  +    public void writeSchemaElementDecl(QName qname, Element element)
  +            throws AxisFault
  +    {
  +        if (writtenElementQNames.contains(qname)) {
  +            throw new AxisFault(Constants.FAULT_SERVER_GENERAL,
  +                                Messages.getMessage("duplicateSchemaElement",
  +                                                    qname.toString()),
  +                                null, null);
  +        }
  +        writeSchemaElement(qname.getNamespaceURI(), element);
  +        writtenElementQNames.add(qname);        
  +    }
   
       /**
        * Write out the given Element into the appropriate schema node.
        * If need be create the schema node as well
        *
  -     * @param qName qName to get the namespace of the schema node
  +     * @param namespaceURI namespace this node should get dropped into
        * @param element the Element to append to the Schema node
        */
  -    public void writeSchemaElement(QName qName, Element element) 
  +    public void writeSchemaElement(String namespaceURI, Element element) 
           throws AxisFault {
  -        if (writtenQNames.contains(qName)) {
  -            throw new AxisFault(Constants.FAULT_SERVER_GENERAL,
  -                                Messages.getMessage("duplicateSchemaElement",
  -                                                    qName.toString()),
  -                                null, null);
  -        }
           if (wsdlTypesElem == null) {
               try {
                   writeWsdlTypesElement();
  @@ -688,11 +701,10 @@
                   return;
               }
           }
  -        String namespaceURI = qName.getNamespaceURI();
           if (namespaceURI == null || namespaceURI.equals("")) {
               throw new AxisFault(Constants.FAULT_SERVER_GENERAL,
                                   Messages.getMessage("noNamespace00",
  -                                                    qName.toString()),
  +                                                    namespaceURI),
                                   null, null);
           }
   
  @@ -722,10 +734,9 @@
                   importElem.setAttribute("namespace", Constants.URI_DEFAULT_SOAP_ENC);
               }
               
  -            writeTypeNamespace(qName);
  +            writeTypeNamespace(namespaceURI);
           }
           schemaElem.appendChild(element);
  -        writtenQNames.add(qName);
       }
   
       /**
  @@ -1032,21 +1043,23 @@
        */
       private boolean addToTypesList (QName qName) {
           boolean added = false;
  -        ArrayList types = (ArrayList)schemaTypes.get(qName.getNamespaceURI());
  +
  +        String namespaceURI = qName.getNamespaceURI();
  +        ArrayList types = (ArrayList)schemaTypes.get(namespaceURI);
   
           // Quick return if schema type (will never add these ourselves)
  -        if (Constants.isSchemaXSD(qName.getNamespaceURI()) ||
  -                (Constants.isSOAP_ENC(qName.getNamespaceURI()) &&
  +        if (Constants.isSchemaXSD(namespaceURI) ||
  +                (Constants.isSOAP_ENC(namespaceURI) &&
                         !"Array".equals(qName.getLocalPart()))) {
               // Make sure we do have the namespace declared, though...
  -            writeTypeNamespace(qName);
  +            writeTypeNamespace(namespaceURI);
               return false;
           }
   
           if (types == null) {
               types = new ArrayList();
               types.add(qName.getLocalPart());
  -            schemaTypes.put(qName.getNamespaceURI(), types);
  +            schemaTypes.put(namespaceURI, types);
               added = true;
           }
           else {
  @@ -1059,7 +1072,7 @@
           // If addded, look at the namespace uri to see if the schema element should be
           // generated.
           if (added) {
  -            String prefix = namespaces.getCreatePrefix(qName.getNamespaceURI());
  +            String prefix = namespaces.getCreatePrefix(namespaceURI);
               if (prefix.equals(Constants.NS_PREFIX_SOAP_ENV) ||
                   prefix.equals(Constants.NS_PREFIX_SOAP_ENC) ||
                   prefix.equals(Constants.NS_PREFIX_SCHEMA_XSD) ||
  @@ -1383,7 +1396,7 @@
                   typeEl.setAttribute("name", qName.getLocalPart());
   
                   // Write the type in the appropriate <schema>
  -                writeSchemaElement(qName, typeEl);
  +                writeSchemaTypeDecl(qName, typeEl);
               }
   
               if (containingElement != null)
  
  
  

Mime
View raw message