diff options
author | fmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-25 23:20:48 +0000 |
---|---|---|
committer | fmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-25 23:20:48 +0000 |
commit | bc2c7212b74937345e3b6288157678e192f6550f (patch) | |
tree | 394bcfc56e680f650b0f6f93e7371786194e0a67 /sca-java-2.x/trunk/modules/binding-comet-runtime/src | |
parent | 24b50c07ad9a697a285bbd11252f901f74deac9e (diff) |
Update testcase for binding-comet-runtime with callbacks.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1127722 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-comet-runtime/src')
3 files changed, 23 insertions, 9 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java index 6d23479f30..2c104611ff 100644 --- a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java +++ b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockService.java @@ -18,11 +18,16 @@ */ package org.apache.tuscany.sca.test; +import org.apache.tuscany.sca.binding.comet.runtime.callback.CometCallback; +import org.oasisopen.sca.annotation.Callback; +import org.oasisopen.sca.annotation.OneWay; import org.oasisopen.sca.annotation.Remotable; +@Callback(CometCallback.class) @Remotable public interface StockService { - String getQuotes(); + @OneWay + void subscribeForQuotes(); } diff --git a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java index 359d7dec0b..bbbbbb78ba 100644 --- a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java +++ b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/java/org/apache/tuscany/sca/test/StockServiceImpl.java @@ -22,18 +22,23 @@ import java.text.DecimalFormat; import java.util.Date; import java.util.Random; +import org.apache.tuscany.sca.binding.comet.runtime.callback.CometCallback; +import org.oasisopen.sca.annotation.Callback; import org.oasisopen.sca.annotation.Service; @Service(StockService.class) public class StockServiceImpl implements StockService { - public static final int MAX_VALUE = 1000; - private final Random random = new Random(new Date().getTime()); + @Callback + protected CometCallback callback; - @Override - public String getQuotes() { - final Double value = Math.abs(this.random.nextDouble() * this.random.nextInt(StockServiceImpl.MAX_VALUE)); - return "ASF" + "#" + Double.valueOf(new DecimalFormat("#.##").format(value)); - } + public static final int MAX_VALUE = 1000; + private final Random random = new Random(new Date().getTime()); + + @Override + public void subscribeForQuotes() { + final Double value = Math.abs(this.random.nextDouble() * this.random.nextInt(StockServiceImpl.MAX_VALUE)); + callback.sendMessage("ASF" + "#" + Double.valueOf(new DecimalFormat("#.##").format(value))); + } } diff --git a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/resources/test.composite b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/resources/test.composite index 15026167be..e2996d2572 100644 --- a/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/resources/test.composite +++ b/sca-java-2.x/trunk/modules/binding-comet-runtime/src/test/resources/test.composite @@ -25,8 +25,12 @@ <component name="test"> <implementation.java class="org.apache.tuscany.sca.test.StockServiceImpl"/> <service name="StockService"> - <interface.java interface="org.apache.tuscany.sca.test.StockService"/> + <interface.java interface="org.apache.tuscany.sca.test.StockService" + callbackInterface="org.apache.tuscany.sca.binding.comet.runtime.callback.CometCallback"/> <tuscany:binding.comet/> + <callback> + <tuscany:binding.comet/> + </callback> </service> </component> |