axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hemap...@apache.org
Subject svn commit: r546634 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
Date Tue, 12 Jun 2007 21:04:27 GMT
Author: hemapani
Date: Tue Jun 12 14:04:26 2007
New Revision: 546634

URL: http://svn.apache.org/viewvc?view=rev&rev=546634
Log:
fix https://issues.apache.org/jira/browse/AXIS2-1363

Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java?view=diff&rev=546634&r1=546633&r2=546634
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractInOutAsyncMessageReceiver.java
Tue Jun 12 14:04:26 2007
@@ -18,6 +18,8 @@
 package org.apache.axis2.receivers;
 
 import org.apache.axis2.AxisFault;
+
+import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.util.MessageContextBuilder;
@@ -33,7 +35,7 @@
     public abstract void invokeBusinessLogic(MessageContext inMessage,
                                              MessageContext outMessage) throws AxisFault;
 
-    public final void receive(final MessageContext messageCtx) {
+    public final void receive(final MessageContext messageCtx) throws AxisFault {
         final ServerCallback callback = new ServerCallback() {
             public void handleResult(MessageContext result) throws AxisFault {
                 AxisEngine.send(result);
@@ -47,31 +49,57 @@
                 AxisEngine.sendFault(faultContext);
             }
         };
-        Runnable theadedTask = new Runnable() {
-            public void run() {
+        
+			
+        AsyncMessageReceiverWorker theadedTask = new AsyncMessageReceiverWorker(messageCtx,callback);
+		messageCtx.getEnvelope().build();
+		
+		
+		/**
+		 * If this type of Message Reciecer is used without addressing, the condtions given in
Jira 
+		 * https://issues.apache.org/jira/browse/AXIS2-1363 would occuer(Both 202 accepted and
200 OK is written to the 
+		 * output stream). To avoid it if addressing is not present we do not spawn a new thread.
This will disapper when
+		 * async message recivers are removed later
+		 */
+		
+		if(messageCtx.getReplyTo() != null 
+				&& !AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(messageCtx.getReplyTo().getAddress())
+				&& !AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(messageCtx.getReplyTo().getAddress())){
+			messageCtx.getConfigurationContext().getThreadPool().execute(theadedTask);
+		}else{
+			theadedTask.run();
+		}
+    }
+    public class AsyncMessageReceiverWorker implements Runnable{
+    	private MessageContext messageCtx;
+    	private ServerCallback callback;
+    	
+    	public AsyncMessageReceiverWorker(MessageContext messageCtx,ServerCallback callback){
+    		this.messageCtx = messageCtx;
+    		this.callback = callback;
+    	}
+    	
+        public void run() {
+            try {
+                MessageContext newmsgCtx =
+                        MessageContextBuilder.createOutMessageContext(messageCtx);
+                newmsgCtx.getOperationContext().addMessageContext(newmsgCtx);
+                ThreadContextDescriptor tc = setThreadContext(messageCtx);
+                try {
+                    invokeBusinessLogic(messageCtx, newmsgCtx);
+                } finally {
+                    restoreThreadContext(tc);
+                }
+                callback.handleResult(newmsgCtx);
+            } catch (AxisFault e) {
                 try {
-                    MessageContext newmsgCtx =
-                            MessageContextBuilder.createOutMessageContext(messageCtx);
-                    newmsgCtx.getOperationContext().addMessageContext(newmsgCtx);
-                    ThreadContextDescriptor tc = setThreadContext(messageCtx);
-                    try {
-                        invokeBusinessLogic(messageCtx, newmsgCtx);
-                    } finally {
-                        restoreThreadContext(tc);
-                    }
-                    callback.handleResult(newmsgCtx);
-                } catch (AxisFault e) {
-                    try {
-                        callback.handleFault(e);
-                    } catch (AxisFault axisFault) {
-                        log.error(e);
-                    }
+                    callback.handleFault(e);
+                } catch (AxisFault axisFault) {
                     log.error(e);
                 }
+                log.error(e);
             }
-        };
-
-        messageCtx.getEnvelope().build();
-        messageCtx.getConfigurationContext().getThreadPool().execute(theadedTask);
-    }
+        }
+    };
+    
 }



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


Mime
View raw message