axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/src/org/apache/axis Message.java SOAPPart.java
Date Thu, 22 Apr 2004 18:00:12 GMT
dims        2004/04/22 11:00:12

  Modified:    java/src/org/apache/axis/attachments AttachmentsImpl.java
               java/test/session build.xml
               java/src/org/apache/axis Message.java SOAPPart.java
  Log:
  Peformance improvement - avoid byte[] <-> string conversions (saves memory, reduces
GC time)
  
  Revision  Changes    Path
  1.47      +1 -1      ws-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java
  
  Index: AttachmentsImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- AttachmentsImpl.java	8 Apr 2004 13:09:05 -0000	1.46
  +++ AttachmentsImpl.java	22 Apr 2004 18:00:12 -0000	1.47
  @@ -516,7 +516,7 @@
   
               // force a serialization of the message so that
               // any attachments will be added
  -            soapPart.getAsString();
  +            soapPart.getAsBytes();
               
               return orderedAttachments.size();
           } catch (AxisFault e) {
  
  
  
  1.7       +1 -1      ws-axis/java/test/session/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/session/build.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- build.xml	21 Feb 2004 19:21:54 -0000	1.6
  +++ build.xml	22 Apr 2004 18:00:12 -0000	1.7
  @@ -63,7 +63,7 @@
   </target>
   
   <target name="run">
  -	<antcall target="execute-Component" />
  +	<antcall target="execute-Component-noServer" />
   </target>
   
   </project>
  
  
  
  1.113     +2 -21     ws-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.112
  retrieving revision 1.113
  diff -u -r1.112 -r1.113
  --- Message.java	19 Apr 2004 17:50:44 -0000	1.112
  +++ Message.java	22 Apr 2004 18:00:12 -0000	1.113
  @@ -37,6 +37,7 @@
   import java.io.IOException;
   import java.io.OutputStreamWriter;
   import java.io.Writer;
  +import java.io.PrintWriter;
   import java.lang.reflect.Constructor;
   import java.lang.reflect.InvocationTargetException;
   import java.util.Iterator;
  @@ -459,19 +460,6 @@
                   soap12 = true;
               }
           }
  -        int sendType = Attachments.SEND_TYPE_NOTSET;
  -        if ((msgContext != null) && (msgContext.getService() != null)) {
  -            sendType = msgContext.getService().getSendType();
  -        }
  -
  -        if (sendType != Attachments.SEND_TYPE_NONE) {
  -            //Force serialization if it hasn't happend it.
  -            //Rick Rineholt fix this later.
  -            //Heejune added null check.
  -            if (mSOAPPart != null){
  -                mSOAPPart.getAsBytes();
  -            }
  -        }
   
           // The origional logic is very simple
           // String ret = sc.getContentType() + "; charset="+XMLUtils.getEncoding().toLowerCase();
  @@ -538,19 +526,12 @@
                   if(charEncoding == null){
                       charEncoding = "UTF-8";
                   }
  -                Writer writer = new OutputStreamWriter(os,charEncoding);
  -                writer = new BufferedWriter(writer);
  -
                   // write the xml declaration header
                   String incXMLDecl = (String)getProperty(SOAPMessage.WRITE_XML_DECLARATION);
                   if(incXMLDecl == null){
                       incXMLDecl = "false";
                   }
  -                if(incXMLDecl.equalsIgnoreCase("true")){
  -                    writer.write("<?xml version=\"1.0\" encoding=\"" + charEncoding
+"\"?>");
  -                }
  -                mSOAPPart.writeTo(writer);
  -                writer.flush();
  +                mSOAPPart.writeTo(os, charEncoding, incXMLDecl);
               } catch (java.io.IOException e) {
                   log.error(Messages.getMessage("javaIOException00"), e);
               }
  
  
  
  1.65      +55 -4     ws-axis/java/src/org/apache/axis/SOAPPart.java
  
  Index: SOAPPart.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/SOAPPart.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- SOAPPart.java	9 Mar 2004 07:25:35 -0000	1.64
  +++ SOAPPart.java	22 Apr 2004 18:00:12 -0000	1.65
  @@ -62,6 +62,10 @@
   import java.io.Reader;
   import java.io.BufferedReader;
   import java.io.ByteArrayInputStream;
  +import java.io.PrintWriter;
  +import java.io.OutputStreamWriter;
  +import java.io.BufferedWriter;
  +import java.io.BufferedOutputStream;
   import java.util.Iterator;
   import java.util.Vector;
   
  @@ -245,6 +249,34 @@
       }
   
       /**
  +     * Write the contents to the specified stream.
  +     *
  +     * @param os  the <code>java.io.OutputStream</code> to write to
  +     * @param charEncoding  
  +     * @param incXMLDecl  
  +     */
  +    public void writeTo(java.io.OutputStream os, String charEncoding,
  +                         String incXMLDecl) throws IOException {
  +        if ( currentForm == FORM_BYTES ) {
  +            if(incXMLDecl.equalsIgnoreCase("true")){
  +                os.write(("<?xml version=\"1.0\" encoding=\"" + charEncoding +
  +                        "\"?>").getBytes());
  +            }
  +            os.write((byte[])currentMessage);
  +        } else {
  +            Writer writer = new OutputStreamWriter(os,charEncoding);
  +            writer = new BufferedWriter(writer);
  +            writer = new PrintWriter(new BufferedWriter(writer));
  +    
  +            if(incXMLDecl.equalsIgnoreCase("true")){
  +                writer.write("<?xml version=\"1.0\" encoding=\"" + charEncoding +"\"?>");
  +            }
  +            writeTo(writer);
  +            writer.flush();
  +        }
  +    }
  +
  +    /**
        * Write the contents to the specified writer.
        *
        * @param writer  the <code>Writer</code> to write to
  @@ -381,9 +413,29 @@
   
           if ( currentForm == FORM_SOAPENVELOPE ||
                currentForm == FORM_FAULT ){
  -            // Set message to FORM_STRING and
  -            // translate to bytes below
  -            getAsString();
  +            String encoding = null;
  +            if (msgObject != null) {
  +                try {
  +                    encoding = (String) msgObject.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  +                } catch (SOAPException e) {
  +                }
  +            }
  +            if (encoding == null) {
  +                encoding = "UTF-8";
  +            }
  +            ByteArrayOutputStream baos = new ByteArrayOutputStream();
  +            BufferedOutputStream os = new BufferedOutputStream(baos);
  +            try {
  +                this.writeTo(os,encoding,"false");
  +                os.flush();
  +            } catch (Exception e) {
  +                throw AxisFault.makeFault(e);
  +            }
  +            setCurrentForm( baos.toByteArray(), FORM_BYTES );
  +            if (log.isDebugEnabled()) {
  +                log.debug("Exit: SOAPPart::getAsBytes(): " + currentMessage);
  +            }
  +            return (byte[])currentMessage;
           }
   
           if ( currentForm == FORM_STRING ) {
  @@ -894,7 +946,6 @@
   
       /**
        * SOAPEnvelope is the Document Elements of this XML docuement
  -     * @return
        */
       protected Document mDocument;
   
  
  
  

Mime
View raw message