You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2010/10/27 17:00:39 UTC
svn commit: r1027990 -
/tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/
Author: slaws
Date: Wed Oct 27 15:00:38 2010
New Revision: 1027990
URL: http://svn.apache.org/viewvc?rev=1027990&view=rev
Log:
TUSCANY-3757 - add code (commented out currently) to demonstrate void return type scenario.
Added:
tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorPrintAsyncHandler.java
Modified:
tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java
tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java
tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java
tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java
tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java
tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java
tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java
Modified: tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java?rev=1027990&r1=1027989&r2=1027990&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java Wed Oct 27 15:00:38 2010
@@ -33,8 +33,6 @@ import org.oasisopen.sca.annotation.Remo
@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);
+*/
}
Modified: tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java?rev=1027990&r1=1027989&r2=1027990&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorClient.java Wed Oct 27 15:00:38 2010
@@ -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);
+ */
}
Added: tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorPrintAsyncHandler.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorPrintAsyncHandler.java?rev=1027990&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorPrintAsyncHandler.java (added)
+++ tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorPrintAsyncHandler.java Wed Oct 27 15:00:38 2010
@@ -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());
+ }
+ }
+}
Modified: tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java?rev=1027990&r1=1027989&r2=1027990&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsync.java Wed Oct 27 15:00:38 2010
@@ -30,4 +30,7 @@ import org.oasisopen.sca.annotation.Remo
@AsyncInvocation
public interface CalculatorServiceAsync {
void calculateAsync(Integer n1, ResponseDispatch<String> response);
+ /* TUSCANY-3757
+ void printAsync(Integer n1, ResponseDispatch<Void> response);
+ */
}
Modified: tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java?rev=1027990&r1=1027989&r2=1027990&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceAsyncImpl.java Wed Oct 27 15:00:38 2010
@@ -30,5 +30,15 @@ public class CalculatorServiceAsyncImpl
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);
+ }
+*/
}
Modified: tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java?rev=1027990&r1=1027989&r2=1027990&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceProxyImpl.java Wed Oct 27 15:00:38 2010
@@ -43,11 +43,11 @@ public class CalculatorServiceProxyImpl
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
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);
+
+ }
+*/
}
Modified: tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java?rev=1027990&r1=1027989&r2=1027990&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java Wed Oct 27 15:00:38 2010
@@ -27,4 +27,5 @@ import org.oasisopen.sca.annotation.Remo
@Remotable
public interface CalculatorServiceSync {
String calculate(Integer n1);
+ void print(Integer n1);
}
Modified: tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java?rev=1027990&r1=1027989&r2=1027990&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSyncImpl.java Wed Oct 27 15:00:38 2010
@@ -27,5 +27,12 @@ public class CalculatorServiceSyncImpl i
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);
+ }
}