From 34ea5dac5d95d94a9acbb4453dfeb097598e63a1 Mon Sep 17 00:00:00 2001 From: slaws Date: Fri, 15 Oct 2010 16:25:02 +0000 Subject: TUSCANY-3728 Rename the reference async interface and correct the signature of the poll operation which is causing a bind failure in the JIRA. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1022997 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/calculator/CalculateReferenceAsync.java | 49 ++++++++++++++++++++++ .../main/java/calculator/CalculateViaAsyncRef.java | 48 --------------------- .../src/main/java/calculator/CalculatorClient.java | 4 +- .../main/java/calculator/CalculatorService.java | 30 ------------- .../calculator/CalculatorServiceProxyImpl.java | 18 ++++---- .../java/calculator/CalculatorServiceSync.java | 30 +++++++++++++ .../java/calculator/CalculatorServiceSyncImpl.java | 2 +- 7 files changed, 92 insertions(+), 89 deletions(-) create mode 100644 sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java delete mode 100644 sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateViaAsyncRef.java delete mode 100644 sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java 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 new file mode 100644 index 0000000000..c07e5d2d65 --- /dev/null +++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateReferenceAsync.java @@ -0,0 +1,49 @@ +/* + * 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.Future; + +import javax.xml.ws.AsyncHandler; +import javax.xml.ws.Response; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * Async client version of the CalculatorService interface + * + */ + +@Remotable +public interface CalculateReferenceAsync { + + //public Response calculate( Integer i1); + + // Sync + public String calculate(Integer i1); + + // Aysnc Poll + public Response calculateAsync(Integer i1); + + // Async Callback + public Future calculateAsync(Integer i1, AsyncHandler handler); + +} + diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateViaAsyncRef.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateViaAsyncRef.java deleted file mode 100644 index 6ae8fd13f6..0000000000 --- a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculateViaAsyncRef.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.Future; - -import javax.xml.ws.AsyncHandler; - -import org.oasisopen.sca.annotation.Remotable; - -/** - * Async client version of the CalculatorService interface - * - */ - -@Remotable -public interface CalculateViaAsyncRef { - - //public Response calculate( Integer i1); - - // Sync - public String calculate(Integer i1); - - // Aysnc Poll - public Future calculateAsync(Integer i1); - - // Async Callback - public Future calculateAsync(Integer i1, AsyncHandler 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 cc1d1d8d46..fd7cfcf1e2 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 @@ -31,11 +31,11 @@ import org.oasisopen.sca.annotation.Scope; @Scope("COMPOSITE") @EagerInit public class CalculatorClient { - private CalculatorService calculatorService; + private CalculatorServiceSync calculatorService; @Reference - public void setCalculatorService(CalculatorService calculatorService) { + public void setCalculatorService(CalculatorServiceSync calculatorService) { this.calculatorService = calculatorService; } diff --git a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorService.java b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorService.java deleted file mode 100644 index 45bdd265d4..0000000000 --- a/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorService.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.annotation.Remotable; - -/** - * The sync Calculator service interface. - */ - -@Remotable -public interface CalculatorService { - String calculate(Integer n1); -} 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 69c96fe892..f27bf7f7f4 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 @@ -21,6 +21,8 @@ package calculator; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; +import javax.xml.ws.Response; + import org.oasisopen.sca.annotation.Reference; /** @@ -28,13 +30,13 @@ import org.oasisopen.sca.annotation.Reference; * to sync and asyn versions of the calculator service. This proxy * exercises the various async interface alternatives */ -public class CalculatorServiceProxyImpl implements CalculatorService { +public class CalculatorServiceProxyImpl implements CalculatorServiceSync { @Reference - protected CalculateViaAsyncRef calculatorServiceRefSync; + protected CalculateReferenceAsync calculatorServiceRefSync; @Reference - protected CalculateViaAsyncRef calculatorServiceRefAsync; + protected CalculateReferenceAsync calculatorServiceRefAsync; @Override public String calculate(Integer n1) { @@ -52,21 +54,21 @@ public class CalculatorServiceProxyImpl implements CalculatorService { } // exercise sync and async versions of a service interface method - private String calculate(CalculateViaAsyncRef calculatorRef, Integer n1) { + private String calculate(CalculateReferenceAsync calculatorRef, Integer n1) { // sync String result = calculatorRef.calculate(1); System.out.println("Sync client patern: result = " + result); // async poll - Future future = calculatorRef.calculateAsync(20); + Response response = calculatorRef.calculateAsync(20); - while (!future.isDone()){ + while (!response.isDone()){ System.out.println("Waiting for poll"); } try { - result = future.get(); + result = response.get(); System.out.println("Async client poll patern: result = " + result); } catch (InterruptedException e) { // TODO Auto-generated catch block @@ -78,7 +80,7 @@ public class CalculatorServiceProxyImpl implements CalculatorService { // async callback CalculatorAsyncHandler handler = new CalculatorAsyncHandler(); - future = calculatorRef.calculateAsync(3, handler); + Future future = calculatorRef.calculateAsync(3, handler); while (!future.isDone()){ System.out.println("Waiting for callback"); 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 new file mode 100644 index 0000000000..c0ed1fa798 --- /dev/null +++ b/sca-java-2.x/trunk/samples/learning-more/async/calculator-contribution/src/main/java/calculator/CalculatorServiceSync.java @@ -0,0 +1,30 @@ +/* + * 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.annotation.Remotable; + +/** + * The sync Calculator service interface. + */ + +@Remotable +public interface CalculatorServiceSync { + String calculate(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 615a4f4f11..a5ab67c086 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 @@ -19,7 +19,7 @@ package calculator; -public class CalculatorServiceSyncImpl implements CalculatorService { +public class CalculatorServiceSyncImpl implements CalculatorServiceSync { @Override public String calculate(Integer n1) { -- cgit v1.2.3