summaryrefslogtreecommitdiffstats
path: root/sandbox/event/samples/event-jms/src/main
diff options
context:
space:
mode:
authoredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2008-11-06 16:38:56 +0000
committeredwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68>2008-11-06 16:38:56 +0000
commitce178b299f1098c72ef6c5ead574943ae28febf1 (patch)
tree824320a1bf2241318159cf5efd11c91185470b80 /sandbox/event/samples/event-jms/src/main
parentff3b544e097687169d9108a00cc64a36a680184c (diff)
Added a second pair of components with producer / consumer relationship, this time connected by binding.sca within one composite.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@711900 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/event/samples/event-jms/src/main')
-rw-r--r--sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java5
-rw-r--r--sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent2.java54
-rw-r--r--sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite18
3 files changed, 75 insertions, 2 deletions
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 23c52400e8..d976454cb9 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
@@ -34,10 +34,11 @@ public class WeatherPublisherComponent implements WeatherService {
public WeatherPublisher weatherPublisher;
public void start() {
+ System.out.println("weatherPublisher code - start() called");
try {
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 1; i++) {
generateWeatherReport();
- Thread.sleep(1000);
+ Thread.sleep(500);
}
} catch (InterruptedException e) {
}
diff --git a/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent2.java b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent2.java
new file mode 100644
index 0000000000..cf674ff6f3
--- /dev/null
+++ b/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent2.java
@@ -0,0 +1,54 @@
+/*
+ * 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 weather;
+
+import java.util.Date;
+import java.util.Random;
+
+import org.osoa.sca.annotations.Producer;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the Weather service and publishes weather reports.
+ */
+@Service(WeatherService.class)
+public class WeatherPublisherComponent2 implements WeatherService {
+
+ @Producer
+ public WeatherPublisher weatherPublisher2;
+
+ public void start() {
+ System.out.println("weatherPublisher2 code - start() called");
+ try {
+ for (int i = 0; i < 1; i++) {
+ generateWeatherReport();
+ Thread.sleep(500);
+ }
+ } catch (InterruptedException e) {
+ }
+ }
+
+ public void generateWeatherReport() {
+ int temperature = new Random().nextInt(20);
+ String report = "Location: New York, Time: " + new Date() + ", Temperature " + temperature;
+
+ weatherPublisher2.publishWeatherReport(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 9eb7e6c880..89064a7f0d 100644
--- a/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite
+++ b/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite
@@ -39,4 +39,22 @@
</component>
+ <!-- Additional components added by Mike Edwards, 31/10/2008 -->
+
+ <component name="WeatherPublisherComponent2">
+ <implementation.java class="weather.WeatherPublisherComponent2" />
+ <service name="WeatherService">
+ <interface.java interface="weather.WeatherService"/>
+ </service>
+ <producer name="weatherPublisher2" target="WeatherSubscriberComponent2/weatherSubscriber"/>
+ </component>
+
+ <component name="WeatherSubscriberComponent2">
+ <implementation.java class="weather.WeatherSubscriberComponent"/>
+
+ <consumer name="weatherSubscriber"/>
+ </component>
+
+ <!-- end of additions -->
+
</composite>