You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ri...@apache.org on 2006/12/07 18:23:11 UTC

svn commit: r483558 - in /incubator/tuscany/java: samples/sca/loanappconversationWS/src/main/resources/wsdl/ samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/ samples/sca/loanappconversationWSClient/src/main/resources/wsdl/ sca...

Author: rineholt
Date: Thu Dec  7 09:23:10 2006
New Revision: 483558

URL: http://svn.apache.org/viewvc?view=rev&rev=483558
Log:
fix up sequence in message.
add to conversation test some testing of state

Added:
    incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/resources/wsdl/loanappconversation.wsdl
Modified:
    incubator/tuscany/java/samples/sca/loanappconversationWS/src/main/resources/wsdl/loanappconversation.wsdl
    incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanAppConversationClient.java
    incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClient.java
    incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClientImpl.java
    incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java

Modified: incubator/tuscany/java/samples/sca/loanappconversationWS/src/main/resources/wsdl/loanappconversation.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversationWS/src/main/resources/wsdl/loanappconversation.wsdl?view=diff&rev=483558&r1=483557&r2=483558
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversationWS/src/main/resources/wsdl/loanappconversation.wsdl (original)
+++ incubator/tuscany/java/samples/sca/loanappconversationWS/src/main/resources/wsdl/loanappconversation.wsdl Thu Dec  7 09:23:10 2006
@@ -71,10 +71,7 @@
 			<xsd:element name="cancelApplication">
 			  <xsd:complexType/>
             </xsd:element>
-			<xsd:element name="cancelApplicationResponse">
-			  <xsd:complexType/>
-            </xsd:element>
-
+            
 			<xsd:element name="getLoanStatus">
 			  <xsd:complexType/>
             </xsd:element>
@@ -105,6 +102,11 @@
 			  <xsd:complexType/>
             </xsd:element>
 
+			<xsd:element name="closeResponse">
+			  <xsd:complexType/>
+            </xsd:element>
+
+
 		</xsd:schema>
 	</wsdl:types>
 	
@@ -130,12 +132,7 @@
 	<wsdl:message name="cancelApplicationRequest">
 		<wsdl:part element="loanservice:cancelApplication" name="cancelApplicationRequest" />
 	</wsdl:message>
-
-	<wsdl:message name="cancelApplicationResponse">
-		<wsdl:part element="loanservice:cancelApplicationResponse"
-			name="cancelApplicationResponse" />
-	</wsdl:message>
-
+	
 	<wsdl:message name="getLoanStatusRequest">
 		<wsdl:part element="loanservice:getLoanStatus" name="getLoanStatusRequest" />
 	</wsdl:message>
@@ -159,6 +156,10 @@
 		<wsdl:part element="loanservice:close" name="closeRequest" />
 	</wsdl:message>
 	
+	<wsdl:message name="closeResponse">
+		<wsdl:part element="loanservice:close" name="closeResponse" />
+	</wsdl:message>
+
 
 	<wsdl:portType name="LoanService">
 		<wsdl:operation name="apply">
@@ -173,7 +174,6 @@
 
 		<wsdl:operation name="cancelApplication">
 			<wsdl:input message="loanservice:cancelApplicationRequest" />
-			<wsdl:output message="loanservice:cancelApplicationResponse" />
 		</wsdl:operation>
 
 		<wsdl:operation name="getLoanStatus">
@@ -188,7 +188,7 @@
 
 		<wsdl:operation name="close">
 			<wsdl:input message="loanservice:closeRequest" />
-			<wsdl:output message="loanservice:displayResponse" />
+			<wsdl:output message="loanservice:closeResponse" />
 		</wsdl:operation>
 
 	</wsdl:portType>
@@ -224,9 +224,6 @@
 			<wsdl:input>
 				<soap:body use="literal" />
 			</wsdl:input>
-			<wsdl:output>
-				<soap:body use="literal" />
-			</wsdl:output>
 		</wsdl:operation>
 
 		<wsdl:operation name="getLoanStatus">
@@ -271,4 +268,4 @@
 				location="http://localhost:8080/sample-loanappconversationWS/services/LoanService" />
 		</wsdl:port>
 	</wsdl:service>
-</wsdl:definitions>
+</wsdl:definitions>
\ No newline at end of file

Modified: incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanAppConversationClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanAppConversationClient.java?view=diff&rev=483558&r1=483557&r2=483558
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanAppConversationClient.java (original)
+++ incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanAppConversationClient.java Thu Dec  7 09:23:10 2006
@@ -18,6 +18,7 @@
  */
 package loanappconversation;
 
