summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-07-15 16:19:24 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-07-15 16:19:24 +0000
commit04c6f646cf7eb5fc4f9d859b583a4dbd349e84f2 (patch)
tree5c28bca08889808d66e6927aa60021042fdd5d06 /sca-java-2.x/trunk
parent88b670871cd7ea084300e58fa6c9870683443597 (diff)
Trying to get the async version of the service working. However it's failing with a policy error that I think is caused by the recent policy changes.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@964477 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-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/CalculatorService.java3
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java33
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.java15
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceProxyImpl.java (renamed from sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceImpl.java)44
-rw-r--r--sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.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.composite18
8 files changed, 97 insertions, 50 deletions
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
deleted file mode 100644
index a01c79c92d..0000000000
--- a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorAsyncServiceImpl.java
+++ /dev/null
@@ -1,11 +0,0 @@
-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/CalculatorService.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.java
index ca9b0397a9..45bdd265d4 100644
--- a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.java
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorService.java
@@ -21,11 +21,10 @@ package calculator;
import org.oasisopen.sca.annotation.Remotable;
/**
- * The sycn Calculator service interface.
+ * The sync Calculator service interface.
*/
@Remotable
public interface CalculatorService {
-
String calculate(Integer n1);
}
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java
new file mode 100644
index 0000000000..3979529595
--- /dev/null
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsync.java
@@ -0,0 +1,33 @@
+/*
+ * 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.ResponseDispatch;
+import org.oasisopen.sca.annotation.AsyncInvocation;
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * The async Calculator service interface.
+ */
+
+@Remotable
+@AsyncInvocation
+public interface CalculatorServiceAsync {
+ void calculateAsync(Integer n1, ResponseDispatch<String> response);
+}
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.java
new file mode 100644
index 0000000000..18a982f4d6
--- /dev/null
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceAsyncImpl.java
@@ -0,0 +1,15 @@
+package calculator;
+
+import org.oasisopen.sca.ResponseDispatch;
+
+public class CalculatorServiceAsyncImpl implements CalculatorServiceAsync {
+
+ @Override
+ public void calculateAsync(Integer n1, ResponseDispatch<String> response) {
+ int result = n1 + n1;
+ String retval = "async service invoked: " + n1 + " + " + n1 + " = " + result;
+
+ response.sendResponse(retval);
+ }
+
+}
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/CalculatorServiceProxyImpl.java
index 994ad42d92..69c96fe892 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/CalculatorServiceProxyImpl.java
@@ -21,32 +21,45 @@ 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.
+ * An implementation of the Calculator service which just proxies
+ * to sync and asyn versions of the calculator service. This proxy
+ * exercises the various async interface alternatives
*/
-public class CalculatorServiceImpl implements CalculatorService {
+public class CalculatorServiceProxyImpl implements CalculatorService {
@Reference
- protected CalculateViaAsyncRef calculatorRefSyncService;
+ protected CalculateViaAsyncRef calculatorServiceRefSync;
-// @Reference
-// protected CalculateViaAsyncRef calculatorRefAsyncService;
+ @Reference
+ protected CalculateViaAsyncRef calculatorServiceRefAsync;
@Override
public String calculate(Integer n1) {
+ String result = null;
+
+ // calculate using a sync service
+ System.out.println("Calling sync service");
+ result = calculate(calculatorServiceRefSync, n1);
+
+ // calculate using an aycn service
+ System.out.println("Calling async service");
+ result += calculate(calculatorServiceRefAsync, n1);
+
+ return result;
+ }
+
+ // exercise sync and async versions of a service interface method
+ private String calculate(CalculateViaAsyncRef calculatorRef, Integer n1) {
// sync
- String result = calculatorRefSyncService.calculate(1);
+ String result = calculatorRef.calculate(1);
System.out.println("Sync client patern: result = " + result);
// async poll
- Future<String> future = calculatorRefSyncService.calculateAsync(20);
+ Future<String> future = calculatorRef.calculateAsync(20);
while (!future.isDone()){
System.out.println("Waiting for poll");
@@ -65,7 +78,7 @@ public class CalculatorServiceImpl implements CalculatorService {
// async callback
CalculatorAsyncHandler handler = new CalculatorAsyncHandler();
- future = calculatorRefSyncService.calculateAsync(3, handler);
+ future = calculatorRef.calculateAsync(3, handler);
while (!future.isDone()){
System.out.println("Waiting for callback");
@@ -73,11 +86,4 @@ public class CalculatorServiceImpl implements CalculatorService {
return result;
}
-
-
-
-
-
-
-
}
diff --git a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.java b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.java
new file mode 100644
index 0000000000..95bf2c9eec
--- /dev/null
+++ b/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorServiceSyncImpl.java
@@ -0,0 +1,12 @@
+package calculator;
+
+public class CalculatorServiceSyncImpl implements CalculatorService {
+
+ @Override
+ public String calculate(Integer n1) {
+ int result = n1 + n1;
+ String retval = "sync service invoked: " + n1 + " + " + n1 + " = " + result;
+ return retval;
+ }
+
+}
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
deleted file mode 100644
index a7b0928a9f..0000000000
--- a/sca-java-2.x/trunk/contrib/samples/async/sample-contribution-implementation-java-calculator-async/src/main/java/calculator/CalculatorSyncServiceImpl.java
+++ /dev/null
@@ -1,11 +0,0 @@
-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 3e6799612a..6117d436db 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
@@ -20,20 +20,24 @@
<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
targetNamespace="http://sample"
xmlns:sample="http://sample"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912"
name="Calculator">
<component name="CalculatorServiceComponent">
- <implementation.java class="calculator.CalculatorServiceImpl"/>
- <reference name="calculatorRefSyncService" target="CalculatorSync"/>
- <!-- <reference name="calculatorRefAsyncService" target="CalculatorAsync"/> -->
+ <implementation.java class="calculator.CalculatorServiceProxyImpl"/>
+ <reference name="calculatorServiceRefSync" target="CalculatorSync"/>
+ <reference name="calculatorServiceRefAsync" target="CalculatorAsync"/>
</component>
<component name="CalculatorSync">
- <implementation.java class="calculator.CalculatorSyncServiceImpl"/>
+ <implementation.java class="calculator.CalculatorServiceSyncImpl"/>
</component>
- <!-- <component name="CalculatorAsync">
- <implementation.java class="calculator.CalculatorAsyncServiceImpl"/>
- </component> -->
+ <component name="CalculatorAsync">
+ <implementation.java class="calculator.CalculatorServiceAsyncImpl"/>
+ <service name="CalculatorServiceAsync">
+ <binding.ws uri="http://localhost:8085/CalculatorAsync"/>
+ </service>
+ </component>
</composite>