Author: edwardsmj
Date: Thu Nov 6 08:38:56 2008
New Revision: 711900
URL: http://svn.apache.org/viewvc?rev=711900&view=rev
Log:
Added a second pair of components with producer / consumer relationship, this
time connected by binding.sca within one composite.
Added:
tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent2.java
Modified:
tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java
tuscany/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite
tuscany/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java
Modified:
tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java
URL:
http://svn.apache.org/viewvc/tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java?rev=711900&r1=711899&r2=711900&view=diff
==============================================================================
---
tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java
(original)
+++
tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent.java
Thu Nov 6 08:38:56 2008
@@ -34,10 +34,11 @@
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) {
}
Added:
tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent2.java
URL:
http://svn.apache.org/viewvc/tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent2.java?rev=711900&view=auto
==============================================================================
---
tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent2.java
(added)
+++
tuscany/sandbox/event/samples/event-jms/src/main/java/weather/WeatherPublisherComponent2.java
Thu Nov 6 08:38:56 2008
@@ -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.
+ */
[EMAIL PROTECTED](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);
+ }
+
+}
Modified:
tuscany/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite
URL:
http://svn.apache.org/viewvc/tuscany/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite?rev=711900&r1=711899&r2=711900&view=diff
==============================================================================
---
tuscany/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite
(original)
+++
tuscany/sandbox/event/samples/event-jms/src/main/resources/weatherPublisher.composite
Thu Nov 6 08:38:56 2008
@@ -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>
Modified:
tuscany/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java
URL:
http://svn.apache.org/viewvc/tuscany/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java?rev=711900&r1=711899&r2=711900&view=diff
==============================================================================
---
tuscany/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java
(original)
+++
tuscany/sandbox/event/samples/event-jms/src/test/java/weather/WeatherTestCase.java
Thu Nov 6 08:38:56 2008
@@ -37,6 +37,7 @@
private BrokerService jmsBroker;
private WeatherService weatherService;
+ private WeatherService weatherService2;
private SCADomain weatherSubscriberDomain;
private SCADomain weatherPublisherDomain;
@@ -50,7 +51,7 @@
weatherPublisherDomain =
SCADomain.newInstance("weatherPublisher.composite");
weatherSubscriberDomain =
SCADomain.newInstance("weatherSubscriber.composite");
weatherService =
weatherPublisherDomain.getService(WeatherService.class,
"WeatherPublisherComponent");
-
+ weatherService2 =
weatherPublisherDomain.getService(WeatherService.class,
"WeatherPublisherComponent2");
} catch (Throwable e) {
e.printStackTrace();
}
@@ -59,6 +60,7 @@
@Test
public void runWeatherTest() throws Exception {
weatherService.start();
+ weatherService2.start();
}