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

svn commit: r474537 - in /incubator/tuscany/java: samples/sca/loanappconversation/ samples/sca/loanappconversation/src/ samples/sca/loanappconversation/src/main/ samples/sca/loanappconversation/src/main/java/ samples/sca/loanappconversation/src/main/ja...

Author: isilval
Date: Mon Nov 13 14:11:11 2006
New Revision: 474537

URL: http://svn.apache.org/viewvc?view=rev&rev=474537
Log:
Completing minimal implementation of conversational services, including sample
adapted from C&I spec. Still using org.apache.tuscany.spi.wire.MessageId in lieu
of a conversation id, need to change to java.util.UUID

Added:
    incubator/tuscany/java/samples/sca/loanappconversation/
    incubator/tuscany/java/samples/sca/loanappconversation/pom.xml
    incubator/tuscany/java/samples/sca/loanappconversation/src/
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanAppConversationClient.java
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanApplication.java
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanService.java
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanServiceImpl.java
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/resources/
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/resources/META-INF/
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/resources/META-INF/sca/
    incubator/tuscany/java/samples/sca/loanappconversation/src/main/resources/META-INF/sca/default.scdl
    incubator/tuscany/java/samples/sca/loanappconversation/src/test/
    incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/
    incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/
    incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java
Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java
    incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl

Added: incubator/tuscany/java/samples/sca/loanappconversation/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/pom.xml?view=auto&rev=474537
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversation/pom.xml (added)
+++ incubator/tuscany/java/samples/sca/loanappconversation/pom.xml Mon Nov 13 14:11:11 2006
@@ -0,0 +1,60 @@
+<?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.    
+-->
+<project>
+    <parent>
+        <groupId>org.apache.tuscany.samples.sca</groupId>
+        <artifactId>parent</artifactId>
+        <version>1.0-incubator-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>sample-loanappconversation</artifactId>
+    <packaging>jar</packaging>
+    <name>Tuscany Loan App Conversation Sample</name>
+    <description>A sample implementation of a loan application conversation.</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osoa</groupId>
+            <artifactId>sca-api-r0.95</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>test</artifactId>
+            <version>${tuscanyVersion}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>loanappconversation.LoanAppConversationClient</mainClass>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanAppConversationClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanAppConversationClient.java?view=auto&rev=474537
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanAppConversationClient.java (added)
+++ incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanAppConversationClient.java Mon Nov 13 14:11:11 2006
@@ -0,0 +1,35 @@
+/*
+ * 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.    
+ */
+package loanappconversation;
+
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class LoanAppConversationClient {
+
+    public static void main(String[] args) throws Exception {
+        // Locate the MyClient component and invoke it
+        CompositeContext context = CurrentCompositeContext.getContext();
+
+        LoanClient loanClient = context.locateService(LoanClient.class, "LoanClientComponent");
+        loanClient.applyForLoan("John Doe", 1000.0f);
+        System.out.println(loanClient.displayLoan());
+        System.out.println("Loan approved: " + loanClient.isApproved());
+    }
+}

Added: incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanApplication.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanApplication.java?view=auto&rev=474537
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanApplication.java (added)
+++ incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanApplication.java Mon Nov 13 14:11:11 2006
@@ -0,0 +1,35 @@
+/*
+ * 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.    
+ */
+package loanappconversation;
+
+public class LoanApplication {
+    
+    private String customerName;
+    private float loanAmount;
+    
+    public LoanApplication(String customerName, float loanAmount) {
+        this.customerName = customerName;
+        this.loanAmount = loanAmount;
+    }
+    
+    public String toString() {
+        return "[Customer: " + customerName + ", loan amount: "
+            + loanAmount + "]";
+    }
+}

Added: incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java?view=auto&rev=474537
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java (added)
+++ incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClient.java Mon Nov 13 14:11:11 2006
@@ -0,0 +1,27 @@
+/*
+ * 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.    
+ */
+package loanappconversation;
+
+public interface LoanClient {
+
+    void applyForLoan(String customerName, float amount);
+    boolean isApproved();
+    String displayLoan();
+    void cancelLoan();
+}

Added: incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java?view=auto&rev=474537
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java (added)
+++ incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanClientImpl.java Mon Nov 13 14:11:11 2006
@@ -0,0 +1,47 @@
+/*
+ * 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.    
+ */
+package loanappconversation;
+
+import org.osoa.sca.annotations.Reference;
+
+public class LoanClientImpl implements LoanClient {
+    
+    private LoanService loanService;
+    
+    @Reference
+    public void setLoanService(LoanService loanService) {
+        this.loanService = loanService;
+    }
+
+    public void applyForLoan(String customerName, float amount) {
+        loanService.apply(new LoanApplication(customerName, amount));
+    }
+    
+    public boolean isApproved() {
+        return loanService.getLoanStatus().equals("approved");
+    }
+    
+    public String displayLoan() {
+        return loanService.display();
+    }
+    
+    public void cancelLoan() {
+        loanService.cancelApplication();
+    }
+}

