You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2002/08/19 20:51:27 UTC

cvs commit: xml-axis/java/src/org/apache/axis/message MessageElement.java SAX2EventRecorder.java

rubys       2002/08/19 11:51:27

  Modified:    java/src simplelog.properties
               java/src/org/apache/axis/encoding
                        DeserializationContextImpl.java
               java/src/org/apache/axis/encoding/ser ArraySerializer.java
                        BeanSerializer.java SimpleSerializer.java
               java/src/org/apache/axis/message MessageElement.java
                        SAX2EventRecorder.java
  Log:
  If we have to copy the Attributes, the least we can do is make sure that
  we are only going to do it once.
  
  Revision  Changes    Path
  1.2       +1 -1      xml-axis/java/src/simplelog.properties
  
  Index: simplelog.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/simplelog.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- simplelog.properties	20 Jun 2002 17:48:22 -0000	1.1
  +++ simplelog.properties	19 Aug 2002 18:51:26 -0000	1.2
  @@ -1,2 +1,2 @@
  -org.apache.commons.logging.simplelog.defaultlog=warn
  +org.apache.commons.logging.simplelog.defaultlog=debug
   
  
  
  
  1.48      +3 -0      xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java
  
  Index: DeserializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- DeserializationContextImpl.java	19 Aug 2002 12:12:08 -0000	1.47
  +++ DeserializationContextImpl.java	19 Aug 2002 18:51:27 -0000	1.48
  @@ -74,6 +74,7 @@
   import org.apache.commons.logging.Log;
   
   import org.xml.sax.Attributes;
  +import org.xml.sax.helpers.AttributesImpl;
   import org.xml.sax.InputSource;
   import org.xml.sax.Locator;
   import org.xml.sax.SAXException;
  @@ -847,6 +848,8 @@
               log.debug("Enter: DeserializationContextImpl::startElement(" + namespace + ", " + localName + ")");
           }
           
  +        attributes = new AttributesImpl(attributes);
  +
           SOAPHandler nextHandler = null;
   
           String prefix = "";
  
  
  
  1.29      +5 -3      xml-axis/java/src/org/apache/axis/encoding/ser/ArraySerializer.java
  
  Index: ArraySerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/ArraySerializer.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ArraySerializer.java	22 Jul 2002 20:10:04 -0000	1.28
  +++ ArraySerializer.java	19 Aug 2002 18:51:27 -0000	1.29
  @@ -215,10 +215,12 @@
   
           if (isEncoded) {
               AttributesImpl attrs;
  -            if (attributes != null) {
  -                attrs = new AttributesImpl(attributes);
  -            } else {
  +            if (attributes == null) {
                   attrs = new AttributesImpl();
  +            } else if (attributes instanceof AttributesImpl) {
  +                attrs = (AttributesImpl)attributes;
  +            } else {
  +                attrs = new AttributesImpl(attributes);
               }
   
               if (attrs.getIndex(Constants.URI_DEFAULT_SOAP_ENC,
  
  
  
  1.52      +6 -3      xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java
  
  Index: BeanSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanSerializer.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- BeanSerializer.java	18 Aug 2002 14:19:50 -0000	1.51
  +++ BeanSerializer.java	19 Aug 2002 18:51:27 -0000	1.52
  @@ -465,10 +465,13 @@
               return attributes;
   
           AttributesImpl attrs;
  -        if (attributes != null)
  -            attrs = new AttributesImpl(attributes);
  -        else
  +        if (attributes == null) {
               attrs = new AttributesImpl();
  +        } else if (attributes instanceof AttributesImpl) {
  +            attrs = (AttributesImpl)attributes;
  +        } else {
  +            attrs = new AttributesImpl(attributes);
  +        }
   
           try {
               // Find each property that is an attribute
  
  
  
  1.25      +6 -3      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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- SimpleSerializer.java	16 Aug 2002 16:41:35 -0000	1.24
  +++ SimpleSerializer.java	19 Aug 2002 18:51:27 -0000	1.25
  @@ -179,10 +179,13 @@
               return attributes;
   
           AttributesImpl attrs;
  -        if (attributes != null)
  -            attrs = new AttributesImpl(attributes);
  -        else
  +        if (attributes == null) {
               attrs = new AttributesImpl();
  +        } else if (attributes instanceof AttributesImpl) {
  +            attrs = (AttributesImpl)attributes;
  +        } else {
  +            attrs = new AttributesImpl(attributes);
  +        }
   
           try {
               // Find each property that is an attribute
  
  
  
  1.121     +29 -21    xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.120
  retrieving revision 1.121
  diff -u -r1.120 -r1.121
  --- MessageElement.java	18 Aug 2002 14:19:50 -0000	1.120
  +++ MessageElement.java	19 Aug 2002 18:51:27 -0000	1.121
  @@ -109,10 +109,12 @@
               new Mapping(Constants.URI_DEFAULT_SOAP_ENC,
                           "SOAP-ENC");
   
  +    private static final Attributes nullAttributes = new AttributesImpl();
  +
       protected String    name ;
       protected String    prefix ;
       protected String    namespaceURI ;
  -    protected transient AttributesImpl attributes = new AttributesImpl();
  +    protected transient Attributes attributes = nullAttributes;
       protected String    id;
       protected String    href;
       protected boolean   _isRoot = true;
  @@ -217,10 +219,8 @@
   
           this.recorder = context.getRecorder();
   
  -        if (attributes == null) {
  -            this.attributes = new AttributesImpl();
  -        } else {
  -            this.attributes = new AttributesImpl(attributes);
  +        if (attributes != null && attributes.getLength() > 0) {
  +            this.attributes = attributes;
   
               typeQName = context.getTypeFromAttributes(namespace,
                                                         localPart,
  @@ -560,12 +560,20 @@
           // !!! Add attribute to attributes!
       }
   
  +    protected AttributesImpl makeAttributesEditable() {
  +        if (attributes == null || attributes == nullAttributes) {
  +            attributes =  new AttributesImpl();
  +        } else if (!(attributes instanceof AttributesImpl)) {
  +            attributes = new AttributesImpl(attributes);
  +        }
  +
  +        return (AttributesImpl) attributes;
  +    }
  +
       public void addAttribute(String namespace, String localName,
                                String value)
       {
  -        if (attributes == null) {
  -            attributes = new AttributesImpl();
  -        }
  +        AttributesImpl attributes = makeAttributesEditable();
           attributes.addAttribute(namespace, localName, "", "CDATA",
                                   value);
       }
  @@ -578,19 +586,17 @@
       public void setAttribute(String namespace, String localName,
                                String value)
       {
  -        if (attributes != null) {
  -            int idx = attributes.getIndex(namespace, localName);
  -            if (idx > -1) {
  -                // Got it, so replace it's value.
  -                if (value != null) {
  -                    attributes.setValue(idx, value);
  -                } else {
  -                    attributes.removeAttribute(idx);
  -                }
  -                return;
  +        AttributesImpl attributes = makeAttributesEditable();
  +
  +        int idx = attributes.getIndex(namespace, localName);
  +        if (idx > -1) {
  +            // Got it, so replace it's value.
  +            if (value != null) {
  +                attributes.setValue(idx, value);
  +            } else {
  +                attributes.removeAttribute(idx);
               }
  -        } else if (value != null) {
  -            attributes = new AttributesImpl();
  +            return;
           }
   
           addAttribute(namespace, localName, value);
  @@ -826,7 +832,7 @@
               typeQName = null;
           }
   
  -        attributes = new AttributesImpl();
  +        AttributesImpl attributes = makeAttributesEditable();
           int n = in.readInt();
           for (int i = 0; i < n; i++) {
               String localName = (String)in.readObject();
  @@ -1017,6 +1023,7 @@
       }
   
       public boolean removeAttribute(Name name) {
  +        AttributesImpl attributes = makeAttributesEditable();
           boolean removed = false;
   
           for (int i = 0; i < attributes.getLength() && !removed; i++) {
  @@ -1030,6 +1037,7 @@
       }
   
       public boolean removeNamespaceDeclaration(String prefix) {
  +        AttributesImpl attributes = makeAttributesEditable();
           boolean removed = false;
   
           for (int i = 0; i < namespaces.size() && !removed; i++) {
  
  
  
  1.7       +1 -2      xml-axis/java/src/org/apache/axis/message/SAX2EventRecorder.java
  
  Index: SAX2EventRecorder.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SAX2EventRecorder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SAX2EventRecorder.java	17 May 2002 19:09:34 -0000	1.6
  +++ SAX2EventRecorder.java	19 Aug 2002 18:51:27 -0000	1.7
  @@ -57,7 +57,6 @@
   import org.apache.axis.encoding.DeserializationContext;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.SAXException;
  -import org.xml.sax.helpers.AttributesImpl;
   
   import java.util.ArrayList;
   
  @@ -124,7 +123,7 @@
               attrs = nattrs;
           }
           
  -        attrs[numattrs++] = new AttributesImpl(p4);
  +        attrs[numattrs++] = p4;
           return events.add(STATE_START_ELEMENT, st.addSymbol(p1), st.addSymbol(p2), st.addSymbol(p3), numattrs-1);
       }
       public int endElement(String p1, String p2, String p3) {