axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r489259 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: Constants.java transport/RequestResponseTransport.java transport/http/AxisServlet.java transport/http/HTTPWorker.java transport/http/util/SOAPUtil.java
Date Thu, 21 Dec 2006 03:39:22 GMT
Author: chamikara
Date: Wed Dec 20 19:39:21 2006
New Revision: 489259

URL: http://svn.apache.org/viewvc?view=rev&rev=489259
Log:
Added a mechanism to give the current state of the RequestResponseTransport. This could be
used by RM 
in resending of messages. Message will be allowed to be resent only if the RequestResponseTranspor
object 
is in the correct state.

Added a mechanism to allow somebody to set an custom transport response code. 
For e.g. Sandesha2 has a requirement to return HTTP 408, but there was not way do do this
in Axis2.

Added a boolean property which should be used by transports to decide weather or not a certain
request 
thread should be blocked (by calling RequestResponseTransport.awaitResponse () ) object. Simply
doing 
this based on wehater or not the request has been is paused is not enough in some cases.

Please see javadocs for more details.

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/AxisServlet.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPWorker.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.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=489259&r1=489258&r2=489259
==============================================================================
--- 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 Dec
20 19:39:21 2006
@@ -192,6 +192,11 @@
     public static final String RESPONSE_WRITTEN = "CONTENT_WRITTEN";
     //To have a floag if the replyTo is not annon one
     public static final String DIFFERENT_EPR = "DIFFERENT_EPR";
+    
+    /**
+     * This can be set in the MessageContext to give an response code the transport should
use when sending it out.
+     */
+    public static final String RESPONSE_CODE = "RESPONSE_CODE";
 
     /**
      * Transport Info

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=489259&r1=489258&r2=489259
==============================================================================
--- 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 Dec 20 19:39:21 2006
@@ -18,6 +18,7 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.Handler.InvocationResponse;
 
 /**
  * This interface represents a control object for a Request/Response transport.
@@ -30,10 +31,17 @@
  */
 public interface RequestResponseTransport
 {
+	
   /*This is the name of the property that is to be stored on the
     MessageContext*/
   public static final String TRANSPORT_CONTROL
     = "RequestResponseTransportControl";
+  
+  /**
+   * If this property is set to true in a message transport will call the awaitResponse method
+   * of the RequestResponseTransport instead of returning. The value should be a Boolean
object.
+   */
+  public static final String HOLD_RESPONSE = "HoldResponse";
 
   /**
    * Notify the transport that a message should be acknowledged at this time.
@@ -60,4 +68,55 @@
    * should release anyone who is blocked on a awaitResponse().
    */
   public void signalResponseReady();
+  
+  /**
+   * This gives the current status of an RequestResponseTransport object.  
+   * @return
+   */
+  public RequestResponseTransportStatus getStatus ();
+  
+  /**
+   * Used to give the current status of the RequestResponseTransport object.
+   */
+  public class RequestResponseTransportStatus {
+	  /**
+	   * Transport is in its initial stage.
+	   */
+	  public static RequestResponseTransportStatus INITIAL = new RequestResponseTransportStatus
(1);
+	  
+	  /**
+	   * awaitResponse has been called.
+	   */
+	  public static RequestResponseTransportStatus WAITING = new RequestResponseTransportStatus
(2);
+	  
+	  /**
+	   * 'signalResponseReady' has been called.
+	   */
+	  public static RequestResponseTransportStatus SIGNALLED = new RequestResponseTransportStatus
(3);
+	  
+	  private int value;
+	  
+	  private RequestResponseTransportStatus (int value) {
+		  this.value = value;
+	  }
+	  
+      public int hashCode()
+      {
+        return value;
+      }
+      
+      public boolean equals(Object obj) {
+        if( !(obj instanceof RequestResponseTransportStatus) ) {
+            return false;
+        }
+        final RequestResponseTransportStatus instance = (RequestResponseTransportStatus)obj;
+        return (value==instance.value);
+      }
+	  
+      public String toString() {
+    	  return Integer.toString(value);
+      }
+      
+  }
+  
 }

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=489259&r1=489258&r2=489259
==============================================================================
--- 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 Dec 20 19:39:21 2006
@@ -37,6 +37,7 @@
 import org.apache.axis2.engine.Handler.InvocationResponse;
 import org.apache.axis2.transport.RequestResponseTransport;
 import org.apache.axis2.transport.TransportListener;
