axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r218974 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis2/transport/ core/src/org/apache/axis2/transport/http/ xml/src/org/apache/axis2/attachments/ xml/src/org/apache/axis2/om/impl/ xml/src/org/apache/axis2/om/impl/llom/...
Date Thu, 14 Jul 2005 03:13:43 GMT
Author: dims
Date: Wed Jul 13 20:13:40 2005
New Revision: 218974

URL: http://svn.apache.org/viewcvs?rev=218974&view=rev
Log:
The comment at top of OutputImpl makes it VERY clear that transport takes
the decisions. Let's just reflect that fact, clean up code and make it
a reality :)


Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageDataSource.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/serialize/StreamingOMSerializer.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java?rev=218974&r1=218973&r2=218974&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/AbstractTransportSender.java
Wed Jul 13 20:13:40 2005
@@ -47,6 +47,7 @@
      */
     private Log log = LogFactory.getLog(getClass());
 
+    protected OMOutputImpl omOutput = new OMOutputImpl();
 
     /**
      * Field NAME
@@ -77,7 +78,7 @@
         //put a <parameter name="doREST" value="true"/> at the axis2.xml
         msgContext.setDoingMTOM(HTTPTransportUtils.doWriteMTOM(msgContext));
 
-        OutputStream out = null;
+        OutputStream out;
 
         EndpointReference epr = null;
 
@@ -129,20 +130,11 @@
         }
 
         if (outputMessage != null) {
-            OMOutputImpl omOutput = null;
-
             try {
-                if (msgContext.isDoingMTOM()) {
-                    omOutput = new org.apache.axis2.om.impl.OMOutputImpl(out, true);
-                    outputMessage.serialize(omOutput);
-                    omOutput.flush();
-                    out.flush();
-                } else {
-                    omOutput = new OMOutputImpl(out, false);
-                    outputMessage.serialize(omOutput);
-                    omOutput.flush();
-                    out.flush();
-                }
+                omOutput.setOutputStream(out, msgContext.isDoingMTOM());
+                outputMessage.serialize(omOutput);
+                omOutput.flush();
+                out.flush();
             } catch (Exception e) {
                 throw new AxisFault("Stream error", e);
             }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=218974&r1=218973&r2=218974&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
Wed Jul 13 20:13:40 2005
@@ -61,6 +61,8 @@
 
     protected OMElement outputMessage;
 
+    protected OMOutputImpl omOutput = new OMOutputImpl();
+
     public CommonsHTTPTransportSender() {
     } //default
 
@@ -80,7 +82,7 @@
                 epr = msgContext.getTo();
             }
 
-            OMElement dataOut = null;
+            OMElement dataOut;
             if (msgContext.isDoingREST()) {
                 dataOut = msgContext.getEnvelope().getFirstElement();
             } else {
@@ -93,8 +95,8 @@
             } else {
                 OutputStream out = (OutputStream) msgContext
                         .getProperty(MessageContext.TRANSPORT_OUT);
-                OMOutputImpl output = new OMOutputImpl(out, false);
-                dataOut.serialize(output);
+                omOutput.setOutputStream(out, false);
+                dataOut.serialize(omOutput);
             }
             msgContext.getOperationContext().setProperty(
                     Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
@@ -118,8 +120,7 @@
             //Configure the transport
             String soapAction = msgContext.getWSAAction();
             //settign soapAction
-            String soapActionString = soapAction == null ? "" : soapAction
-                    .toString();
+            String soapActionString = soapAction == null ? "" : soapAction;
 
             PostMethod postMethod = new PostMethod();
             postMethod.setPath(url.getFile());
@@ -129,12 +130,12 @@
                             chuncked, msgContext.isDoingMTOM()));
             if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)
                     && chuncked) {
-                ((PostMethod) postMethod).setContentChunked(true);
+                postMethod.setContentChunked(true);
             }
 
             if (msgContext.isDoingMTOM()) {
                 postMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
-                        OMOutputImpl.getContentType(true));
+                        omOutput.getOptimizedContentType());
             } else {
                 postMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
                         "text/xml; charset=utf-8");
@@ -276,9 +277,9 @@
         public void writeRequest(OutputStream out) throws IOException {
             try {
                 if (chuncked || doingMTOM) {
-                    OMOutputImpl output = new OMOutputImpl(out, doingMTOM);
-                    element.serialize(output);
-                    output.flush();
+                    omOutput.setOutputStream(out, doingMTOM);
+                    element.serialize(omOutput);
+                    omOutput.flush();
                     out.flush();
                 } else {
                     if (bytes == null) {

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java?rev=218974&r1=218973&r2=218974&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java
(original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/transport/http/HTTPTransportSender.java
Wed Jul 13 20:13:40 2005
@@ -22,7 +22,6 @@
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.axis2.engine.AxisFault;
-import org.apache.axis2.om.impl.OMOutputImpl;
 import org.apache.axis2.soap.impl.llom.soap11.SOAP11Constants;
 import org.apache.axis2.soap.impl.llom.soap12.SOAP12Constants;
 import org.apache.axis2.transport.AbstractTransportSender;
@@ -69,7 +68,7 @@
                     "\n");
             if (doMTOM) {
                 buf.append(HTTPConstants.HEADER_CONTENT_TYPE).append(": ")
-                        .append(OMOutputImpl.getContentType(true))
+                        .append(omOutput.getOptimizedContentType())
                         .append("\n");
             } else {
                 String nsURI = msgContext.getEnvelope().getNamespace().getName();
@@ -159,7 +158,7 @@
             TransportSenderInfo transportInfo =
                     (TransportSenderInfo) msgContext.getProperty(
                             TRANSPORT_SENDER_INFO);
-            InputStream in = null;
+            InputStream in;
             if (chuncked || msgContext.isDoingMTOM()) {
                 if (chuncked) {
                     ((ChunkedOutputStream) out).eos();
@@ -244,7 +243,7 @@
                     HTTPConstants.HTTPOutTransportInfo);
             if (httpOutTransportInfo != null) {
                 httpOutTransportInfo.setContentType(
-                        OMOutputImpl.getContentType(true));
+                        omOutput.getOptimizedContentType());
             } else {
                 throw new AxisFault(
                         "Property " + HTTPConstants.HTTPOutTransportInfo +

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageDataSource.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageDataSource.java?rev=218974&r1=218973&r2=218974&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageDataSource.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/attachments/ImageDataSource.java
Wed Jul 13 20:13:40 2005
@@ -58,7 +58,7 @@
 
     public String getContentType() {
         return contentType;
-    } // getContentType
+    } // getOptimizedContentType
 
     public InputStream getInputStream() throws IOException {
         if (os.size() != 0) {

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java?rev=218974&r1=218973&r2=218974&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
Wed Jul 13 20:13:40 2005
@@ -15,7 +15,6 @@
  */
 package org.apache.axis2.om.impl;
 