+//import org.apache.tuscany.spi.component.TargetNotFoundException;
 import org.osoa.sca.CompositeContext;
 import org.osoa.sca.CurrentCompositeContext;
 
@@ -28,8 +29,29 @@
         CompositeContext context = CurrentCompositeContext.getContext();
 
         LoanClient loanClient = context.locateService(LoanClient.class, "LoanClientComponent");
+        assert loanClient != null : "loanClient was not resolved!";
         loanClient.applyForLoan("John Doe", 1000.0f);
-        System.out.println(loanClient.displayLoan());
-        System.out.println("Loan approved: " + loanClient.isApproved());
+        assert loanClient.isOpen() : "Failed loan not in approved state";
+        System.out.println("Loan opened: " + loanClient.displayLoan());
+        
+        
+        loanClient.cancelLoan();
+        System.out.println("Sleeping to let cancel complete ...");
+        Thread.sleep(5000);
+        
+        assert loanClient.isCancelled() : "Failed to cancel loan";
+        System.out.println("Cancelled: " + loanClient.displayLoan());
+        
+        loanClient.closeLoan();
+        
+        System.out.println("Closing for a second time!");
+        try{
+            loanClient.closeLoan();
+            assert false : "close for second time incorrectly succeed";
+            System.out.println("Failed: close for second time incorrectly succeed.");
+        }catch(Exception e){
+            System.out.println("Second close successfully produced: '" + e.getClass().getName() +"'");
+        }
+        
     }
 }

Modified: incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClient.java?view=diff&rev=483558&r1=483557&r2=483558
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClient.java (original)
+++ incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClient.java Thu Dec  7 09:23:10 2006
@@ -22,6 +22,8 @@
 
     void applyForLoan(String customerName, float amount);
     boolean isApproved();
+    boolean isOpen();
+    boolean isCancelled();
     String displayLoan();
     void cancelLoan();
     void closeLoan();

Modified: incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClientImpl.java?view=diff&rev=483558&r1=483557&r2=483558
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClientImpl.java (original)
+++ incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/java/loanappconversation/LoanClientImpl.java Thu Dec  7 09:23:10 2006
@@ -24,6 +24,19 @@
     
     private LoanService loanService;
     
