axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r480660 - in /webservices/axis2/trunk/java/modules: kernel/src/org/apache/axis2/engine/ kernel/src/org/apache/axis2/transport/ kernel/src/org/apache/axis2/transport/http/ samples/quickstartaxiom/src/samples/quickstart/clients/
Date Wed, 29 Nov 2006 17:56:03 GMT
Author: nagy
Date: Wed Nov 29 09:56:02 2006
New Revision: 480660

URL: http://svn.apache.org/viewvc?view=rev&rev=480660
Log:
Added a control object/callback to the transport to allow other components to provide processing
information to the transport.  The modifications in this patch allow the AxisServlet to be
notified when a one-way message has be processed far enough to be ack'd as per the specs.
 (A similar change, although warranted, was not made to the SimpleHTTPServer, as the API does
not seem to provide a means to return a response without unwinding the call stack.)  The quickstart
sample was modified to fix a dependency that it had upon fire-and-forget invocations not returning
until the one-way message had been completely processed on the server side (at least in the
case of Axis2.)

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java
    webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java?view=diff&rev=480660&r1=480659&r2=480660
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java
Wed Nov 29 09:56:02 2006
@@ -1,10 +1,13 @@
 package org.apache.axis2.engine;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.transport.RequestResponseTransport;
+import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004Constants;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -65,6 +68,17 @@
         if ((msgContext.getAxisService() == null) && (msgContext.getServiceContext()
!= null)) {
             msgContext.setAxisService(msgContext.getServiceContext().getAxisService());
         }
+        
+        //TODO: The same thing should probably happen for a IN-OUT if addressing is enabled
and the replyTo/faultTo are not anonymous 
+        if (msgContext.getAxisOperation().getMessageExchangePattern().equals(WSDL20_2004Constants.MEP_URI_IN_ONLY))
+        {
+          Object requestResponseTransport = msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
+          if (requestResponseTransport != null)
+          {
+            ((RequestResponseTransport)requestResponseTransport).acknowledgeMessage(msgContext);
+          }
+        }
+
         ArrayList operationChain = msgContext.getAxisOperation().getRemainingPhasesInFlow();
         msgContext.setExecutionChain((ArrayList) operationChain.clone());
     }

Added: 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=auto&rev=480660
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java
(added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/RequestResponseTransport.java
Wed Nov 29 09:56:02 2006
@@ -0,0 +1,42 @@
+/*
+* Copyright 2006 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.transport;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+
+/**
+ * This interface represents a control object for a Request/Response transport.
+ * The normal flow of Axis2 is rooted at the transport -- this does not
+ * allow for an acknowledgement to be transmitted before processing has
+ * completed, nor does it allow for processing to be paused and resumed
+ * on a separate thread without having a response be sent back.  This interface
+ * enables both of those scenarios by allowing the transport to expose
+ * controls to the rest of the engine via a callback.     
+ */
+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";
+
+  public void acknowledgeMessage(MessageContext msgContext) throws AxisFault;
+  
+  //public void suspendOnReturn(MessageContext msgContext);
+  //public void processResponse(MessageContext msgContext);
+}

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=480660&r1=480659&r2=480660
==============================================================================
--- 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 Nov 29 09:56:02 2006
@@ -32,6 +32,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.transport.RequestResponseTransport;
 import org.apache.axis2.transport.TransportListener;
 import org.apache.axis2.transport.http.server.HttpUtils;
 import org.apache.axis2.transport.http.util.RESTUtil;
@@ -98,6 +99,8 @@
 
         msgContext.setProperty(Constants.OUT_TRANSPORT_INFO,
                 new ServletBasedOutTransportInfo(resp));
+        msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
+                               new ServletRequestResponseTransport(resp));
         msgContext.setProperty(MessageContext.REMOTE_ADDR, req.getRemoteAddr());
         msgContext.setFrom(new EndpointReference(req.getRemoteAddr()));
         msgContext.setProperty(MessageContext.TRANSPORT_HEADERS,
@@ -539,5 +542,31 @@
 
         return ((soapActionHeader == null) ||
                 (contentType != null && contentType.indexOf(HTTPConstants.MEDIA_TYPE_X_WWW_FORM)
> -1));
+    }
+    
+    class ServletRequestResponseTransport implements RequestResponseTransport
+    {
+      private HttpServletResponse response;
+      
+      ServletRequestResponseTransport(HttpServletResponse response)
+      {
+        this.response = response;
+      }
+      
+      public void acknowledgeMessage(MessageContext msgContext) throws AxisFault
+      {
+        response.setContentType("text/xml; charset="
+                                + msgContext.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING));
+        
+        response.setStatus(HttpServletResponse.SC_ACCEPTED);
+        try
+        {
+          response.flushBuffer();
+        }
+        catch (IOException e)
+        {
+          throw new AxisFault("Error sending acknowledgement", e);
+        }
+      }
     }
 }

Modified: webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java?view=diff&rev=480660&r1=480659&r2=480660
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java
(original)
+++ webservices/axis2/trunk/java/modules/samples/quickstartaxiom/src/samples/quickstart/clients/AXIOMClient.java
Wed Nov 29 09:56:02 2006
@@ -58,6 +58,7 @@
 
             sender.fireAndForget(updatePayload);
             System.err.println("done");
+            Thread.sleep(3000);
             OMElement result = sender.sendReceive(getPricePayload);
 
             String response = result.getFirstElement().getText();



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