diff options
author | rsivaram <rsivaram@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-21 09:04:28 +0000 |
---|---|---|
committer | rsivaram <rsivaram@13f79535-47bb-0310-9956-ffa450edef68> | 2008-10-21 09:04:28 +0000 |
commit | e753f271ccf0ff4617725130b82dd21ae721b3d2 (patch) | |
tree | 41c5d085b635978d93a1ba068980dc459ca157bc /sandbox/event/samples | |
parent | a7ad2f6b64171d59288ebd468363255a29d464a0 (diff) |
Event prototype: Initial model changes
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@706556 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/event/samples')
6 files changed, 35 insertions, 6 deletions
diff --git a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisher.java b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisher.java index 7ef72d10b1..cdaabd9f54 100644 --- a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisher.java +++ b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisher.java @@ -18,6 +18,11 @@ */ package weather; +import org.osoa.sca.annotations.Remotable; + +// FIXME: At the moment, we need this @Remotable to make sure all the processing +// is done properly +@Remotable public interface WeatherPublisher { void publishWeatherReport(String report); diff --git a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java index 658229799d..23c52400e8 100644 --- a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java +++ b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java @@ -31,7 +31,7 @@ import org.osoa.sca.annotations.Service; public class WeatherPublisherComponent implements WeatherService { @Producer - public WeatherPublisher publisher; + public WeatherPublisher weatherPublisher; public void start() { try { @@ -47,7 +47,7 @@ public class WeatherPublisherComponent implements WeatherService { int temperature = new Random().nextInt(20); String report = "Location: New York, Time: " + new Date() + ", Temperature " + temperature; - publisher.publishWeatherReport(report); + weatherPublisher.publishWeatherReport(report); } } diff --git a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherSubscriberComponent.java b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherSubscriberComponent.java index eb9185a70e..2d8d17260e 100644 --- a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherSubscriberComponent.java +++ b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherSubscriberComponent.java @@ -21,13 +21,15 @@ package weather; import java.util.Date; import org.osoa.sca.annotations.Consumer; +import org.osoa.sca.annotations.Remotable; /** * The WeatherService subscriber implementation - receives weather reports and prints it on stdout */ -public class WeatherSubscriberComponent { +@Remotable +public class WeatherSubscriberComponent { @Consumer(name="weatherSubscriber") public void onWeather(String report) { diff --git a/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite b/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite index 6b2e59dc8f..8c1e84adfc 100644 --- a/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite +++ b/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite @@ -31,6 +31,10 @@ <producer name="weatherPublisher">
+ <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ jndiURL="tcp://localhost:61619">
+ <destination name="WeatherQueue" create="ifnotexist"/>
+ </binding.jms>
</producer>
</component>
diff --git a/sandbox/event/samples/event-jms/src/main/resources/weatherSubscriber.composite b/sandbox/event/samples/event-jms/src/main/resources/weatherSubscriber.composite index eac1b242ea..b4fcae1565 100644 --- a/sandbox/event/samples/event-jms/src/main/resources/weatherSubscriber.composite +++ b/sandbox/event/samples/event-jms/src/main/resources/weatherSubscriber.composite @@ -28,6 +28,10 @@ <consumer name="weatherSubscriber">
+ <binding.jms initialContextFactory="org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ jndiURL="tcp://localhost:61619">
+ <destination name="WeatherQueue" create="ifnotexist"/>
+ </binding.jms>
</consumer>
</component>
diff --git a/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java b/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java index a251de53c2..dfff7cc666 100644 --- a/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java +++ b/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java @@ -20,6 +20,7 @@ package weather; +import org.apache.activemq.broker.BrokerService; import org.apache.tuscany.sca.host.embedded.SCADomain; import org.junit.After; import org.junit.Before; @@ -33,14 +34,19 @@ import weather.WeatherService; */ public class WeatherTestCase { + private BrokerService jmsBroker; + private WeatherService weatherService; private SCADomain weatherSubscriberDomain; private SCADomain weatherPublisherDomain; @Before - public void startClient() throws Exception { + public void startWeatherTest() throws Exception { try { + + startBroker(); + weatherPublisherDomain = SCADomain.newInstance("weatherPublisher.composite"); weatherSubscriberDomain = SCADomain.newInstance("weatherSubscriber.composite"); weatherService = weatherPublisherDomain.getService(WeatherService.class, "WeatherPublisherComponent"); @@ -51,7 +57,7 @@ public class WeatherTestCase { } @Test - public void testClient() throws Exception { + public void runWeatherTest() throws Exception { weatherService.start(); } @@ -62,5 +68,13 @@ public class WeatherTestCase { weatherSubscriberDomain.close(); } - + + + protected void startBroker() throws Exception { + jmsBroker = new BrokerService(); + jmsBroker.setPersistent(false); + jmsBroker.setUseJmx(false); + jmsBroker.addConnector("tcp://localhost:61619"); + jmsBroker.start(); + } } |