You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ru...@apache.org on 2009/08/01 14:36:50 UTC

svn commit: r799852 - in /synapse/branches/1.3: modules/core/src/main/java/org/apache/synapse/core/axis2/ modules/core/src/main/java/org/apache/synapse/mediators/builtin/ modules/samples/src/main/java/samples/userguide/ modules/samples/src/main/scripts...

Author: ruwan
Date: Sat Aug  1 12:36:49 2009
New Revision: 799852

URL: http://svn.apache.org/viewvc?rev=799852&view=rev
Log:
Applying the patch from Amila on https://issues.apache.org/jira/browse/SYNAPSE-548 for RM11 support

Added:
    synapse/branches/1.3/repository/conf/sample/synapse_sample_102.xml
    synapse/branches/1.3/repository/conf/sample/synapse_sample_202.xml
Modified:
    synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
    synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java
    synapse/branches/1.3/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java
    synapse/branches/1.3/modules/samples/src/main/scripts/axis2Client/build.xml
    synapse/branches/1.3/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java

Modified: synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
URL: http://svn.apache.org/viewvc/synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java?rev=799852&r1=799851&r2=799852&view=diff
==============================================================================
--- synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java (original)
+++ synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java Sat Aug  1 12:36:49 2009
@@ -28,6 +28,7 @@
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.OperationClient;
 import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
@@ -44,6 +45,9 @@
 import org.apache.synapse.transport.nhttp.NhttpConstants;
 import org.apache.synapse.endpoints.EndpointDefinition;
 import org.apache.synapse.util.MessageHelper;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.Sandesha2Constants;
 
 import javax.xml.namespace.QName;
 
@@ -340,7 +344,18 @@
         originalInMsgCtx.getOperationContext().setProperty(
             org.apache.axis2.Constants.RESPONSE_WRITTEN, "SKIP");
 
-        mepClient.execute(true);        
+        mepClient.execute(true);
+        if (wsRMEnabled) {
+            Object rm11 = clientOptions.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
+            if ( (rm11 != null) && rm11.equals(Sandesha2Constants.SPEC_VERSIONS.v1_1)){
+                ServiceClient serviceClient = new ServiceClient(
+                        axisOutMsgCtx.getConfigurationContext(), axisOutMsgCtx.getAxisService());
+                serviceClient.setTargetEPR(new EndpointReference(endpoint.getAddress()));
+                serviceClient.setOptions(clientOptions);
+                serviceClient.getOptions().setTo(new EndpointReference(endpoint.getAddress()));
+                SandeshaClient.terminateSequence(serviceClient);
+            }
+        }
    }
 
     private static MessageContext cloneForSend(MessageContext ori, String preserveAddressing)

Modified: synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java
URL: http://svn.apache.org/viewvc/synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java?rev=799852&r1=799851&r2=799852&view=diff
==============================================================================
--- synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java (original)
+++ synapse/branches/1.3/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java Sat Aug  1 12:36:49 2009
@@ -75,14 +75,11 @@
             orgMessageCtx.getOptions().setProperty(
                 SandeshaClientConstants.RM_SPEC_VERSION, version);
 
