summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncClientLogic.java
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncClientLogic.java')
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncClientLogic.java81
1 files changed, 81 insertions, 0 deletions
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;
+ }
+
+
+
+
+
+
+
+}