summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi')
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/AService.java56
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/AServiceCallback.java35
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/BService.java47
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/BServiceBusinessException.java53
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/CService.java34
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/DService.java38
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/AServiceImpl.java197
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/BServiceImpl.java64
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/CServiceImpl.java40
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/DServiceImpl.java78
10 files changed, 642 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/AService.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/AService.java
new file mode 100644
index 0000000000..8deef5df31
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/AService.java
@@ -0,0 +1,56 @@
+/*
+ * 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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime;
+
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Remotable Service
+ */
+@Remotable
+public interface AService {
+
+ public void testConversationStarted();
+
+ public void testConversationStarted2();
+
+ public void testConversationContinue();
+
+ public void testConversationContinue2();
+
+ public void testConversationContinue3();
+
+ public void testConversationEnd();
+
+ public void testConversationEnd2();
+
+ public void testConversationEnd3();
+
+ public void testConversationEnd4();
+
+ public void testConversationEnd5();
+
+ public void testConversationEnd6();
+
+ public void testConversationEnd7();
+
+ public void testConversationEnd8();
+
+ public void testConversationEnd9();
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/AServiceCallback.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/AServiceCallback.java
new file mode 100644
index 0000000000..5a20f4d960
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/AServiceCallback.java
@@ -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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime;
+
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Remotable Service
+ */
+@Remotable
+@Conversational
+public interface AServiceCallback {
+
+ @EndsConversation
+ public void endConversation();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/BService.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/BService.java
new file mode 100644
index 0000000000..6368b1157b
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/BService.java
@@ -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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Local Service
+ */
+@Remotable
+@Conversational
+@Callback(AServiceCallback.class)
+public interface BService {
+
+ public void setState(String someState);
+
+ public String getState();
+
+ @EndsConversation
+ public void endConversation();
+
+ public void endConversationViaCallback();
+
+ public void throwNonBusinessException();
+
+ public void throwBusinessException() throws BServiceBusinessException;
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/BServiceBusinessException.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/BServiceBusinessException.java
new file mode 100644
index 0000000000..ab186ee7eb
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/BServiceBusinessException.java
@@ -0,0 +1,53 @@
+/*
+ * 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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime;
+
+
+/**
+ * Denotes an error starting the runtime
+ *
+ * @version $Rev$ $Date$
+ */
+public class BServiceBusinessException extends Exception {
+
+ static final long serialVersionUID = 2096658015909178325L;
+
+ private String message;
+
+ public BServiceBusinessException() {
+ }
+
+ public BServiceBusinessException(String message) {
+ super(message);
+ setMessage(message);
+ }
+
+ public BServiceBusinessException(Throwable cause) {
+ super(cause);
+ setMessage(cause.getMessage());
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/CService.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/CService.java
new file mode 100644
index 0000000000..dcc2e5d9c4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/CService.java
@@ -0,0 +1,34 @@
+/*
+ * 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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime;
+
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Local Service
+ */
+@Remotable
+@Conversational
+public interface CService {
+
+ public void setState(String someState);
+ public String getState();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/DService.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/DService.java
new file mode 100644
index 0000000000..06d40accd4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/DService.java
@@ -0,0 +1,38 @@
+/*
+ * 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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime;
+
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Simple Local Service
+ */
+@Remotable
+@Conversational
+public interface DService {
+
+ public void setState(String someState);
+ public String getState();
+
+ public void continueConversation(ServiceReference<BService> b, Object convId);
+ public void continueConversation2(String filename, Object id, String serializedState);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/AServiceImpl.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/AServiceImpl.java
new file mode 100644
index 0000000000..56bfcabfc4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/AServiceImpl.java
@@ -0,0 +1,197 @@
+/*
+ * 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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.impl;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.AService;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.AServiceCallback;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.BService;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.BServiceBusinessException;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.CService;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.DService;
+import org.junit.Assert;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ConversationEndedException;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(AService.class)
+@Scope("CONVERSATION")
+public class AServiceImpl implements AService, AServiceCallback {
+
+ @Context
+ public ComponentContext context;
+
+ @Reference
+ protected ServiceReference<BService> b;
+
+ @Reference
+ protected DService d;
+
+ public void testConversationStarted() {
+ b.getService().setState("Some state");
+ Assert.assertNotNull(b.getConversation().getConversationID());
+ }
+
+ public void testConversationStarted2() {
+ ServiceReference<BService> ref = context.getServiceReference(BService.class, "b");
+ ref.getService().setState("Some state");
+ Assert.assertNotNull(ref.getConversation().getConversationID());
+ }
+
+ public void testConversationContinue() {
+
+ b.getService().setState("Some state");
+ Object id = b.getConversation().getConversationID();
+ b.getService().setState("Some more state");
+ Assert.assertEquals(id, b.getConversation().getConversationID());
+ }
+
+ public void testConversationContinue2() {
+
+ b.getService().setState("Some state");
+ d.continueConversation(b, b.getConversation().getConversationID());
+
+ }
+
+ public void testConversationContinue3() {
+
+ String serializedState = "Serialized State";
+
+ String filename = "target/Serialized-Reference.txt";
+ b.getService().setState(serializedState);
+ Object id = b.getConversation().getConversationID();
+ writeReference(b, filename);
+ d.continueConversation2(filename, id, serializedState);
+
+ }
+
+ // Utilities
+
+ private void delayForSeconds(int numSeconds) {
+ try {
+ Thread.sleep(numSeconds * 1000);// millisecs
+ } catch (InterruptedException ex) {
+ throw new Error(ex);
+ }
+ }
+
+ private void writeReference(ServiceReference<BService> ref, String filename) {
+
+ FileOutputStream fos = null;
+ ObjectOutputStream out = null;
+ try {
+ fos = new FileOutputStream(filename);
+ out = new ObjectOutputStream(fos);
+ out.writeObject(ref);
+ out.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public void testConversationEnd() {
+ String someState = "Some state";
+ b.getService().setState(someState);
+ b.getService().endConversation();
+ Assert.assertNotSame(someState, b.getService().getState());
+ }
+
+ public void testConversationEnd2() {
+ String someState = "Some state";
+ b.getService().setState(someState);
+ b.getService().endConversationViaCallback();
+ Assert.assertNotSame(someState, b.getService().getState());
+ }
+
+ public void endConversation() {
+ System.out.println("A-callback to end conversation");
+ }
+
+ public void testConversationEnd3() {
+ String someState = "Some state";
+ b.getService().setState(someState);
+ delayForSeconds(2);
+ try {
+ b.getService().getState();
+ } catch (ConversationEndedException e) {
+ b.getConversation().end();// need to clean up to avoid exception
+ }
+ Assert.assertNotSame(someState, b.getService().getState());
+ }
+
+ public void testConversationEnd4() {
+ String someState = "Some state";
+ b.getService().setState(someState);
+ b.getConversation().end();
+ Assert.assertNotSame(someState, b.getService().getState());
+ }
+
+ public void testConversationEnd5() {
+ String someState = "Some state";
+ b.getService().setState(someState);
+ try {
+ b.getService().throwNonBusinessException();
+ } catch (Error e) {
+ // Expected
+ }
+ Assert.assertNotSame(someState, b.getService().getState());
+ }
+
+ public void testConversationEnd6() {
+ String someState = "Some state";
+ b.getService().setState(someState);
+ Object id = b.getConversation().getConversationID();
+ b.getService().endConversation();
+ Assert.assertNotSame(someState, b.getService().getState());
+ Assert.assertNotSame(id, b.getConversation().getConversationID());
+ }
+
+ public void testConversationEnd7() {
+ b.getService().setState("Some state");
+ b.getService().endConversation();
+ Assert.assertNull(b.getConversationID());
+ }
+
+ public void testConversationEnd8() {
+ String someState = "Some state";
+ b.getService().setState(someState);
+ delayForSeconds(2);
+ b.getService().getState();
+ }
+
+ public void testConversationEnd9() {
+ String someState = "Some state";
+ b.getService().setState(someState);
+ try {
+ b.getService().throwBusinessException();
+ } catch (BServiceBusinessException e) {
+ // Expected
+ }
+ Assert.assertSame(someState, b.getService().getState());
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/BServiceImpl.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/BServiceImpl.java
new file mode 100644
index 0000000000..0919734c7a
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/BServiceImpl.java
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.AServiceCallback;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.BService;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.BServiceBusinessException;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.ConversationAttributes;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(BService.class)
+@Scope("CONVERSATION")
+@ConversationAttributes(maxAge="1 seconds")
+public class BServiceImpl implements BService {
+
+ String someState;
+
+ @Callback
+ protected AServiceCallback callback;
+
+ public void setState(String someState) {
+ this.someState = someState;
+ }
+
+ public String getState() {
+ return someState;
+ }
+
+ public void endConversation() {
+ System.out.println("Someone called Bservice.endsConversation()");
+ }
+
+ public void endConversationViaCallback() {
+ callback.endConversation();
+ }
+
+ public void throwNonBusinessException() {
+ throw new Error();
+ }
+
+ public void throwBusinessException() throws BServiceBusinessException {
+ throw new BServiceBusinessException("Business Exception");
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/CServiceImpl.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/CServiceImpl.java
new file mode 100644
index 0000000000..d9910d445c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/CServiceImpl.java
@@ -0,0 +1,40 @@
+/*
+ * 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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.CService;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(CService.class)
+@Scope("CONVERSATION")
+public class CServiceImpl implements CService {
+
+ String someState;
+
+ public void setState(String someState) {
+ this.someState = someState;
+ }
+
+ public String getState() {
+ return someState;
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/DServiceImpl.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/DServiceImpl.java
new file mode 100644
index 0000000000..34c57e402e
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/conversation/lifetime/src/main/java/org/apache/tuscany/sca/vtest/javaapi/conversation/lifetime/impl/DServiceImpl.java
@@ -0,0 +1,78 @@
+/*
+ * 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 org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.impl;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.BService;
+import org.apache.tuscany.sca.vtest.javaapi.conversation.lifetime.DService;
+import org.junit.Assert;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(DService.class)
+@Scope("CONVERSATION")
+public class DServiceImpl implements DService {
+
+ String someState;
+
+ public void setState(String someState) {
+ this.someState = someState;
+ }
+
+ public String getState() {
+ return someState;
+ }
+
+ public void continueConversation(ServiceReference<BService> b, Object convId) {
+
+ b.getService().setState("Some more state");
+ Assert.assertEquals(convId, b.getConversation().getConversationID());
+ }
+
+ public void continueConversation2(String filename, Object convId, String serializedState) {
+ ServiceReference<BService> b = readReference(filename);
+ Assert.assertEquals(serializedState, b.getService().getState());
+ Assert.assertEquals(convId, b.getConversation().getConversationID());
+ }
+
+ // Utilities
+ @SuppressWarnings("unchecked")
+ private ServiceReference<BService> readReference(String filename) {
+ ServiceReference<BService> b = null;
+ FileInputStream fis = null;
+ ObjectInputStream in = null;
+ try {
+ fis = new FileInputStream(filename);
+ in = new ObjectInputStream(fis);
+ ServiceReference<BService> readObject = (ServiceReference<BService>)in.readObject();
+ b = readObject;
+ in.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ } catch (ClassNotFoundException ex) {
+ ex.printStackTrace();
+ }
+ return b;
+ }
+}