summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-10-27 15:00:38 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-10-27 15:00:38 +0000
commit77ee1e713a1a4df51ba73ca1e0249eff4edbd7c0 (patch)
treee13c603922f7ebe392478a2a612d6c72137f89c7 /sca-java-2.x
parent317445eb5be508380bedb7b41cc855450ffc03a0 (diff)
TUSCANY-3757 - add code (commented out currently) to demonstrate void return type scenario.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1027990 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x')
-rw-r--r--sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java14
-rw-r--r--sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java4
-rw-r--r--sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorPrintAsyncHandler.java36
-rw-r--r--sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java3
-rw-r--r--sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java10
-rw-r--r--sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java35
-rw-r--r--sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java1
-rw-r--r--sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java7
8 files changed, 105 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java
index c07e5d2d65..a8a323ba04 100644
--- a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java
+++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java
@@ -33,8 +33,6 @@ import org.oasisopen.sca.annotation.Remotable;
@Remotable
public interface CalculateReferenceAsync {
-
- //public Response<String> calculate( Integer i1);
// Sync
public String calculate(Integer i1);
@@ -44,6 +42,16 @@ public interface CalculateReferenceAsync {
// Async Callback
public Future<String> calculateAsync(Integer i1, AsyncHandler<String> handler);
-
+
+/* TUSCANY-3757
+ // Sync
+ public void print(Integer i1);
+
+ // Aysnc Poll
+ public Response<Void> printAsync(Integer i1);
+
+ // Async Callback
+ public Future<Void> printAsync(Integer i1, AsyncHandler<Void> handler);
+*/
}
diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java
index fd7cfcf1e2..6f4ffc0ca7 100644
--- a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java
+++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java
@@ -42,6 +42,10 @@ public class CalculatorClient {
@Init
public void calculate() {
System.out.println("calculation=" + calculatorService.calculate(20));
+ System.out.println("print");
+ /* TUSCANY-3757
+ calculatorService.print(27);
+ */
}
diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorPrintAsyncHandler.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorPrintAsyncHandler.java
new file mode 100644
index 0000000000..8faf390974
--- /dev/null
+++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorPrintAsyncHandler.java
@@ -0,0 +1,36 @@
+/*
+ * 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 javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+/**
+ * Handles callbacks to the async client
+ */
+
+public class CalculatorPrintAsyncHandler implements AsyncHandler<Void> {
+ public void handleResponse(Response<Void> res) {
+ try {
+ System.out.println("Async client callback patern: result in print handler = " + res.get());
+ } catch(Exception ex){
+ System.out.println("Async client callback patern: exception in print handler = " + ex.getMessage());
+ }
+ }
+}
diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java
index 3979529595..bcb931e418 100644
--- a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java
+++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java
@@ -30,4 +30,7 @@ import org.oasisopen.sca.annotation.Remotable;
@AsyncInvocation
public interface CalculatorServiceAsync {
void calculateAsync(Integer n1, ResponseDispatch<String> response);
+ /* TUSCANY-3757
+ void printAsync(Integer n1, ResponseDispatch<Void> response);
+ */
}
diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java
index 1906f46f5b..d865bcf454 100644
--- a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java
+++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java
@@ -30,5 +30,15 @@ public class CalculatorServiceAsyncImpl implements CalculatorServiceAsync {
response.sendResponse(retval);
}
+
+/* TUSCANY-3757
+ @Override
+
+ public void printAsync(Integer n1, ResponseDispatch<Void> response) {
+ int result = n1 + n1;
+ String retval = "async service invoked: " + n1 + " + " + n1 + " = " + result;
+ System.out.println(retval);
+ }
+*/
}
diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java
index 351ba9c5ef..45e23b8e93 100644
--- a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java
+++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java
@@ -43,11 +43,11 @@ public class CalculatorServiceProxyImpl implements CalculatorServiceSync {
String result = null;
// calculate using a sync service
- System.out.println("Calling sync service");
+ System.out.println("Calling sync service for calculate");
result = calculate(calculatorServiceRefSync, n1);
// calculate using an aycn service
- System.out.println("Calling async service");
+ System.out.println("Calling async service for calculate");
result += calculate(calculatorServiceRefAsync, n1);
return result;
@@ -98,4 +98,35 @@ public class CalculatorServiceProxyImpl implements CalculatorServiceSync {
return result;
}
+
+/* TUSCANY-3757
+ @Override
+*/
+ public void print(Integer n1) {
+
+ // calculate using a sync service
+ System.out.println("Calling sync service for print");
+ //print(calculatorServiceRefSync, n1);
+
+ // calculate using an asycn service
+ System.out.println("Calling async service for print");
+ //print(calculatorServiceRefAsync, n1);
+ }
+
+/* TUSCANY-3757
+ // exercise sync and async versions of a service interface method
+ private void print(CalculateReferenceAsync calculatorRef, Integer n1) {
+
+ // sync
+ calculatorRef.print(1);
+
+ // async poll
+ Response<Void> response = calculatorRef.printAsync(20);
+
+ // async callback
+ CalculatorPrintAsyncHandler handler = new CalculatorPrintAsyncHandler();
+ Future<Void> future = calculatorRef.printAsync(3, handler);
+
+ }
+*/
}
diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java
index c0ed1fa798..cded310a15 100644
--- a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java
+++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java
@@ -27,4 +27,5 @@ import org.oasisopen.sca.annotation.Remotable;
@Remotable
public interface CalculatorServiceSync {
String calculate(Integer n1);
+ void print(Integer n1);
}
diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java
index a5ab67c086..01e0d9f414 100644
--- a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java
+++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java
@@ -27,5 +27,12 @@ public class CalculatorServiceSyncImpl implements CalculatorServiceSync {
String retval = "sync service invoked: " + n1 + " + " + n1 + " = " + result;
return retval;
}
+
+ @Override
+ public void print(Integer n1) {
+ int result = n1 + n1;
+ String retval = "sync service invoked: " + n1 + " + " + n1 + " = " + result;
+ System.out.println(retval);
+ }
}