summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/contrib
diff options
context:
space:
mode:
authorkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2010-07-13 16:53:31 +0000
committerkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2010-07-13 16:53:31 +0000
commitcdd0b2d71315be4abe7c1acf99e5cbbe97dc625a (patch)
tree3a84cd9199deaf8904e1afa7e1a320872835f336 /sca-java-2.x/trunk/contrib
parent29c48e8a53352d703933dba6c30eb7fc8e6fb4c6 (diff)
async sample update
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@963791 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/contrib')
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml2
-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/pom.xml2
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java12
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java2
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceImpl.java48
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite2
7 files changed, 60 insertions, 10 deletions
diff --git a/sca-java-2.x/trunk/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml b/sca-java-2.x/trunk/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml
index 5a71b7e412..cdf1c59f2b 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml
+++ b/sca-java-2.x/trunk/contrib/samples/async/embedded-jse-async-sample-launcher/pom.xml
@@ -23,7 +23,7 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-sca</artifactId>
<version>2.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
<artifactId>embedded-jse-async-sample-launcher</artifactId>
<name>Embedded JSE Launcher for async samples</name>
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 8554487601..49f58baa34 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/pom.xml
+++ b/sca-java-2.x/trunk/contrib/samples/async/pom.xml
@@ -23,7 +23,7 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-sca</artifactId>
<version>2.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
+ <relativePath>../../../pom.xml</relativePath>
</parent>
<artifactId>tuscany-sample-async</artifactId>
<packaging>pom</packaging>
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml
index 2d4ac4f8b1..a0f60bcf6b 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/pom.xml
@@ -23,7 +23,7 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-sca</artifactId>
<version>2.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
+ <relativePath>../pom.xml</relativePath>
</parent>
<artifactId>sample-contribution-implementation-java-calculator-async</artifactId>
<name>Apache Tuscany SCA Sample Contribution Implementation Java Calculator for Async Sample</name>
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java
index e370bd915b..2d3fc97bb0 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculateViaAsyncRef.java
@@ -13,6 +13,16 @@ import javax.xml.ws.Response;
public interface CalculateViaAsyncRef {
- public Response<String> calculate( Integer i1);
+ //public Response<String> calculate( Integer i1);
+
+ // Sync
+ public String calculate(Integer i1);
+
+ // Aysnc Poll
+ public Future<String> calculateAsync(Integer i1);
+
+ // Async Callback
+ public Future<String> calculateAsync(Integer i1, AsyncHandler<String> handler);
}
+
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java
index 60c7d8d3ce..fd92647dd1 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorClient.java
@@ -33,11 +33,13 @@ public class CalculatorClient {
private CalculatorService calculatorService;
+
@Reference
public void setCalculatorService(CalculatorService calculatorService) {
this.calculatorService = calculatorService;
}
+
@Init
public void calculate() {
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 8352a528d7..da9963087f 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
@@ -18,20 +18,58 @@
*/
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 CalculatorServiceImpl implements CalculatorService {
+
+ @Reference
+ protected CalculateViaAsyncRef calculatorRefSyncService;
+
+ @Reference
+ protected CalculateViaAsyncRef calculatorRefAsyncService;
@Override
public String calculate(Integer n1) {
-
- // TODO brute force search for divisors of n1 (http://en.wikipedia.org/wiki/Brute-force_search)
- // which should give a nice example of a method that takes a long time if given a
- // big enough input parameter
- return "1 2";
+
+ // 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/resources/CalculatorClient.composite b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite
index dfd32761be..374ef27e2b 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/resources/CalculatorClient.composite
@@ -25,6 +25,6 @@
<component name="CalculatorClient">
<implementation.java class="calculator.CalculatorClient"/>
<reference name="calculatorService" target="CalculatorServiceComponent" />
- </component>
+ </component>
</composite>