-import org.apache.axis2.om.impl.MIMEOutputUtils;
 import org.apache.axis2.om.OMText;
 
 import javax.xml.stream.FactoryConfigurationError;
@@ -39,22 +38,23 @@
     private ByteArrayOutputStream bufferedSoapOutStream;
     private static String mimeBoundary = "----=_AxIs2_Def_boundary_=42214532";
 
-    /**
-     * @param xmlWriter if it is guaranteed for not using attachments one can use this
-     */
+    public OMOutputImpl() {
+    }
+
     public OMOutputImpl(XMLStreamWriter xmlWriter) {
         this.xmlWriter = xmlWriter;
     }
 
-    /**
-     * @throws FactoryConfigurationError
-     * @throws XMLStreamException
-     */
-    public OMOutputImpl(OutputStream outStream, boolean doOptimise)
+    public OMOutputImpl(OutputStream outStream, boolean doOptimize)
+            throws XMLStreamException, FactoryConfigurationError {
+        setOutputStream(outStream, doOptimize);
+    }
+
+    public void setOutputStream(OutputStream outStream, boolean doOptimize)
             throws XMLStreamException, FactoryConfigurationError {
-        this.doOptimize = doOptimise;
+        this.doOptimize = doOptimize;
         this.outStream = outStream;
-        if (doOptimise) {
+        if (doOptimize) {
             bufferedSoapOutStream = new ByteArrayOutputStream();
             xmlWriter =
                     XMLOutputFactory.newInstance().createXMLStreamWriter(
@@ -67,10 +67,6 @@
         }
     }
 
-    public XMLStreamWriter getXmlStreamWriter() {
-        return xmlWriter;
-    }
-
     public void flush() throws XMLStreamException {
         xmlWriter.flush();
         if (doOptimize) {
@@ -79,22 +75,23 @@
         }
     }
 
-    public boolean doOptimise() {
+    public boolean isOptimized() {
         return doOptimize;
     }
 
-    public static String getContentType(boolean doOptimize) {
-        if (doOptimize) {
-            return org.apache.axis2.om.impl.MIMEOutputUtils.getContentTypeForMime(mimeBoundary);
-        }
-        //TODO have to check whether SOAP1.1 & SOAP 1.2
-        return null;
+    public String getOptimizedContentType() {
+        return org.apache.axis2.om.impl.MIMEOutputUtils.getContentTypeForMime(mimeBoundary);
     }
 
     public void writeOptimized(OMText node) {
         binaryNodeList.add(node);
     }
 
-    public void complete() throws XMLStreamException {
+    public void setXmlStreamWriter(XMLStreamWriter xmlWriter) {
+        this.xmlWriter = xmlWriter;
+    }
+
+    public XMLStreamWriter getXmlStreamWriter() {
+        return xmlWriter;
     }
 }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java?rev=218974&r1=218973&r2=218974&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMTextImpl.java
Wed Jul 13 20:13:40 2005
@@ -269,7 +269,7 @@
         if (!this.isBinary) {
             serializeWithCache(omOutput);
         } else {
-            if (omOutput.doOptimise()) {
+            if (omOutput.isOptimized()) {
                 // send binary as MTOM optimised
                 this.attribute =
                         new OMAttributeImpl("href",

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/serialize/StreamingOMSerializer.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/serialize/StreamingOMSerializer.java?rev=218974&r1=218973&r2=218974&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/serialize/StreamingOMSerializer.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/serialize/StreamingOMSerializer.java
Wed Jul 13 20:13:40 2005
@@ -61,10 +61,6 @@
      */
     public void serialize(XMLStreamReader obj, OMOutputImpl omOutput)
             throws XMLStreamException {
-        if (!(obj instanceof XMLStreamReader)) {
-            throw new UnsupportedOperationException(
-                    "Unsupported input object. Must be of the the type XMLStreamReader");
-        }
         XMLStreamReader node = (XMLStreamReader) obj;
         serializeNode(node, omOutput);
     }



Mime
View raw message