+import org.apache.axis2.transport.RequestResponseTransport.RequestResponseTransportStatus;
 import org.apache.axis2.transport.http.server.HttpUtils;
 import org.apache.axis2.transport.http.util.RESTUtil;
 import org.apache.axis2.util.JavaUtils;
@@ -552,6 +553,7 @@
     {
       private HttpServletResponse response;
       private CountDownLatch responseReadySignal = new CountDownLatch(1);
+      RequestResponseTransportStatus status = RequestResponseTransportStatus.INITIAL;
       
       ServletRequestResponseTransport(HttpServletResponse response)
       {
@@ -581,13 +583,21 @@
       throws InterruptedException
       {
         log.debug("Blocking servlet thread -- awaiting response");
+  	  	status = RequestResponseTransportStatus.WAITING;
         responseReadySignal.await();
       }
       
       public void signalResponseReady()
       {
         log.debug("Signalling response available");
+  	    status = RequestResponseTransportStatus.SIGNALLED;
         responseReadySignal.countDown();
       }
+
+	public RequestResponseTransportStatus getStatus() {
+		return status;
+	}
+      
+      
     }
 }

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=489259&r1=489258&r2=489259
==============================================================================
--- 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 Dec 20 19:39:21 2006
@@ -242,7 +242,9 @@
                     soapAction,
                     uri);
 
-            if (pi.equals(InvocationResponse.SUSPEND))
+            Boolean holdResponse = (Boolean) msgContext.getProperty(RequestResponseTransport.HOLD_RESPONSE);
+            
+            if (pi.equals(InvocationResponse.SUSPEND) ||  (holdResponse!=null &&
Boolean.TRUE.equals(holdResponse)))
             {
               try
               {
@@ -284,7 +286,9 @@
 
     class SimpleHTTPRequestResponseTransport implements RequestResponseTransport
     {
+    	
       private CountDownLatch responseReadySignal = new CountDownLatch(1);
+      RequestResponseTransportStatus status = RequestResponseTransportStatus.INITIAL;
       
       public void acknowledgeMessage(MessageContext msgContext) throws AxisFault
       {
@@ -292,15 +296,21 @@
         signalResponseReady();
       }
       
-      public void awaitResponse()
-      throws InterruptedException
+      public void awaitResponse() throws InterruptedException
       {
-        responseReadySignal.await();
+    	  status = RequestResponseTransportStatus.WAITING;
+    	  responseReadySignal.await();
       }
       
       public void signalResponseReady()
       {
-        responseReadySignal.countDown();
+    	  status = RequestResponseTransportStatus.SIGNALLED;
+    	  responseReadySignal.countDown();
+      }
+
+      public RequestResponseTransportStatus getStatus() {
+		return status;
       }
+      
     }
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.java?view=diff&rev=489259&r1=489258&r2=489259
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/util/SOAPUtil.java
Wed Dec 20 19:39:21 2006
@@ -74,7 +74,11 @@
                                     + msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING));
 
             if ((contextWritten == null) || !Constants.VALUE_TRUE.equals(contextWritten))
{
-                response.setStatus(HttpServletResponse.SC_ACCEPTED);
+            	Integer statusCode = (Integer) msgContext.getProperty(Constants.RESPONSE_CODE);
+            	if (statusCode!=null) 
+            		response.setStatus(statusCode.intValue());
+            	else
+            		response.setStatus(HttpServletResponse.SC_ACCEPTED);
             }
 
             boolean closeReader = true;



---------------------------------------------------------------------
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