diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-comet-runtime/src/test')
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> |