You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2008/10/21 03:05:46 UTC

svn commit: r706485 - in /synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp: Axis2HttpRequest.java HttpCoreNIOSender.java NhttpUtils.java util/NhttpUtil.java

Author: ruwan
Date: Mon Oct 20 18:05:46 2008
New Revision: 706485

URL: http://svn.apache.org/viewvc?rev=706485&view=rev
Log:
Moving the util methods in the NhttpUtils class into the util.NhttpUtil class

Modified:
    synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/Axis2HttpRequest.java
    synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/HttpCoreNIOSender.java
    synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/NhttpUtils.java
    synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/util/NhttpUtil.java

Modified: synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/Axis2HttpRequest.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/Axis2HttpRequest.java?rev=706485&r1=706484&r2=706485&view=diff
==============================================================================
--- synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/Axis2HttpRequest.java (original)
+++ synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/Axis2HttpRequest.java Mon Oct 20 18:05:46 2008
@@ -39,6 +39,7 @@
 import org.apache.http.protocol.HTTP;
 import org.apache.synapse.transport.nhttp.util.MessageFormatterDecoratorFactory;
 import org.apache.synapse.transport.nhttp.util.RESTUtil;
+import org.apache.synapse.transport.nhttp.util.NhttpUtil;
 import org.apache.synapse.util.TemporaryData;
 
 import java.io.IOException;
@@ -84,7 +85,7 @@
         this.epr = epr;
         this.httpHost = httpHost;
         this.msgContext = msgContext;
-        this.format = NhttpUtils.getOMOutputFormat(msgContext);
+        this.format = NhttpUtil.getOMOutputFormat(msgContext);
         this.messageFormatter =
                 MessageFormatterDecoratorFactory.createMessageFormatterDecorator(msgContext);
     }

Modified: synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/HttpCoreNIOSender.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/HttpCoreNIOSender.java?rev=706485&r1=706484&r2=706485&view=diff
==============================================================================
--- synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/HttpCoreNIOSender.java (original)
+++ synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/HttpCoreNIOSender.java Mon Oct 20 18:05:46 2008
@@ -53,6 +53,7 @@
 import org.apache.http.protocol.HTTP;
 import org.apache.axis2.transport.base.threads.NativeThreadFactory;
 import org.apache.synapse.transport.nhttp.util.MessageFormatterDecoratorFactory;
+import org.apache.synapse.transport.nhttp.util.NhttpUtil;
 
 import javax.net.ssl.SSLContext;
 import java.io.IOException;
@@ -227,7 +228,7 @@
             msgContext.setProperty(NhttpConstants.IGNORE_SC_ACCEPTED, Constants.VALUE_TRUE);
         }
 