Added: incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanService.java?view=auto&rev=474537
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanService.java (added)
+++ incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanService.java Mon Nov 13 14:11:11 2006
@@ -0,0 +1,32 @@
+/*
+ * 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.    
+ */
+package loanappconversation;
+
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("CONVERSATIONAL")
+@Remotable
+public interface LoanService {
+    void apply(LoanApplication application);
+    void lockCurrentRate(int termInYears);
+    void cancelApplication();
+    String getLoanStatus();
+    String display();
+}

Added: incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanServiceImpl.java?view=auto&rev=474537
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanServiceImpl.java (added)
+++ incubator/tuscany/java/samples/sca/loanappconversation/src/main/java/loanappconversation/LoanServiceImpl.java Mon Nov 13 14:11:11 2006
@@ -0,0 +1,52 @@
+/*
+ * 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.    
+ */
+package loanappconversation;
+
+import org.osoa.sca.annotations.Scope;
+
+@Scope("CONVERSATIONAL")
+public class LoanServiceImpl implements LoanService {
+    
+    private LoanApplication application;
+    private String status;
+    private int termLocked = 0;
+
+    public void apply(LoanApplication application) {
+        this.application = application;
+        status = "open";
+    }
+    
+    public void lockCurrentRate(int termInYears) {
+        termLocked = termInYears;
+        status = "locked";
+    }
+    
+    public void cancelApplication() {
+        status = "cancelled";
+    }
+    
+    public String getLoanStatus() {
+        return status;
+    }
+    
+    public String display() {
+        return "Loan application: " + application + ", term: "
+        + termLocked + ", status: " + status;
+    }
+}

Added: incubator/tuscany/java/samples/sca/loanappconversation/src/main/resources/META-INF/sca/default.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/main/resources/META-INF/sca/default.scdl?view=auto&rev=474537
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversation/src/main/resources/META-INF/sca/default.scdl (added)
+++ incubator/tuscany/java/samples/sca/loanappconversation/src/main/resources/META-INF/sca/default.scdl Mon Nov 13 14:11:11 2006
@@ -0,0 +1,31 @@
+<?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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="simplecallback">
+
+    <component name="LoanClientComponent">
+        <implementation.java class="loanappconversation.LoanClientImpl"/>
+        <reference name="loanService">LoanServiceComponent</reference>
+    </component>
+    
+    <component name="LoanServiceComponent">
+        <implementation.java class="loanappconversation.LoanServiceImpl"/>
+    </component>
+    
+</composite>

Added: incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java?view=auto&rev=474537
==============================================================================
--- incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java (added)
+++ incubator/tuscany/java/samples/sca/loanappconversation/src/test/java/loanappconversation/LoanAppConversationTestCase.java Mon Nov 13 14:11:11 2006
@@ -0,0 +1,52 @@
+/*
+ * 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.    
+ */
+package loanappconversation;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class LoanAppConversationTestCase extends SCATestCase {
+
+    private LoanClient loanClient;
+
+    protected void setUp() throws Exception {
+        try {
+        setApplicationSCDL(LoanClient.class, "META-INF/sca/default.scdl");
+        super.setUp();
+
+        CompositeContext context = CurrentCompositeContext.getContext();
+        loanClient = context.locateService(LoanClient.class, "LoanClientComponent");
+        } catch(Throwable e) {
+            e.printStackTrace();
+        }
+    }
+
+    public void test() throws Exception {
+        try {
+        loanClient.applyForLoan("John Doe", 1000.0f);
+        System.out.println("Applied: " + loanClient.displayLoan());
+        System.out.println("Loan approved: " + loanClient.isApproved());
+        loanClient.cancelLoan();
+        System.out.println("Cancelled: " + loanClient.displayLoan());
+        } catch(Throwable e) {
+            e.printStackTrace();
+        }
+    }
+}

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java?view=diff&rev=474537&r1=474536&r2=474537
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java Mon Nov 13 14:11:11 2006
@@ -23,8 +23,13 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.tuscany.core.component.scope.ConversationalScopeContainer;
 import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+
 import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+
+import org.apache.tuscany.spi.model.InteractionScope;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.wire.AbstractOutboundInvocationHandler;
 import org.apache.tuscany.spi.wire.OutboundInvocationChain;
@@ -52,8 +57,15 @@
     private Map<Method, ChainHolder> chains;
     private Object fromAddress;
     private boolean contractHasCallback;
+    private boolean contractIsConversational;
+    
+    private WorkContext workContext;
 