+    public boolean isApproved() {
+        return "approved".equals(loanService.getLoanStatus());
+    }
+
+    public boolean isOpen() {
+        return "open".equals(loanService.getLoanStatus());
+        
+    }
+
+    public boolean isCancelled() {
+       return "cancelled".equals(loanService.getLoanStatus());
+    }
+
     @Reference
     public void setLoanService(LoanService loanService) {
         this.loanService = loanService;
@@ -32,10 +45,6 @@
     public void applyForLoan(String customerName, float amount) {
        //prim loanService.apply(new LoanApplication(customerName, amount));
         loanService.apply(customerName, amount);
-    }
-    
-    public boolean isApproved() {
-        return loanService.getLoanStatus().equals("approved");
     }
     
     public String displayLoan() {

Added: incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/resources/wsdl/loanappconversation.wsdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/resources/wsdl/loanappconversation.wsdl?view=auto&rev=483558
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/resources/wsdl/loanappconversation.wsdl (added)
+++ incubator/tuscany/java/samples/sca/loanappconversationWSClient/src/main/resources/wsdl/loanappconversation.wsdl Thu Dec  7 09:23:10 2006
@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:loanservice="http://www.loanappconversation.com/loanservice"
+	targetNamespace="http://www.loanappconversation.com/loanservice"
+	name="LoanService">
+
+	<wsdl:types>
+		<xsd:schema targetNamespace="http://www.loanappconversation.com/loanservice"
+			xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+			xmlns:loanservice="http://www.loanappconversation.com/loanservice"
+			>
+			
+
+			<xsd:element name="apply">
+				<xsd:complexType>
+					<xsd:sequence>
+					<xsd:element name="customerName"
+						type="xsd:string" />
+					<xsd:element name="loanAmount"
+						type="xsd:float"  />
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+			<xsd:element name="applyResponse">
+			  <xsd:complexType/>
+            </xsd:element>
+<!--
+			<xsd:complexType name="LoanApplication">
+				<xsd:sequence>
+					<xsd:element name="customerName"
+						type="xsd:string"  />
+					<xsd:element name="loanAmount"
+						type="xsd:float" />
+				</xsd:sequence>
+			</xsd:complexType>
+-->
+			
+			<xsd:element name="lockCurrentRate">
+				<xsd:complexType>
+					<xsd:sequence>
+						<xsd:element name="termInYears" type="xsd:int" />
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+
+
+			<xsd:element name="lockCurrentRateResponse">
+			  <xsd:complexType/>
+            </xsd:element>
+
+			<xsd:element name="cancelApplication">
+			  <xsd:complexType/>
+            </xsd:element>
+            
+			<xsd:element name="getLoanStatus">
+			  <xsd:complexType/>
+            </xsd:element>
+			<xsd:element name="getLoanStatusResponse">
+				<xsd:complexType>
+					<xsd:sequence>
+						<xsd:element name="getLoanStatusReturn" type="xsd:string" />
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+
+			<xsd:element name="display">
+			  <xsd:complexType/>
+            </xsd:element>
+			
+
+			<xsd:element name="displayResponse">
+				<xsd:complexType>
+					<xsd:sequence>
+						<xsd:element name="displayReturn"
+							type="xsd:string" />
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+
+
+			<xsd:element name="close">
+			  <xsd:complexType/>
+            </xsd:element>
+
+			<xsd:element name="closeResponse">
+			  <xsd:complexType/>
+            </xsd:element>
+
+
+		</xsd:schema>
+	</wsdl:types>
+	
+	
+	<wsdl:message name="applyRequest">
+		<wsdl:part element="loanservice:apply"
+			name="applyRequest" />
+	</wsdl:message>
+	<wsdl:message name="applyResponse">
+		<wsdl:part element="loanservice:applyResponse"
+			name="applyResponse" />
+	</wsdl:message>
+
+	<wsdl:message name="lockCurrentRateRequest">
+		<wsdl:part element="loanservice:lockCurrentRate"
+			name="lockCurrentRate" />
+	</wsdl:message>
+	<wsdl:message name="lockCurrentRateResponse">
+		<wsdl:part element="loanservice:lockCurrentRateResponse"
+			name="lockCurrentRateResponse" />
+	</wsdl:message>
+
+	<wsdl:message name="cancelApplicationRequest">
+		<wsdl:part element="loanservice:cancelApplication" name="cancelApplicationRequest" />
+	</wsdl:message>
+	
+	<wsdl:message name="getLoanStatusRequest">
+		<wsdl:part element="loanservice:getLoanStatus" name="getLoanStatusRequest" />
+	</wsdl:message>
+
+	<wsdl:message name="getLoanStatusResponse">
+		<wsdl:part element="loanservice:getLoanStatusResponse"
+			name="getLoanStatusResponse" />
+	</wsdl:message>
+
+	<wsdl:message name="displayRequest">
+		<wsdl:part element="loanservice:display"
+			name="displayRequest" />
+	</wsdl:message>
+
+	<wsdl:message name="displayResponse">
+		<wsdl:part element="loanservice:displayResponse"
+			name="displayResponse" />
+	</wsdl:message>
+
+	<wsdl:message name="closeRequest">
+		<wsdl:part element="loanservice:close" name="closeRequest" />
+	</wsdl:message>
+	
+	<wsdl:message name="closeResponse">
+		<wsdl:part element="loanservice:close" name="closeResponse" />
+	</wsdl:message>
+
+
+	<wsdl:portType name="LoanService">
+		<wsdl:operation name="apply">
+			<wsdl:input message="loanservice:applyRequest" />
+			<wsdl:output message="loanservice:applyResponse" />
+		</wsdl:operation>
+
+		<wsdl:operation name="lockCurrentRate">
+			<wsdl:input message="loanservice:lockCurrentRateRequest" />
+			<wsdl:output message="loanservice:lockCurrentRateResponse" />
+		</wsdl:operation>
+
+		<wsdl:operation name="cancelApplication">
+			<wsdl:input message="loanservice:cancelApplicationRequest" />
+		</wsdl:operation>
+
+		<wsdl:operation name="getLoanStatus">
+			<wsdl:input message="loanservice:getLoanStatusRequest" />
+			<wsdl:output message="loanservice:getLoanStatusResponse" />
+		</wsdl:operation>
+
+		<wsdl:operation name="display">
+			<wsdl:input message="loanservice:displayRequest" />
+			<wsdl:output message="loanservice:displayResponse" />
+		</wsdl:operation>
+
+		<wsdl:operation name="close">
+			<wsdl:input message="loanservice:closeRequest" />
+			<wsdl:output message="loanservice:closeResponse" />
+		</wsdl:operation>
+
+	</wsdl:portType>
+
+
+	<wsdl:binding name="LoanServiceSOAP" type="loanservice:LoanService">
+		<soap:binding style="document"
+			transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="apply">
+			<soap:operation
+				soapAction="http://www.loanappconversation.com/loanservice/apply" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+		<wsdl:operation name="lockCurrentRate">
+			<soap:operation
+				soapAction="http://www.loanappconversation.com/loanservice/lockCurrentRate" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+
+		<wsdl:operation name="cancelApplication">
+			<soap:operation
+				soapAction="http://www.loanappconversation.com/loanservice/cancelApplication" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+		</wsdl:operation>
+
+		<wsdl:operation name="getLoanStatus">
+			<soap:operation
+				soapAction="http://www.loanappconversation.com/loanservice/getLoanStatus" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+
+		<wsdl:operation name="display">
+			<soap:operation
+				soapAction="http://www.loanappconversation.com/loanservice/display" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+
+		<wsdl:operation name="close">
+			<soap:operation
+				soapAction="http://www.loanappconversation.com/loanservice/close" />
+			<wsdl:input>
+				<soap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<soap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+
+
+	</wsdl:binding>
+	<wsdl:service name="LoanService">
+		<wsdl:port binding="loanservice:LoanServiceSOAP"
+			name="LoanServiceSOAP">
+			<soap:address
+				location="http://localhost:8080/sample-loanappconversationWS/services/LoanService" />
+		</wsdl:port>
+	</wsdl:service>
+</wsdl:definitions>
\ No newline at end of file

Modified: incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java?view=diff&rev=483558&r1=483557&r2=483558
==============================================================================
--- incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java (original)
+++ incubator/tuscany/java/sca/services/bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2Service.java Thu Dec  7 09:23:10 2006
@@ -20,9 +20,12 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 
 import javax.wsdl.Definition;
@@ -60,6 +63,7 @@
 import org.apache.tuscany.spi.wire.WireService;
 import org.osoa.sca.annotations.Destroy;
 
+// org.apache.tuscany.spi.model
 /**
  * An implementation of a {@link ServiceExtension} configured with the Axis2
  * binding
@@ -82,6 +86,8 @@
     private WorkContext workContext;
     
     private Boolean conversational= null;
+    
+    private Set<String> seenConversations= Collections.synchronizedSet( new HashSet<String>());
 
     public Axis2Service(String theName,
                         ServiceContract<?> serviceContract,
@@ -192,16 +198,12 @@
         }
         try {
             if (headInterceptor == null) {
-                try {
-                    // short-circuit the dispatch and invoke the target directly
-                    if (chain.getTargetInvoker() == null) {
-                        throw new AssertionError("No target invoker [" + chain.getOperation().getName() + "]");
-                    }
-                    return chain.getTargetInvoker().invokeTarget(args, TargetInvoker.NONE);
-                } catch (InvocationTargetException e) {
-                    // the cause was thrown by the target so throw it
-                    throw e;
+                // short-circuit the dispatch and invoke the target directly
+                TargetInvoker targetInvoker = chain.getTargetInvoker();
+                if (targetInvoker == null) {
+                    throw new AssertionError("No target invoker [" + chain.getOperation().getName() + "]");
                 }
+                return targetInvoker.invokeTarget(args, TargetInvoker.NONE);
             } else {
 
                 Message msg = new MessageImpl();
@@ -212,6 +214,29 @@
                 }
                 msg.setBody(args);
                 Message resp;
+                
+                if(isConversational()){
+                    
+                    
+                    int opSeq = op.getConversationSequence();
+                    if(opSeq == org.apache.tuscany.spi.model.Operation.CONVERSATION_END){
+                        assert seenConversations.contains(conversationID) : "End of conversation called when no conversation existed";
+                        msg.setConversationSequence(TargetInvoker.END);
+                        seenConversations.remove(conversationID); //if a fault occurs does the conversation end?
+                           //how do I know if a component called locally another opeation that ended this conversation?
+                        
+                    } else {
+                        boolean ec = seenConversations.contains(conversationID);
+                        if(ec){
+                          
+                            msg.setConversationSequence(TargetInvoker.CONTINUE);
+                        }else{
+                            seenConversations.add(conversationID);
+                            msg.setConversationSequence(TargetInvoker.START);
+                        }
+                    }
+                    
+                }
                 // dispatch the wire down the chain and get the response
                 // TODO http://issues.apache.org/jira/browse/TUSCANY-777
                 ClassLoader oldtccl = Thread.currentThread().getContextClassLoader();



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