+            // always we need to start a new sequence if there is an terminated sequence
+            orgMessageCtx.getOptions().setProperty(
+                        SandeshaClientConstants.AUTO_START_NEW_SEQUENCE, "true");
+
             if (isSingle()) {
-//                String sequenceID = UUIDGenerator.getUUID();
-//                String offeredSeqID = UUIDGenerator.getUUID();
-//
-//                orgMessageCtx.getOptions().setProperty(
-//                    SynapseConstants.MERCURY_SEQUENCE_KEY, sequenceID);
-//                orgMessageCtx.getOptions().setProperty(
-//                    MercuryClientConstants.SEQUENCE_OFFER, offeredSeqID);
                 orgMessageCtx.getOptions().setProperty(
                     SandeshaClientConstants.LAST_MESSAGE, "true");
 

Modified: synapse/branches/1.3/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java
URL: http://svn.apache.org/viewvc/synapse/branches/1.3/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java?rev=799852&r1=799851&r2=799852&view=diff
==============================================================================
--- synapse/branches/1.3/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java (original)
+++ synapse/branches/1.3/modules/samples/src/main/java/samples/userguide/StockQuoteClient.java Sat Aug  1 12:36:49 2009
@@ -34,6 +34,8 @@
 import org.apache.neethi.PolicyEngine;
 import org.apache.rampart.RampartMessageData;
 import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.client.SandeshaClient;
+import org.apache.sandesha2.Sandesha2Constants;
 import org.apache.synapse.util.UUIDGenerator;
 import samples.common.StockQuoteHandler;
 
@@ -114,6 +116,7 @@
         String svcPolicy = getProperty("policy", null);
         String rest = getProperty("rest", null);
         String wsrm = getProperty("wsrm", null);
+        String wsrm11 = getProperty("wsrm11", null);
         String itr = getProperty("itr", "1");
         int iterations = 1;
         boolean infinite = false;
@@ -207,12 +210,14 @@
             System.out.println("Sending as REST");
             options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
         }
