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 ch...@apache.org on 2007/04/04 12:27:52 UTC

svn commit: r525485 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: Constants.java transport/RequestResponseTransport.java transport/http/AbstractHTTPSender.java transport/http/AxisServlet.java transport/http/HTTPWorker.java

Author: chamikara
Date: Wed Apr  4 03:27:43 2007
New Revision: 525485

URL: http://svn.apache.org/viewvc?view=rev&rev=525485
Log:
Added the following two changes.

1.
Currently when we send messages out using the HTTP transport, it is 
checked weather a MessageContext object has been set for the 'In' 
entry of the OperationContext. If this is present transport information 
is saved there, else they are ignored. In Sandesha2 we have a scenario
where this MessageContext is not present in the operation context (the 
incoming message may be a Acknowledgement which should not be added to 
the OpCtx of the application message). So we Axis2 to preserve the 
transport information even when MsgCtx is not set.
This was needed to keep Sandesha2+MTOM working for the 1.2 release

2.
Added a new method named 'signalFaultReady' to the RequestResponseTransport 
object. This will basially ask the Transport to end a current wait throwing 
the given fault. 




Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?view=diff&rev=525485&r1=525484&r2=525485
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Wed Apr  4 03:27:43 2007
@@ -319,6 +319,8 @@
          * @see org.apache.axis2.transport.MessageFormatter
          */
         public static final String MESSAGE_TYPE = "messageType";
-
+        
+        public static final String TRANSPORT_INFO_MAP = "TransportInfoMap";
+        
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java?view=diff&rev=525485&r1=525484&r2=525485
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java Wed Apr  4 03:27:43 2007
@@ -59,7 +59,7 @@
      *
      * @throws InterruptedException
      */
-    public void awaitResponse() throws InterruptedException;
+    public void awaitResponse() throws InterruptedException, AxisFault;
 
     /**
      * Signal that a response has be created and is ready for transmission.  This
@@ -67,6 +67,8 @@
      */
     public void signalResponseReady();
 
+    public void signalFaultReady(AxisFault fault);
+    
     /**
      * This gives the current status of an RequestResponseTransport object.
      *

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java?view=diff&rev=525485&r1=525484&r2=525485
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AbstractHTTPSender.java Wed Apr  4 03:27:43 2007
@@ -49,6 +49,7 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -217,20 +218,33 @@
             MessageContext inMessageContext = msgContext.getOperationContext().getMessageContext(
                     WSDLConstants.MESSAGE_LABEL_IN_VALUE);
 
+            Object contentType = header.getValue();
+            Object charSetEnc = null;
+            
+            for (int i = 0; i < headers.length; i++) {
+                NameValuePair charsetEnc = headers[i].getParameterByName(
+                        HTTPConstants.CHAR_SET_ENCODING);
+                if (charsetEnc != null) {
+                	charSetEnc = charsetEnc.getValue();    
+                }
+            }
+            
             if (inMessageContext != null) {
                 inMessageContext
-                        .setProperty(Constants.Configuration.CONTENT_TYPE, header.getValue());
-
-
-                for (int i = 0; i < headers.length; i++) {
-                    NameValuePair charsetEnc = headers[i].getParameterByName(
-                            HTTPConstants.CHAR_SET_ENCODING);
-                    if (charsetEnc != null) {
-                        inMessageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
-                                                     charsetEnc.getValue());    // change to the value, which is text/xml or application/xml+soap
-                    }
-                }
+                        .setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
+                inMessageContext
+                	.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
+            } else {
+            	
+            	//Transport details will be stored in a HashMap so that anybody interested can retriece them
+            	HashMap transportInfoMap = new HashMap ();
+            	transportInfoMap.put(Constants.Configuration.CONTENT_TYPE, contentType);
+            	transportInfoMap.put(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
+            	
+            	//the HashMap is stored in the outgoing message.
+            	msgContext.setProperty(Constants.Configuration.TRANSPORT_INFO_MAP, transportInfoMap);
             }
+            
         }
 
         String sessionCookie = null;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java?view=diff&rev=525485&r1=525484&r2=525485
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java Wed Apr  4 03:27:43 2007
@@ -687,7 +687,8 @@
         private HttpServletResponse response;
         private CountDownLatch responseReadySignal = new CountDownLatch(1);
         RequestResponseTransportStatus status = RequestResponseTransportStatus.INITIAL;
-
+        AxisFault faultToBeThrownOut = null;
+        
         ServletRequestResponseTransport(HttpServletResponse response) {
             this.response = response;
         }
@@ -710,10 +711,13 @@
         }
 
         public void awaitResponse()
-                throws InterruptedException {
+                throws InterruptedException,AxisFault {
             log.debug("Blocking servlet thread -- awaiting response");
             status = RequestResponseTransportStatus.WAITING;
             responseReadySignal.await();
+            
+            if (faultToBeThrownOut!=null)
+            	throw faultToBeThrownOut;
         }
 
         public void signalResponseReady() {
@@ -726,6 +730,11 @@
             return status;
         }
 
+		public void signalFaultReady(AxisFault fault) {
+			faultToBeThrownOut = fault;
+			signalResponseReady();
+		}
+		
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java?view=diff&rev=525485&r1=525484&r2=525485
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java Wed Apr  4 03:27:43 2007
@@ -315,15 +315,19 @@
 
         private CountDownLatch responseReadySignal = new CountDownLatch(1);
         RequestResponseTransportStatus status = RequestResponseTransportStatus.INITIAL;
-
+        AxisFault faultToBeThrownOut = null;
+        
         public void acknowledgeMessage(MessageContext msgContext) throws AxisFault {
             //TODO: Once the core HTTP API allows us to return an ack before unwinding, then the should be fixed
             signalResponseReady();
         }
 
-        public void awaitResponse() throws InterruptedException {
+        public void awaitResponse() throws InterruptedException,AxisFault {
             status = RequestResponseTransportStatus.WAITING;
             responseReadySignal.await();
+            
+            if (faultToBeThrownOut!=null)
+            	throw faultToBeThrownOut;
         }
 
         public void signalResponseReady() {
@@ -335,5 +339,10 @@
             return status;
         }
 
+		public void signalFaultReady(AxisFault fault) {
+			faultToBeThrownOut = fault;
+			signalResponseReady();
+		}
+        
     }
 }



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