-        EndpointReference epr = NhttpUtils.getDestinationEPR(msgContext);
+        EndpointReference epr = NhttpUtil.getDestinationEPR(msgContext);
         if (epr != null) {
             if (!AddressingConstants.Final.WSA_NONE_URI.equals(epr.getAddress())) {
                 sendAsyncRequest(epr, msgContext);
@@ -356,7 +357,7 @@
         ServerWorker worker = (ServerWorker) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
         HttpResponse response = worker.getResponse();
 
-        OMOutputFormat format = NhttpUtils.getOMOutputFormat(msgContext);
+        OMOutputFormat format = NhttpUtil.getOMOutputFormat(msgContext);
         MessageFormatter messageFormatter =
                 MessageFormatterDecoratorFactory.createMessageFormatterDecorator(msgContext);
         response.setHeader(
@@ -449,7 +450,7 @@
 
     private void sendUsingOutputStream(MessageContext msgContext) throws AxisFault {
 
-        OMOutputFormat format = NhttpUtils.getOMOutputFormat(msgContext);
+        OMOutputFormat format = NhttpUtil.getOMOutputFormat(msgContext);
         MessageFormatter messageFormatter =
                 MessageFormatterDecoratorFactory.createMessageFormatterDecorator(msgContext);
         OutputStream out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);

Modified: synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/NhttpUtils.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/NhttpUtils.java?rev=706485&r1=706484&r2=706485&view=diff
==============================================================================
--- synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/NhttpUtils.java (original)
+++ synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/NhttpUtils.java Mon Oct 20 18:05:46 2008
@@ -30,68 +30,4 @@
 
 public class NhttpUtils {
 
-    /**
-     * Get the EPR for the message passed in
-     * @param msgContext the message context
-     * @return the destination EPR
-     */
-    public static EndpointReference getDestinationEPR(MessageContext msgContext) {
-
-        // Trasnport URL can be different from the WSA-To
-        String transportURL = (String) msgContext.getProperty(
-            Constants.Configuration.TRANSPORT_URL);
-
-        if (transportURL != null) {
-            return new EndpointReference(transportURL);
-        } else if (
-            (msgContext.getTo() != null) &&
-                !AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(
-                    msgContext.getTo().getAddress()) &&
-                !AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(
-                    msgContext.getTo().getAddress())) {
-            return msgContext.getTo();
-        }
-        return null;
-    }
-
-    /**
-     * Retirn the OMOutputFormat to be used for the message context passed in
-     * @param msgContext the message context
-     * @return the OMOutputFormat to be used
-     */
-    public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) {
-
-        OMOutputFormat format = new OMOutputFormat();
-        msgContext.setDoingMTOM(BaseUtils.doWriteMTOM(msgContext));
-        msgContext.setDoingSwA(BaseUtils.doWriteSwA(msgContext));
-        msgContext.setDoingREST(BaseUtils.isDoingREST(msgContext));        
-        format.setSOAP11(msgContext.isSOAP11());
-        format.setDoOptimize(msgContext.isDoingMTOM());
-        format.setDoingSWA(msgContext.isDoingSwA());
-
-        format.setCharSetEncoding(BaseUtils.getCharSetEncoding(msgContext));
-        Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY);
-        if (mimeBoundaryProperty != null) {
-            format.setMimeBoundary((String) mimeBoundaryProperty);
-        }
-
-        return format;
-    }
-
-    /**
-     * Get the content type for the message passed in
-     * @param msgContext the message
-     * @return content type of the message
-     */
-    public static String getContentType(MessageContext msgContext) {
-        Object contentTypeObject = msgContext.getProperty(Constants.Configuration.CONTENT_TYPE);
-        if (contentTypeObject != null) {
-            return (String) contentTypeObject;
-        } else if (msgContext.isDoingREST()) {
-            return HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
-        } else {
-            return getOMOutputFormat(msgContext).getContentType();
-        }
-    }
-
 }

Modified: synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/util/NhttpUtil.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/util/NhttpUtil.java?rev=706485&r1=706484&r2=706485&view=diff
==============================================================================
--- synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/util/NhttpUtil.java (original)
+++ synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/nhttp/util/NhttpUtil.java Mon Oct 20 18:05:46 2008
@@ -18,6 +18,14 @@
 */
 package org.apache.synapse.transport.nhttp.util;
 
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.Constants;
+import org.apache.axis2.transport.base.BaseUtils;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axiom.om.OMOutputFormat;
+
 import java.net.InetAddress;
 
 /**
@@ -59,4 +67,68 @@
         }
         return result;
     }
+
+    /**
+     * Get the EPR for the message passed in
+     * @param msgContext the message context
+     * @return the destination EPR
+     */
+    public static EndpointReference getDestinationEPR(MessageContext msgContext) {
+
+        // Trasnport URL can be different from the WSA-To
+        String transportURL = (String) msgContext.getProperty(
+            Constants.Configuration.TRANSPORT_URL);
+
+        if (transportURL != null) {
+            return new EndpointReference(transportURL);
+        } else if (
+            (msgContext.getTo() != null) &&
+                !AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(
+                    msgContext.getTo().getAddress()) &&
+                !AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(
+                    msgContext.getTo().getAddress())) {
+            return msgContext.getTo();
+        }
+        return null;
+    }
+
+    /**
+     * Retirn the OMOutputFormat to be used for the message context passed in
+     * @param msgContext the message context
+     * @return the OMOutputFormat to be used
+     */
+    public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) {
+
+        OMOutputFormat format = new OMOutputFormat();
+        msgContext.setDoingMTOM(BaseUtils.doWriteMTOM(msgContext));
+        msgContext.setDoingSwA(BaseUtils.doWriteSwA(msgContext));
+        msgContext.setDoingREST(BaseUtils.isDoingREST(msgContext));
+        format.setSOAP11(msgContext.isSOAP11());
+        format.setDoOptimize(msgContext.isDoingMTOM());
+        format.setDoingSWA(msgContext.isDoingSwA());
+
+        format.setCharSetEncoding(BaseUtils.getCharSetEncoding(msgContext));
+        Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY);
+        if (mimeBoundaryProperty != null) {
+            format.setMimeBoundary((String) mimeBoundaryProperty);
+        }
+
+        return format;
+    }
+
+    /**
+     * Get the content type for the message passed in
+     * @param msgContext the message
+     * @return content type of the message
+     */
+    public static String getContentType(MessageContext msgContext) {
+        Object contentTypeObject = msgContext.getProperty(Constants.Configuration.CONTENT_TYPE);
+        if (contentTypeObject != null) {
+            return (String) contentTypeObject;
+        } else if (msgContext.isDoingREST()) {
+            return HTTPConstants.MEDIA_TYPE_APPLICATION_XML;
+        } else {
+            return getOMOutputFormat(msgContext).getContentType();
+        }
+    }
 }