-        if (Boolean.parseBoolean(wsrm)) {
+        if (Boolean.parseBoolean(wsrm) || Boolean.parseBoolean(wsrm11)) {
             System.out.println("Using WS-RM");
             serviceClient.engageModule("sandesha2");
+            if (Boolean.parseBoolean(wsrm11)){
+               options.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, Sandesha2Constants.SPEC_VERSIONS.v1_1);
+            }
             options.setProperty(SandeshaClientConstants.LAST_MESSAGE, Constants.VALUE_TRUE);
-            options.setProperty(
-                    SandeshaClientConstants.OFFERED_SEQUENCE_ID, UUIDGenerator.getUUID());
+            options.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID, UUIDGenerator.getUUID());
         }
 
         if ("soap12".equals(soapVer)) {
@@ -239,8 +244,11 @@
                 InnerStruct.RESULT = serviceClient.sendReceive(payload);
                 i++;
                 printResult();
-                if (Boolean.parseBoolean(wsrm)) {
+                if (Boolean.parseBoolean(wsrm) || Boolean.parseBoolean(wsrm11)) {
                     // give some time for RM to terminate normally
+                    if (Boolean.parseBoolean(wsrm11)){
+                        SandeshaClient.terminateSequence(serviceClient);
+                    }
                     Thread.sleep(5000);
                     if (configContext != null) {
                         configContext.getListenerManager().stop();

Modified: synapse/branches/1.3/modules/samples/src/main/scripts/axis2Client/build.xml
URL: http://svn.apache.org/viewvc/synapse/branches/1.3/modules/samples/src/main/scripts/axis2Client/build.xml?rev=799852&r1=799851&r2=799852&view=diff
==============================================================================
--- synapse/branches/1.3/modules/samples/src/main/scripts/axis2Client/build.xml (original)
+++ synapse/branches/1.3/modules/samples/src/main/scripts/axis2Client/build.xml Sat Aug  1 12:36:49 2009
@@ -37,6 +37,7 @@
             [-Dprxurl=http://localhost:8280]
             [-Drest=true]
             [-Dwsrm=true]
+            [-Dwsrm11=true]
             [-Dpolicy=../../repository/conf/sample/resources/policy/policy_1.xml]
 
         Mode :
@@ -126,6 +127,7 @@
     <property name="policy" value=""/>
     <property name="rest" value=""/>
     <property name="wsrm" value=""/>
+    <property name="wsrm11" value=""/>
     <property name="itr" value=""/>
     <property name="jms_dest" value=""/>
     <property name="jms_type" value=""/>
@@ -170,6 +172,7 @@
             <sysproperty key="policy" value="${policy}"/>
             <sysproperty key="rest" value="${rest}"/>
             <sysproperty key="wsrm" value="${wsrm}"/>
+            <sysproperty key="wsrm11" value="${wsrm11}"/>
             <sysproperty key="itr" value="${itr}"/>
             <sysproperty key="javax.net.ssl.trustStore" value="./../../lib/trust.jks"/>
             <sysproperty key="javax.net.ssl.trustStorePassword" value="password"/>

Modified: synapse/branches/1.3/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java
URL: http://svn.apache.org/viewvc/synapse/branches/1.3/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java?rev=799852&r1=799851&r2=799852&view=diff
==============================================================================
--- synapse/branches/1.3/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java (original)
+++ synapse/branches/1.3/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/ServerWorker.java Sat Aug  1 12:36:49 2009
@@ -258,9 +258,9 @@
         // is received to synapse. Otherwise we will not be able to support the single channel
         // invocation within the actual service and synapse for a dual channel request from the
         // client. This condition is a bit complex but cannot simplify any further.
-        if (msgContext != null &&
-            msgContext.getOperationContext() != null &&
-            !msgContext.getOperationContext().getAxisOperation().isControlOperation()) {
+        if (msgContext != null && msgContext.getOperationContext() != null &&
+                (!msgContext.getOperationContext().getAxisOperation().isControlOperation() ||
+                        msgContext.isPropertyTrue(NhttpConstants.FORCE_SC_ACCEPTED))) {
 
             String respWritten = (String)
                 msgContext.getOperationContext().getProperty(Constants.RESPONSE_WRITTEN);

Added: synapse/branches/1.3/repository/conf/sample/synapse_sample_102.xml
URL: http://svn.apache.org/viewvc/synapse/branches/1.3/repository/conf/sample/synapse_sample_102.xml?rev=799852&view=auto
==============================================================================
--- synapse/branches/1.3/repository/conf/sample/synapse_sample_102.xml (added)
+++ synapse/branches/1.3/repository/conf/sample/synapse_sample_102.xml Sat Aug  1 12:36:49 2009
@@ -0,0 +1,44 @@
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you 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.
+  -->
+    
+<!-- Reliable message exchange between Synapse and the back-end server using WS-ReliableMessaging -->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+    <in>
+        <RMSequence single="true" version="1.1"/>
+        <send>
+        	<endpoint name="reliable">
+    			<address uri="http://localhost:9000/services/ReliableStockQuoteService">
+	    			<enableRM/>
+		    		<enableAddressing/>
+			    </address>
+            </endpoint>
+        </send>
+    </in>
+    <out>
+        <header name="wsrm:SequenceAcknowledgement" action="remove"
+                xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+        <header name="wsrm:Sequence" action="remove"
+                xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+        <header name="wsrm:AckRequested" action="remove"
+                xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+        <send/>
+    </out>
+
+</definitions>

Added: synapse/branches/1.3/repository/conf/sample/synapse_sample_202.xml
URL: http://svn.apache.org/viewvc/synapse/branches/1.3/repository/conf/sample/synapse_sample_202.xml?rev=799852&view=auto
==============================================================================
--- synapse/branches/1.3/repository/conf/sample/synapse_sample_202.xml (added)
+++ synapse/branches/1.3/repository/conf/sample/synapse_sample_202.xml Sat Aug  1 12:36:49 2009
@@ -0,0 +1,44 @@
+<!--
+  ~  Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you 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.
+  -->
+    
+<!-- Reliable message exchange between the client and proxy services using WS-ReliableMessaging -->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+    <proxy name="StockQuoteProxy">
+        <target>
+            <inSequence>
+                <header name="wsrm:SequenceAcknowledgement" action="remove"
+                        xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                <header name="wsrm:Sequence" action="remove"
+                        xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                <header name="wsrm:AckRequested" action="remove"
+                        xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
+                <send>
+                    <endpoint>
+                        <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
+                    </endpoint>
+                </send>
+            </inSequence>
+			<outSequence>
+				<send/>
+			</outSequence>
+        </target>
+        <publishWSDL uri="file:repository/conf/sample/resources/proxy/sample_proxy_1.wsdl"/>
+        <enableRM/>
+    </proxy>
+</definitions>