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 di...@apache.org on 2004/04/19 19:50:44 UTC

cvs commit: ws-axis/java/src/org/apache/axis/components/encoding XMLEncoderFactory.java

dims        2004/04/19 10:50:44

  Modified:    java/src/org/apache/axis Message.java
               java/src/org/apache/axis/components/encoding
                        XMLEncoderFactory.java
  Log:
  Performance enhancement as part of AXIS-1323 (Prevent unnecessary conversions of Message and streamline getEncoder a bit). Makes it a bit more faster but need to dig deeper.
  
  Revision  Changes    Path
  1.112     +10 -6     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.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- Message.java	11 Mar 2004 17:27:03 -0000	1.111
  +++ Message.java	19 Apr 2004 17:50:44 -0000	1.112
  @@ -451,7 +451,14 @@
        *              this message
        */
       public String getContentType(SOAPConstants sc) throws AxisFault {
  -
  +        boolean soap12 = false;
  +        // Support of SOAP 1.2 HTTP binding
  +        SOAPEnvelope envelope = getSOAPEnvelope();
  +        if (envelope != null) {
  +            if (envelope.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS) {
  +                soap12 = true;
  +            }
  +        }
           int sendType = Attachments.SEND_TYPE_NOTSET;
           if ((msgContext != null) && (msgContext.getService() != null)) {
               sendType = msgContext.getService().getSendType();
  @@ -481,11 +488,8 @@
           String ret = sc.getContentType() + "; charset=" + encoding;
           
           // Support of SOAP 1.2 HTTP binding
  -        SOAPEnvelope envelope = getSOAPEnvelope();
  -        if (envelope != null) {
  -            if (envelope.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS) {
  -                ret = HTTPConstants.HEADER_ACCEPT_APPL_SOAP +"; charset=" + encoding;
  -            }
  +        if (soap12) {
  +            ret = HTTPConstants.HEADER_ACCEPT_APPL_SOAP +"; charset=" + encoding;
           }
   
           if (mAttachments != null && 0 != mAttachments.getAttachmentCount()) {
  
  
  
  1.3       +4 -4      ws-axis/java/src/org/apache/axis/components/encoding/XMLEncoderFactory.java
  
  Index: XMLEncoderFactory.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/encoding/XMLEncoderFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLEncoderFactory.java	25 Feb 2004 14:02:31 -0000	1.2
  +++ XMLEncoderFactory.java	19 Apr 2004 17:50:44 -0000	1.3
  @@ -46,6 +46,8 @@
       static {
           encoderMap.put(ENCODING_UTF_8, new UTF8Encoder());
           encoderMap.put(ENCODING_UTF_16, new UTF16Encoder());
  +        encoderMap.put(ENCODING_UTF_8.toLowerCase(), new UTF8Encoder());
  +        encoderMap.put(ENCODING_UTF_16.toLowerCase(), new UTF16Encoder());
           try {
               loadPluggableEncoders();
           } catch (Throwable t){
  @@ -74,13 +76,10 @@
        * @throws UnsupportedEncodingException
        */
       public static XMLEncoder getEncoder(String encoding) throws UnsupportedEncodingException {
  -        XMLEncoder encoder = (XMLEncoder) encoderMap.get(encoding.toUpperCase());
  +        XMLEncoder encoder = (XMLEncoder) encoderMap.get(encoding);
           if (encoder == null) {
               throw new UnsupportedEncodingException(Messages.getMessage("unsupportedEncoding00", encoding));
           }
  -        // test local encoding so we can ensure that getBytes()
  -        // will not fail later
  -        "test".getBytes(encoder.getEncoding());
           return encoder;
       }
   
  @@ -113,6 +112,7 @@
                   if (o instanceof XMLEncoder) {
                       XMLEncoder encoder = (XMLEncoder) o;
                       encoderMap.put(encoder.getEncoding(), encoder);
  +                    encoderMap.put(encoder.getEncoding().toLowerCase(), encoder);
                   }
               } catch (Exception e) {
                   String msg = e + JavaUtils.LS + JavaUtils.stackToString(e);