summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-29 08:31:14 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-29 08:31:14 +0000
commit7d34713fecd6b842bb4abd78f3bbc5bac6dad3bf (patch)
tree525637f7e8aca1b6ad046adab3973f31e42c4039 /branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java
parent8d5c5870cc4754f73652177bc48b880463e3b5a4 (diff)
Branch for 1.3.2
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@690149 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java')
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleClient.java26
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleClientImpl.java59
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleService.java30
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleServiceImpl.java33
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Alpha.java26
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/AlphaImpl.java96
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Beta.java27
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/BetaImpl.java46
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Gamma.java34
-rw-r--r--branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/GammaImpl.java49
10 files changed, 426 insertions, 0 deletions
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleClient.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleClient.java
new file mode 100644
index 0000000000..ecf1ac27e1
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleClient.java
@@ -0,0 +1,26 @@
+/*
+ * 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 com.example;
+
+public interface ExampleClient {
+
+ void runTest();
+
+ void sayHello(String name);
+}
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleClientImpl.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleClientImpl.java
new file mode 100644
index 0000000000..c46087d865
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleClientImpl.java
@@ -0,0 +1,59 @@
+/*
+ * 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 com.example;
+
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+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(ExampleClient.class)
+@Scope("COMPOSITE")
+public class ExampleClientImpl implements ExampleClient {
+
+ private ExampleService myService;
+
+ @Context
+ protected ComponentContext context;
+
+ @Reference
+ public void setMyService(ExampleService myService) {
+ this.myService = myService;
+ }
+
+ public void runTest() {
+ ServiceReference<ExampleClient> ref = context.createSelfReference(ExampleClient.class);
+ ref.getService().sayHello("Jack");
+ CallableReference result = myService.hello("Jill", ref);
+ if (result != null) {
+ ((CallableReference<ExampleClient>)result).getService().sayHello("John");
+ }
+ result = myService.hello("Jane", null);
+ if (result != null) {
+ ((CallableReference<ExampleClient>)result).getService().sayHello("Jim");
+ }
+ }
+
+ public void sayHello(String name) {
+ System.out.println("Hello, client " + name + "!");
+ }
+}
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleService.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleService.java
new file mode 100644
index 0000000000..670c145cc3
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleService.java
@@ -0,0 +1,30 @@
+/*
+ * 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 com.example;
+
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface ExampleService {
+
+ CallableReference hello(String name, ServiceReference ref);
+
+}
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleServiceImpl.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleServiceImpl.java
new file mode 100644
index 0000000000..eb4d647a22
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/com/example/ExampleServiceImpl.java
@@ -0,0 +1,33 @@
+/*
+ * 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 com.example;
+
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ServiceReference;
+
+public class ExampleServiceImpl implements ExampleService {
+
+ public CallableReference hello(String name, ServiceReference ref) {
+ if (ref != null) {
+ ((ServiceReference<ExampleClient>)ref).getService().sayHello(name);
+ }
+ return (CallableReference)ref;
+ }
+
+}
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Alpha.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Alpha.java
new file mode 100644
index 0000000000..bb5e57397d
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Alpha.java
@@ -0,0 +1,26 @@
+/*
+ * 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.itest.callablerefwsreturn;
+
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface Alpha {
+ boolean run();
+}
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/AlphaImpl.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/AlphaImpl.java
new file mode 100644
index 0000000000..6e5f1cedf9
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/AlphaImpl.java
@@ -0,0 +1,96 @@
+/*
+ * 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.itest.callablerefwsreturn;
+
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.Conversation;
+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(Alpha.class)
+@Scope("COMPOSITE")
+public class AlphaImpl implements Alpha {
+ @Reference
+ public Beta beta;
+
+ @Context
+ protected ComponentContext componentContext;
+
+ Object conversationId0 = null;
+
+ public boolean run() {
+ CallableReference<Gamma> gammaRef = null;
+ try {
+ Object conversationId1 = null;
+ Object conversationId2 = null;
+
+ // it is expected that this call returns a reference to Gamma that
+ // reuses the established Conversation
+ gammaRef = beta.getRef();
+
+ // no Conversation exists
+ Conversation con = gammaRef.getConversation();
+ if (con == null) {
+ System.out.println("Alpha1: Conversation to gamma is null");
+ } else {
+ System.out
+ .println("Alpha1: Conversation to gamma exists. conversationId="
+ + con.getConversationID());
+ conversationId1 = con.getConversationID();
+ }
+
+ // this call should reuse a Conversation, but as none exists it
+ // creates a new conversation
+ gammaRef.getService().doSomething();
+ gammaRef.getService().doSomething();
+ gammaRef.getService().doSomething();
+
+ con = gammaRef.getConversation();
+ if (con == null) {
+ System.out.println("Alpha2: Conversation to gamma is null");
+ } else {
+ System.out
+ .println("Alpha2: Conversation to gamma exists. conversationId="
+ + con.getConversationID());
+ conversationId2 = con.getConversationID();
+ }
+
+ boolean testPassed = conversationId1.equals(conversationId2);
+
+ if (conversationId0 == null){
+ conversationId0 = conversationId1;
+ return testPassed;
+ } else {
+ return testPassed && (!conversationId0.equals(conversationId1));
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ } finally {
+ if (gammaRef != null) {
+ gammaRef.getService().stop();
+ }
+ }
+ }
+
+}
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Beta.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Beta.java
new file mode 100644
index 0000000000..995e4fcf39
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Beta.java
@@ -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 org.apache.tuscany.sca.itest.callablerefwsreturn;
+
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+public interface Beta {
+ CallableReference<Gamma> getRef();
+}
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/BetaImpl.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/BetaImpl.java
new file mode 100644
index 0000000000..be72fd779e
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/BetaImpl.java
@@ -0,0 +1,46 @@
+/*
+ * 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.itest.callablerefwsreturn;
+
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+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(Beta.class)
+@Scope("COMPOSITE")
+public class BetaImpl implements Beta {
+ @Context
+ protected ComponentContext componentContext;
+
+ @Reference
+ public Gamma gamma;
+
+ public CallableReference<Gamma> getRef() {
+ ServiceReference<Gamma> gammaRef = componentContext
+ .getServiceReference(Gamma.class, "gamma");
+ Gamma g = gammaRef.getService();
+ g.start();
+ return gammaRef;
+ }
+
+}
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Gamma.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Gamma.java
new file mode 100644
index 0000000000..b73f26b573
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/Gamma.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.itest.callablerefwsreturn;
+
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+import org.osoa.sca.annotations.Remotable;
+
+@Remotable
+@Conversational
+public interface Gamma {
+ int start();
+
+ void doSomething();
+
+ @EndsConversation
+ void stop();
+}
diff --git a/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/GammaImpl.java b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/GammaImpl.java
new file mode 100644
index 0000000000..c3abc4c65d
--- /dev/null
+++ b/branches/sca-java-1.3.2/itest/callablereferences-ws/src/main/java/org/apache/tuscany/sca/itest/callablerefwsreturn/GammaImpl.java
@@ -0,0 +1,49 @@
+/*
+ * 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.itest.callablerefwsreturn;
+
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(Gamma.class)
+@Scope("CONVERSATION")
+public class GammaImpl implements Gamma {
+ @ConversationID
+ protected String conversationId;
+
+ public GammaImpl() {
+ System.out.println("GammaImpl:GammaImpl(), conversationId="
+ + conversationId);
+ }
+
+ public int start() {
+ System.out.println("Gamma:start(), conversationId=" + conversationId);
+ return 1;
+ }
+
+ public void doSomething() {
+ System.out.println("Gamma:doSomething(), conversationId="
+ + conversationId);
+ }
+
+ public void stop() {
+ System.out.println("Gamma:stop(), conversationId=" + conversationId);
+ }
+}