-    public JDKOutboundInvocationHandler(OutboundWire wire)
+    public JDKOutboundInvocationHandler(OutboundWire wire) {
+        this(wire, null);
+    }
+    
+    public JDKOutboundInvocationHandler(OutboundWire wire, WorkContext workContext)
         throws NoMethodForOperationException {
         Map<Operation<?>, OutboundInvocationChain> invocationChains = wire.getInvocationChains();
         this.chains = new HashMap<Method, ChainHolder>(invocationChains.size());
@@ -69,6 +81,10 @@
             }
             this.chains.put(method, new ChainHolder(entry.getValue()));
         }
+        
+        this.workContext = workContext;
+        this.contractIsConversational =
+            wire.getServiceContract().getInteractionScope().equals(InteractionScope.CONVERSATIONAL);
     }
 
     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
@@ -110,6 +126,15 @@
             assert chain != null;
             invoker = chain.getTargetInvoker();
         }
+        
+        if (contractIsConversational) {
+            assert workContext != null : "Work context cannot be null for conversational invocation";
+            if (workContext.getIdentifier(ConversationalScopeContainer.CONVERSATIONAL_IDENTIFIER) == null) {
+                Object convID = new org.apache.tuscany.spi.wire.MessageId();
+                workContext.setIdentifier(ConversationalScopeContainer.CONVERSATIONAL_IDENTIFIER, convID);
+            }
+        }
+        
         return invoke(chain, invoker, args, null, null);
     }
 

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java?view=diff&rev=474537&r1=474536&r2=474537
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java Mon Nov 13 14:11:11 2006
@@ -97,7 +97,7 @@
             return Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler);
         } else if (wire instanceof OutboundWire) {
             OutboundWire outbound = (OutboundWire) wire;
-            JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(outbound);
+            JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(outbound, context);
             Class<?> interfaze = outbound.getServiceContract().getInterfaceClass();
             ClassLoader cl = interfaze.getClassLoader();
             return Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler);
@@ -124,7 +124,7 @@
             return new JDKInboundInvocationHandler(chains, context);
         } else if (wire instanceof OutboundWire) {
             OutboundWire outbound = (OutboundWire) wire;
-            return new JDKOutboundInvocationHandler(outbound);
+            return new JDKOutboundInvocationHandler(outbound, context);
         } else {
             ProxyCreationException e = new ProxyCreationException("Invalid wire type");
             e.setIdentifier(wire.getClass().getName());

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java?view=diff&rev=474537&r1=474536&r2=474537
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java Mon Nov 13 14:11:11 2006
@@ -31,6 +31,7 @@
 import org.apache.tuscany.spi.idl.InvalidServiceContractException;
 import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
 import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.InteractionScope;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.model.ServiceContract;
 import org.apache.tuscany.spi.wire.InboundWire;
@@ -211,6 +212,7 @@
         throws InvalidServiceContractException {
         OutboundWire wire = new OutboundWireImpl();
         JavaServiceContract contract = new JavaServiceContract(interfaze);
+        contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
         wire.setServiceContract(contract);
         wire.setTargetName(targetName);
         wire.addInvocationChains(createInvocationChains(interfaze));

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java?view=diff&rev=474537&r1=474536&r2=474537
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandlerTestCase.java Mon Nov 13 14:11:11 2006
@@ -21,6 +21,8 @@
 import java.lang.reflect.Proxy;
 
 import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.InteractionScope;
+import org.apache.tuscany.spi.model.ServiceContract;
 
 import junit.framework.TestCase;
 
@@ -33,7 +35,9 @@
 
     public void testToString() {
         OutboundWireImpl wire = new OutboundWireImpl();
-        wire.setServiceContract(new JavaServiceContract(Foo.class));
+        ServiceContract contract = new JavaServiceContract(Foo.class);
+        contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
+        wire.setServiceContract(contract);
         JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
         assertNotNull(foo.toString());
@@ -41,7 +45,9 @@
 
     public void testHashCode() {
         OutboundWireImpl wire = new OutboundWireImpl();
-        wire.setServiceContract(new JavaServiceContract(Foo.class));
+        ServiceContract contract = new JavaServiceContract(Foo.class);
+        contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
+        wire.setServiceContract(contract);
         JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire);
         Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
         assertNotNull(foo.hashCode());

Modified: incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl?view=diff&rev=474537&r1=474536&r2=474537
==============================================================================
--- incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl (original)
+++ incubator/tuscany/java/sca/test/src/main/resources/META-INF/tuscany/system.scdl Mon Nov 13 14:11:11 2006
@@ -86,6 +86,10 @@
         <system:implementation.system class="org.apache.tuscany.core.component.scope.RequestScopeObjectFactory"/>
     </component>
 
+    <component name="scope.conversational">
+        <system:implementation.system class="org.apache.tuscany.core.component.scope.ConversationalScopeObjectFactory"/>
+    </component>
+
     <!-- include loader configuration -->
     <include name="org.apache.tuscany.launcher.Loader" scdlResource="org/apache/tuscany/core/loader.scdl"/>
 



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