summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2010-07-15 14:51:06 +0000
committerkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2010-07-15 14:51:06 +0000
commit8343c879a235d4200d11ac894e889c80efde359e (patch)
tree7be4787aaec08bbfa509d6fde58abe0a0f94afcc /sca-java-2.x/trunk
parent76594bbf77f5001834610d43cc96befbc402ace2 (diff)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@964452 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/pom.xml2
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncClientLogic.java81
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncServiceImpl.java11
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorBoot.java52
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceImpl.java12
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorSyncServiceImpl.java11
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite10
7 files changed, 174 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/contrib/samples/async/pom.xml b/sca-java-2.x/trunk/contrib/samples/async/pom.xml
index 49f58baa34..f44ae33067 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/pom.xml
+++ b/sca-java-2.x/trunk/contrib/samples/async/pom.xml
@@ -27,7 +27,7 @@
</parent>
<artifactId>tuscany-sample-async</artifactId>
<packaging>pom</packaging>
- <name>Apache Tuscany SCA Samples for Synchronous/Asynchronous invocation</name>
+ <name>MYYYYYYYYYYYYYYYYYYY Apache Tuscany SCA Samples for Synchronous/Asynchronous invocation</name>
<profiles>
<profile>
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncClientLogic.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncClientLogic.java
new file mode 100644
index 0000000000..562cc87521
--- /dev/null
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncClientLogic.java
@@ -0,0 +1,81 @@
+/*
+ * 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 calculator;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+
+import org.oasisopen.sca.annotation.Reference;
+
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorAsyncClientLogic implements CalculatorService {
+
+ @Reference
+ protected CalculateViaAsyncRef calculatorRefSyncService;
+
+ @Reference
+ protected CalculateViaAsyncRef calculatorRefAsyncService;
+
+ @Override
+ public String calculate(Integer n1) {
+
+ // sync
+ String result = calculatorRefSyncService.calculate(1);
+
+ // async poll
+ Future<String> future = calculatorRefAsyncService.calculateAsync(2);
+
+ while (!future.isDone()){
+ System.out.println("Waiting for poll");
+ }
+
+ try {
+ result = future.get();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ExecutionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ // async callback
+// AsyncHandler<String> handler = new AsyncHandler<String>();
+// future = calculatorRef.calculateAsync(3, handler);
+/*
+ while (!future.isDone()){
+ System.out.println("Waiting for callback");
+ }
+*/
+ return result;
+ }
+
+
+
+
+
+
+
+}
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncServiceImpl.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncServiceImpl.java
new file mode 100644
index 0000000000..a01c79c92d
--- /dev/null
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncServiceImpl.java
@@ -0,0 +1,11 @@
+package calculator;
+
+public class CalculatorAsyncServiceImpl implements CalculatorService {
+
+ @Override
+ public String calculate(Integer n1) {
+ String retval = "sync service invoked";
+ return retval;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorBoot.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorBoot.java
new file mode 100644
index 0000000000..0ddac8e1d2
--- /dev/null
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorBoot.java
@@ -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 calculator;
+
+import org.oasisopen.sca.annotation.EagerInit;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE") @EagerInit
+public class CalculatorBoot {
+
+ private CalculatorService calculatorService;
+
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+
+ @Init
+ public void calculate() {
+
+ // Calculate
+ //System.out.println("SCA API ClassLoader: " + print(Reference.class.getClassLoader()));
+ System.out.println("calculation=" + calculatorService.calculate(20));
+ }
+
+
+}
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceImpl.java
index da9963087f..c5b0562c65 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceImpl.java
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceImpl.java
@@ -35,17 +35,18 @@ public class CalculatorServiceImpl implements CalculatorService {
@Reference
protected CalculateViaAsyncRef calculatorRefSyncService;
- @Reference
- protected CalculateViaAsyncRef calculatorRefAsyncService;
+// @Reference
+// protected CalculateViaAsyncRef calculatorRefAsyncService;
@Override
public String calculate(Integer n1) {
// sync
String result = calculatorRefSyncService.calculate(1);
+ System.out.println(result);
- // async poll
- Future<String> future = calculatorRefAsyncService.calculateAsync(2);
+// // async poll
+ Future<String> future = calculatorRefSyncService.calculateAsync(20);
while (!future.isDone()){
System.out.println("Waiting for poll");
@@ -53,6 +54,7 @@ public class CalculatorServiceImpl implements CalculatorService {
try {
result = future.get();
+ System.out.println("Async client patern success: result = " + result);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -61,6 +63,8 @@ public class CalculatorServiceImpl implements CalculatorService {
e.printStackTrace();
}
+
+
// async callback
// AsyncHandler<String> handler = new AsyncHandler<String>();
// future = calculatorRef.calculateAsync(3, handler);
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorSyncServiceImpl.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorSyncServiceImpl.java
new file mode 100644
index 0000000000..a7b0928a9f
--- /dev/null
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorSyncServiceImpl.java
@@ -0,0 +1,11 @@
+package calculator;
+
+public class CalculatorSyncServiceImpl implements CalculatorService {
+
+ @Override
+ public String calculate(Integer n1) {
+ String retval = "sync service invoked";
+ return retval;
+ }
+
+}
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite
index 867b0e6c33..ed02597dc3 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/Calculator.composite
@@ -24,6 +24,16 @@
<component name="CalculatorServiceComponent">
<implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="calculatorRefSyncService" target="CalculatorSync"/>
+ <!-- <reference name="calculatorRefAsyncService" target="CalculatorAsync"/> -->
+
</component>
+ <component name="CalculatorSync">
+ <implementation.java class="calculator.CalculatorSyncServiceImpl"/>
+ </component>
+ <!-- <component name="CalculatorAsync">
+ <implementation.java class="calculator.CalculatorAsyncServiceImpl"/>
+ </component> -->
+
</composite>