You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2006/10/15 14:25:44 UTC

svn commit: r464159 - in /incubator/synapse/branches/NIO/modules: core/src/org/apache/synapse/core/axis2/ niohttp/src/org/apache/axis2/transport/niohttp/ niohttp/src/org/apache/axis2/transport/niohttp/impl/

Author: asankha
Date: Sun Oct 15 05:25:42 2006
New Revision: 464159

URL: http://svn.apache.org/viewvc?view=rev&rev=464159
Log:
integration of new transport to synapse branch

Modified:
    incubator/synapse/branches/NIO/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
    incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/Axis2CallbackImpl.java
    incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/NHttpListener.java
    incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java

Modified: incubator/synapse/branches/NIO/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java
URL: http://svn.apache.org/viewvc/incubator/synapse/branches/NIO/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java?view=diff&rev=464159&r1=464158&r2=464159
==============================================================================
--- incubator/synapse/branches/NIO/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java (original)
+++ incubator/synapse/branches/NIO/modules/core/src/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java Sun Oct 15 05:25:42 2006
@@ -22,6 +22,7 @@
 import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.AxisFault;
 import org.apache.synapse.Constants;
+import org.apache.axiom.soap.SOAPFault;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -48,7 +49,15 @@
 
         if (callback != null) {
             callbackStore.remove(messageID);
-            callback.onComplete(new AsyncResult(messageCtx));
+            if (messageCtx.getEnvelope().getBody().hasFault()) {
+                SOAPFault fault = messageCtx.getEnvelope().getBody().getFault();
+                AxisFault axisFault = new AxisFault(fault.getCode(), fault.getReason(),
+                    fault.getNode(), fault.getRole(), fault.getDetail());
+                callback.onError(axisFault);
+            } else {
+                callback.onComplete(new AsyncResult(messageCtx));
+            }
+            callback.setComplete(true);
         }
     }
 }

Modified: incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/Axis2CallbackImpl.java
URL: http://svn.apache.org/viewvc/incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/Axis2CallbackImpl.java?view=diff&rev=464159&r1=464158&r2=464159
==============================================================================
--- incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/Axis2CallbackImpl.java (original)
+++ incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/Axis2CallbackImpl.java Sun Oct 15 05:25:42 2006
@@ -27,26 +27,15 @@
 
 public class Axis2CallbackImpl implements Callback {
 
-    /** The HttpRequest for which we received this HttpResponse */
-    private HttpRequest request;
     /** The HttpResponse to be handled */
     private HttpResponse response;
     /** The original Axis2 MessageContext (request) */
     private MessageContext outMsgCtx;
 
     public Axis2CallbackImpl(HttpRequest request, MessageContext msgCtx) {
-        this.request = request;
         this.outMsgCtx = msgCtx;
     }
 
-    public HttpRequest getRequest() {
-        return request;
-    }
-
-    public void setRequest(HttpRequest request) {
-        this.request = request;
-    }
-
     public HttpResponse getResponse() {
         return response;
     }
@@ -65,13 +54,7 @@
 
     public void run() {
 
-        outMsgCtx.getOperationContext().getAxisOperation();
-
         MessageContext responseMsgCtx = new MessageContext();
-        //responseMsgCtx.setOptions(outMsgCtx.getOptions()); // this is called a hack.. why?
-        // Options object reused above so soapAction needs to be removed so
-        // that soapAction+wsa:Action on response don't conflict
-        responseMsgCtx.setSoapAction("");
         responseMsgCtx.setServerSide(true);
         responseMsgCtx.setDoingREST(outMsgCtx.isDoingREST());
         responseMsgCtx.setProperty(MessageContext.TRANSPORT_IN, outMsgCtx
@@ -86,13 +69,18 @@
         responseMsgCtx.setTo(null);
 
         try {
-            SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(
-                        responseMsgCtx,
-                        response.getInputStream(),
-                        outMsgCtx.getEnvelope().getNamespace().getNamespaceURI());
-            responseMsgCtx.setEnvelope(resenvelope);
+            SOAPEnvelope envelope = TransportUtils.createSOAPMessage(
+                responseMsgCtx,
+                response.getInputStream(),
+                outMsgCtx.getEnvelope().getNamespace().getNamespaceURI());
+            responseMsgCtx.setEnvelope(envelope);
+
             AxisEngine engine = new AxisEngine(outMsgCtx.getConfigurationContext());
-            engine.receive(responseMsgCtx);
+            if (envelope.getBody().hasFault()) {
+                engine.receiveFault(responseMsgCtx);
+            } else {
+                engine.receive(responseMsgCtx);
+            }
         } catch (AxisFault af) {
             af.printStackTrace();
         }

Modified: incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/NHttpListener.java
URL: http://svn.apache.org/viewvc/incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/NHttpListener.java?view=diff&rev=464159&r1=464158&r2=464159
==============================================================================
--- incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/NHttpListener.java (original)
+++ incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/NHttpListener.java Sun Oct 15 05:25:42 2006
@@ -192,7 +192,7 @@
         if (callback instanceof Axis2CallbackImpl) {
             Axis2CallbackImpl cb = (Axis2CallbackImpl) callback;
             cb.setResponse(response);
-            cb.run();
+            workerPool.execute(cb);
         }
     }
 

Modified: incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java
URL: http://svn.apache.org/viewvc/incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java?view=diff&rev=464159&r1=464158&r2=464159
==============================================================================
--- incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java (original)
+++ incubator/synapse/branches/NIO/modules/niohttp/src/org/apache/axis2/transport/niohttp/impl/ReadHandler.java Sun Oct 15 05:25:42 2006
@@ -121,18 +121,17 @@
                 return false;
             }
 
-            //if (log.isDebugEnabled()) {
-            debug("Read from socket to buffer position: " + readPos + " to: " + buffer.position());
-            debug(Util.dumpAsHex(buffer.array(), readPos));
-            //}
+            if (log.isDebugEnabled()) {
+                debug("Read from socket to buffer position: " + readPos + " to: " + buffer.position());
+                debug(Util.dumpAsHex(buffer.array(), readPos));
+            }
 
             // save position for next read
             readPos = buffer.position();
             return processIncomingMessage();
 
         } catch (IOException e) {
-            log.warn("Unexpected error reading from socket: " + socket +
-                " Closing connection : " + e.getMessage());
+            log.warn(e.getMessage() + " Closing socket: " + socket);
             try {
                 socket.close();
             } catch (IOException e1) {



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org