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/message RPCElement.java RPCParam.java SOAPEnvelope.java SOAPSAXHandler.java
Date Sun, 06 May 2001 15:57:21 GMT
gdaniels    01/05/06 08:57:21

  Modified:    java/src/org/apache/axis Message.java
               java/src/org/apache/axis/encoding ArraySerializer.java
                        DeserializerBase.java
               java/src/org/apache/axis/message RPCElement.java
                        RPCParam.java SOAPEnvelope.java SOAPSAXHandler.java
  Log:
  Improvements to array serialization and ID/HREF handling.
  
  We should now hopefully be able to pass all the interop echo tests
  (including echoStructArray) even when getting results with arbitrary
  usage of id/hrefs.
  
  Some salient points about the changes:
  
  * RPCParams now process their own startElement events,
    and get pushed onto the element handler stack like anything
    else.  This is a step towards cleaning up the handler
    model, and allows us to much more simply process things
    like the type attribute on the target of an href.
  
  * Due to the above, I put in a replaceElementHandler()
    method in SOAPSAXHandler.  This lets the RPCParam
    put its deserializer at the top of the stack once it
    starts getting content, without pushing an extra level.
  
  * Create a new MessageContext in Message if we need
    one and haven't had one assigned.  This was breaking
    many of the tests that created Messages directly.
  
  * Now that the basics are almost all there, it's time for
    more tests and cleanup.
  
  Revision  Changes    Path
  1.31      +2 -0      xml-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- Message.java	2001/05/05 23:44:43	1.30
  +++ Message.java	2001/05/06 15:57:20	1.31
  @@ -331,6 +331,8 @@
       
       // ThreadedSAXAdapter parser = 
       //    new ThreadedSAXAdapter(new org.apache.xerces.parsers.SAXParser(), is);
  +    if (msgContext == null)
  +        msgContext = new MessageContext();
       SAXAdapter parser = 
           new SAXAdapter(new org.apache.xerces.parsers.SAXParser(), is, 
                          msgContext);
  
  
  
  1.3       +0 -5      xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java
  
  Index: ArraySerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArraySerializer.java	2001/05/05 18:23:55	1.2
  +++ ArraySerializer.java	2001/05/06 15:57:20	1.3
  @@ -93,8 +93,6 @@
       {
           super.startElement(namespace, localName, qName, attributes);
           
  -        System.out.println("In Array.startElement");
  -
           QName arrayTypeValue = context.getQNameFromString(
                    attributes.getValue(Constants.URI_SOAP_ENC,
                                        Constants.ATTR_ARRAY_TYPE));
  @@ -164,9 +162,6 @@
                                String qName, Attributes attributes)
           throws SAXException
       {
  -        // Array element
  -        System.out.println("In array element...");
  -        
           // !!! Check position attribute, type attribute....
           QName itemType = context.getTypeFromAttributes(attributes);
           
  
  
  
  1.6       +0 -29     xml-axis/java/src/org/apache/axis/encoding/DeserializerBase.java
  
  Index: DeserializerBase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializerBase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DeserializerBase.java	2001/05/05 13:47:12	1.5
  +++ DeserializerBase.java	2001/05/06 15:57:20	1.6
  @@ -209,35 +209,6 @@
                                String qName, Attributes attributes)
           throws SAXException
       {
  -        String href = attributes.getValue("href");
  -        if (href != null) {
  -            if (DEBUG_LOG) {
  -                System.err.println("looking for href " + href);
  -            }
  -            
  -            MessageElement target = context.getElementByID(href.substring(1));
  -            if (target != null) {
  -                if (DEBUG_LOG)
  -                    System.out.println("found target " + target);
  -                
  -                DeserializerBase rec = target.getContentHandler();
  -                if (rec == null)
  -                    throw new SAXException("No handler in target element?");
  -                
  -                if (rec instanceof ElementRecorder) {
  -                    ((ElementRecorder)rec).publishChildrenToHandler(context.getSAXHandler());
  -                } else {
  -                    this.value = rec.value;
  -                }
  -                
  -                // Might want to somehow write deserialized version
  -                // back to the IDmapping table...
  -                
  -                return;
  -            }
  -            
  -            context.addFixupHandler(href.substring(1), this);
  -        }
       }
       
       public void endElement(String namespace, String localName,
  
  
  
  1.7       +1 -18     xml-axis/java/src/org/apache/axis/message/RPCElement.java
  
  Index: RPCElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCElement.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RPCElement.java	2001/05/05 22:16:58	1.6
  +++ RPCElement.java	2001/05/06 15:57:20	1.7
  @@ -144,25 +144,8 @@
           RPCParam param = new RPCParam(namespace, name, attributes, context);
           
           params.addElement(param);
  -        if (param.getType() == null) {
  -            // No type inline, so check service description.
  -            ServiceDescription serviceDesc = context.getServiceDescription();
  -            if (serviceDesc != null) {
  -                param.setType(serviceDesc.getParamTypeByName(getEnvelope().getMessageType(),
  -                                                             param.getName()));
  -            }
  -        } else {
  -            /** !!! If we have a service description and this is an
  -            * explicitly-typed param, we might want to check here to
  -            * see if the xsi:type val is indeed a subtype of the type
  -            * we expect from the service description.
  -            */
  -            
  -        }
           
  -        DeserializerBase handler = param.getContentHandler(context);
  -        
  -        context.pushElementHandler(handler);
  +        context.pushElementHandler(param);
       }
   
       public void output(SerializationContext context)
  
  
  
  1.15      +44 -2     xml-axis/java/src/org/apache/axis/message/RPCParam.java
  
  Index: RPCParam.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCParam.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- RPCParam.java	2001/05/05 22:16:58	1.14
  +++ RPCParam.java	2001/05/06 15:57:20	1.15
  @@ -83,8 +83,6 @@
       {
           super(namespace, localName, attrs, context);
           name = localName;
  -        
  -        typeQName = context.getTypeFromAttributes(attrs);
       }
       
       /** Constructor for building up messages.
  @@ -119,8 +117,52 @@
           return super.getEnvelope();
       }
       
  +    public void startElement(String namespace, String localName,
  +                             String qName, Attributes attributes)
  +        throws SAXException
  +    {
  +        if (DEBUG_LOG) {
  +            System.err.println("Start element in RPCParam.");
  +        }
  +        typeQName = context.getTypeFromAttributes(attributes);
  +        if (typeQName == null) {
  +            // No type inline, so check service description.
  +            ServiceDescription serviceDesc = context.getServiceDescription();
  +            if (serviceDesc != null) {
  +                setType(serviceDesc.getParamTypeByName(getEnvelope().getMessageType(),
  +                                                             name));
  +            }
  +        } else {
  +            /** !!! If we have a service description and this is an
  +            * explicitly-typed param, we might want to check here to
  +            * see if the xsi:type val is indeed a subtype of the type
  +            * we expect from the service description.
  +            */
  +        }
  +        
  +        DeserializerBase dSer = getContentHandler(context);
  +        
  +        context.getSAXHandler().replaceElementHandler(dSer);
  +        
  +        dSer.startElement(namespace,localName,qName,attributes);
  +    }
  +    
       public DeserializerBase getContentHandler(DeserializationContext context)
       {
  +        // !!! Does this check want to live here?
  +        if (typeQName == null) {
  +            QName myQName = new QName(namespaceURI, name);
  +            if (myQName.equals(SOAPTypeMappingRegistry.SOAP_ARRAY)) {
  +                typeQName = SOAPTypeMappingRegistry.SOAP_ARRAY;
  +            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_INT)) {
  +                typeQName = SOAPTypeMappingRegistry.XSD_INT;
  +            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_BOOLEAN)) {
  +                typeQName = SOAPTypeMappingRegistry.XSD_BOOLEAN;
  +            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_SHORT)) {
  +                typeQName = SOAPTypeMappingRegistry.XSD_SHORT;
  +            }
  +        }
  +
           // Look up type and return an appropriate deserializer
           if (typeQName != null) {
               deserializer = context.getDeserializer(typeQName);
  
  
  
  1.23      +3 -0      xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java
  
  Index: SOAPEnvelope.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- SOAPEnvelope.java	2001/05/05 22:16:59	1.22
  +++ SOAPEnvelope.java	2001/05/06 15:57:20	1.23
  @@ -133,6 +133,9 @@
               handler.parseToEnd();
           }
           
  +        if (bodyElements.isEmpty())
  +            return null;
  +        
           return (SOAPBodyElement)bodyElements.elementAt(0);
       }
       
  
  
  
  1.10      +56 -5     xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java
  
  Index: SOAPSAXHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SOAPSAXHandler.java	2001/05/05 22:16:59	1.9
  +++ SOAPSAXHandler.java	2001/05/06 15:57:20	1.10
  @@ -131,7 +131,7 @@
               if ((serviceDesc != null) && (!serviceDesc.isRPC())) {
                   return new SOAPBodyElement(namespace, localName, attributes, context);
               }
  -            
  +
               return RPCElement.getFactory().createElement(namespace,
                                                            localName,
                                                            attributes,
  @@ -333,6 +333,15 @@
           }
       }
       
  +    /** This is so RPCParams can replace themselves on the handler stack
  +     * without pushing.  Allows deserialization of multi-refs to work
  +     * correctly.
  +     */
  +    public void replaceElementHandler(DeserializerBase newHandler)
  +    {
  +        elementHandler = newHandler;
  +    }
  +    
       /****************************************************************
        * SAX event handlers
        */
  @@ -391,6 +400,44 @@
           if (elementHandler != null) elementHandler.skippedEntity(p1);
       }
   
  +    public boolean needsStartElement(Attributes attributes)
  +        throws SAXException
  +    {
  +        String href = attributes.getValue(Constants.ATTR_HREF);
  +        if (href != null) {
  +            if (DEBUG_LOG) {
  +                System.err.println("looking for href " + href);
  +            }
  +            
  +            MessageElement target = context.getElementByID(href.substring(1));
  +            if (target != null) {
  +                if (DEBUG_LOG)
  +                    System.out.println("found target " + target);
  +                
  +                DeserializerBase rec = target.getContentHandler();
  +                if (rec == null)
  +                    throw new SAXException("No handler in target element?");
  +                
  +                if (rec instanceof ElementRecorder) {
  +                    ((ElementRecorder)rec).publishToHandler(context.getSAXHandler());
  +                } else {
  +                    System.out.println("Setting value to " + rec.getValue());
  +                    elementHandler.setValue(rec.getValue());
  +                }
  +                
  +                // Might want to somehow write deserialized version
  +                // back to the IDmapping table...
  +                
  +                return false;
  +            }
  +            
  +            context.addFixupHandler(href.substring(1), elementHandler);
  +            return false;
  +        }
  +
  +        return true;
  +    }
  +    
       /** This is a big workhorse.  Manage the state of the parser, check for
        * basic SOAP compliance (envelope, then optional header, then body, etc).
        * 
  @@ -415,8 +462,10 @@
               // push another handler onto the element stack.
               elementHandler.onStartChild(namespace, localName, qName, attributes);
               
  -            // This may, therefore, refer to a different handler than the last line.
  -            elementHandler.startElement(namespace, localName, qName, attributes);
  +            if (needsStartElement(attributes)) {
  +                // This may, therefore, refer to a different handler than the last one.
  +                elementHandler.startElement(namespace, localName, qName, attributes);
  +            }
               
               recordingDepth++;
               
  @@ -506,7 +555,7 @@
               default:
                   throw new SAXException("In unknown parsing state!");
               }
  -            
  +
               // Let the event stream run until the end of this element,
               // sending the events to an appropriate handler.
               if (element != null) {
  @@ -536,7 +585,9 @@
                   pushElementHandler(handler);
   
                   elementHandler.setDeserializationContext(context);
  -                elementHandler.startElement(namespace, localName, qName, attributes);
  +                
  +                if (needsStartElement(attributes))
  +                    elementHandler.startElement(namespace, localName, qName, attributes);
               }
           } catch (SAXException saxEx) {
               throw saxEx;
  
  
  

Mime
View raw message