You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by is...@apache.org on 2007/06/27 17:31:40 UTC
svn commit: r551198 - in
/incubator/tuscany/java/sca/samples/implementation-notification: ./ src/
src/main/ src/main/java/ src/main/java/notification/ src/test/
src/test/java/ src/test/java/notification/ src/test/resources/
Author: isilval
Date: Wed Jun 27 08:31:38 2007
New Revision: 551198
URL: http://svn.apache.org/viewvc?view=rev&rev=551198
Log:
Sample that illustrates the use of <implementation.notification/>
Added:
incubator/tuscany/java/sca/samples/implementation-notification/ (with props)
incubator/tuscany/java/sca/samples/implementation-notification/README
incubator/tuscany/java/sca/samples/implementation-notification/implementation-notification.png (with props)
incubator/tuscany/java/sca/samples/implementation-notification/pom.xml
incubator/tuscany/java/sca/samples/implementation-notification/src/
incubator/tuscany/java/sca/samples/implementation-notification/src/main/
incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/
incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/
incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java
incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java
incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java
incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java
incubator/tuscany/java/sca/samples/implementation-notification/src/test/
incubator/tuscany/java/sca/samples/implementation-notification/src/test/java/
incubator/tuscany/java/sca/samples/implementation-notification/src/test/java/notification/
incubator/tuscany/java/sca/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java
incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/
incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType
incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite
Propchange: incubator/tuscany/java/sca/samples/implementation-notification/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jun 27 08:31:38 2007
@@ -0,0 +1,14 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+test*
Added: incubator/tuscany/java/sca/samples/implementation-notification/README
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/README?view=auto&rev=551198
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-notification/README (added)
+++ incubator/tuscany/java/sca/samples/implementation-notification/README Wed Jun 27 08:31:38 2007
@@ -0,0 +1,70 @@
+Notification Implementation Sample
+===============================
+
+This sample illustrates the use of <implementation.notification/>
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+If you just want to run it to see what happens open a command prompt, navigate
+to this sample directory and do:
+
+mvn test
+
+Sample Overview
+---------------
+
+This sample consists of a single composite that contains a notification component,
+a producer component and two consumer components. Take a look at the composite file
+or the .svg file which shows the composite file in pictorial form. The notification
+component has an <implementation.notification/> that refers to the component type
+that defines the TrafficAdvisory java interface. This interface indicates the
+makeup of the messages being sent and received and is also implemented by the
+consumer components.
+
+Sample directory structure:
+
+implementation-notification/
+ src/
+ main/
+ java/
+ notification/
+ TestCaseProducer.java - interface for the producer component
+ TrafficAdvisory.java - interface for the notification and consumer components
+ TrafficAdvisoryConsumer.java - implementation for the consumer components
+ TrafficAdvisoryProducer.java - implementation for the producer component
+ test/
+ java/
+ notification/
+ TrafficAdvisoryTestCase.java - JUnit test case
+ resources/
+ TrafficAdvisoryNotification.componentType - the component type referred to by
+ <implementation.notification/>
+ TrafficAdvisoryNotification.composite - the main composite including producer,
+ notification component, and consumers
+ pom.xml - the Maven build file
+
+Building And Running The Sample Using Maven
+-------------------------------------------
+With either the binary or source distributions the sample can be built and run
+using Maven as follows.
+
+cd implementation-notification
+mvn
+
+You should see the following output from the test phase.
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running notification.TrafficAdvisoryTestCase
+Consumer [Consumer1] received report: Nothing to report today
+Consumer [Consumer2] received report: Nothing to report today
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.742 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+This shows that the Junit test cases have run successfully.
Added: incubator/tuscany/java/sca/samples/implementation-notification/implementation-notification.png
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/implementation-notification.png?view=auto&rev=551198
==============================================================================
Binary file - no diff available.
Propchange: incubator/tuscany/java/sca/samples/implementation-notification/implementation-notification.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/tuscany/java/sca/samples/implementation-notification/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/pom.xml?view=auto&rev=551198
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-notification/pom.xml (added)
+++ incubator/tuscany/java/sca/samples/implementation-notification/pom.xml Wed Jun 27 08:31:38 2007
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>sample-implementation-notification</artifactId>
+ <name>Notification Implementation Sample</name>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <description></description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-notification</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-embedded</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ </dependency>
+ <!-- if this is not in, BuilderRegistryImpl throws NPE (line 96) -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>1.0-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- end -->
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ <defaultGoal>install</defaultGoal>
+ </build>
+</project>
Added: incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java?view=auto&rev=551198
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java Wed Jun 27 08:31:38 2007
@@ -0,0 +1,24 @@
+/*
+ * 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 notification;
+
+public interface TestCaseProducer {
+
+ public void produceTrafficNotification(String report);
+}
Added: incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java?view=auto&rev=551198
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java Wed Jun 27 08:31:38 2007
@@ -0,0 +1,24 @@
+/*
+ * 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 notification;
+
+public interface TrafficAdvisory {
+
+ void trafficNotification(String report);
+}
Added: incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java?view=auto&rev=551198
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java Wed Jun 27 08:31:38 2007
@@ -0,0 +1,39 @@
+/*
+ * 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 notification;
+
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@Service(TrafficAdvisory.class)
+@Scope("COMPOSITE")
+public class TrafficAdvisoryConsumer implements TrafficAdvisory {
+
+ @Property
+ protected String name;
+
+ public void trafficNotification(String report) {
+
+ System.out.println("Consumer [" + name + "] received report: " + report);
+ }
+}
Added: incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java?view=auto&rev=551198
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java Wed Jun 27 08:31:38 2007
@@ -0,0 +1,36 @@
+/*
+ * 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 notification;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+@Service(TestCaseProducer.class)
+@Scope("COMPOSITE")
+public class TrafficAdvisoryProducer implements TestCaseProducer {
+
+ @Reference
+ protected TrafficAdvisory destination;
+
+ public void produceTrafficNotification(String report) {
+
+ destination.trafficNotification(report);
+ }
+}
Added: incubator/tuscany/java/sca/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java?view=auto&rev=551198
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java (added)
+++ incubator/tuscany/java/sca/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java Wed Jun 27 08:31:38 2007
@@ -0,0 +1,58 @@
+/*
+ * 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 notification;
+
+import junit.framework.TestCase;
+
+import notification.TestCaseProducer;
+
+import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+public class TrafficAdvisoryTestCase extends TestCase {
+
+ private SCADomain domain;
+ private TestCaseProducer testCaseProducer;
+
+ public void testTrafficAdvisoryNotification() throws Exception {
+ try {
+ testCaseProducer.produceTrafficNotification("Nothing to report today");
+ } catch(Throwable e) {
+ e.printStackTrace();
+ }
+ }
+
+ protected void setUp() throws Exception {
+ try {
+ domain = SCADomain.newInstance("TrafficAdvisoryNotification.composite");
+ testCaseProducer = domain.getService(TestCaseProducer.class, "TrafficAdvisoryProducer");
+ } catch(Throwable e) {
+ e.printStackTrace();
+ if (e instanceof Exception) {
+ throw (Exception)e;
+ }
+ else {
+ throw new Exception(e);
+ }
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ domain.close();
+ }
+}
Added: incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType?view=auto&rev=551198
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType (added)
+++ incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType Wed Jun 27 08:31:38 2007
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+
+<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <service name="TrafficAdvisoryNotificationService">
+ <interface.java interface="notification.TrafficAdvisory"/>
+ </service>
+
+ <reference name="TrafficAdvisoryNotificationReference"
+ multiplicity="0..n">
+ <interface.java interface="notification.TrafficAdvisory"/>
+ </reference>
+</componentType>
Added: incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite?view=auto&rev=551198
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite (added)
+++ incubator/tuscany/java/sca/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite Wed Jun 27 08:31:38 2007
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * 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.
+-->
+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="TrafficAdvisoryNotificationLocalComposite">
+
+ <component name="TrafficAdvisoryProducer">
+ <implementation.java class="notification.TrafficAdvisoryProducer"/>
+ <reference name="destination" target="TrafficAdvisoryNotificationComponent"/>
+ </component>
+
+ <component name="TrafficAdvisoryNotificationComponent">
+ <implementation.notification name="TrafficAdvisoryNotification"/>
+ <!-- Never use > 1 reference elements here !! -->
+ <reference name="TrafficAdvisoryNotificationReference"
+ multiplicity="0..n"
+ target="TrafficAdvisoryConsumer1 TrafficAdvisoryConsumer2"/>
+ </component>
+
+ <component name="TrafficAdvisoryConsumer1">
+ <implementation.java class="notification.TrafficAdvisoryConsumer"/>
+ <property name="name">Consumer1</property>
+ </component>
+
+ <component name="TrafficAdvisoryConsumer2">
+ <implementation.java class="notification.TrafficAdvisoryConsumer"/>
+ <property name="name">Consumer2</property>
+ </component>
+
+</composite>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org