You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/10/24 22:04:05 UTC
svn commit: r1188341 - in
/cxf/trunk/distribution/src/main/release/samples/ws_notification: ./
README.txt pom.xml src/ src/main/ src/main/java/ src/main/java/demo/
src/main/java/demo/client/ src/main/java/demo/client/Client.java
Author: dkulp
Date: Mon Oct 24 20:04:04 2011
New Revision: 1188341
URL: http://svn.apache.org/viewvc?rev=1188341&view=rev
Log:
Add a very basic WS-Notification sample to get people started with it.
Added:
cxf/trunk/distribution/src/main/release/samples/ws_notification/
cxf/trunk/distribution/src/main/release/samples/ws_notification/README.txt (with props)
cxf/trunk/distribution/src/main/release/samples/ws_notification/pom.xml (with props)
cxf/trunk/distribution/src/main/release/samples/ws_notification/src/
cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/
cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/
cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/demo/
cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/demo/client/
cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/demo/client/Client.java (with props)
Added: cxf/trunk/distribution/src/main/release/samples/ws_notification/README.txt
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/ws_notification/README.txt?rev=1188341&view=auto
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/ws_notification/README.txt (added)
+++ cxf/trunk/distribution/src/main/release/samples/ws_notification/README.txt Mon Oct 24 20:04:04 2011
@@ -0,0 +1,28 @@
+WS-Notification Demo
+====================
+
+This demo shows how to use the WS-Notification service and API's
+provided by Apache CXF.
+
+
+Please review the README in the samples directory before continuing.
+
+
+Building and running the demo using Maven
+-----------------------------------------
+
+From the base directory of this sample (i.e., where this README file is
+located), the maven pom.xml file can be used to build and run the demo.
+
+Using either UNIX or Windows:
+
+ mvn install (builds the demo)
+ mvn -Pwsn-server (from one command line window)
+ Mvn -Pclient (from a second command line window)
+
+On startup, the client will create a Consumer and subscribe that consumer
+to a specific Topic on the broker. It will then use the NotificationBroker
+API's to notify the Consumers of an event.
+
+
+
Propchange: cxf/trunk/distribution/src/main/release/samples/ws_notification/README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/distribution/src/main/release/samples/ws_notification/README.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: cxf/trunk/distribution/src/main/release/samples/ws_notification/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/ws_notification/pom.xml?rev=1188341&view=auto
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/ws_notification/pom.xml (added)
+++ cxf/trunk/distribution/src/main/release/samples/ws_notification/pom.xml Mon Oct 24 20:04:04 2011
@@ -0,0 +1,131 @@
+<!--
+ 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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.cxf.samples</groupId>
+ <artifactId>ws_notification</artifactId>
+ <name>WS-Notification Demo</name>
+ <description>WS-Notification Demo</description>
+ <version>2.5.0-SNAPSHOT</version>
+
+ <parent>
+ <groupId>org.apache.cxf.samples</groupId>
+ <artifactId>cxf-samples</artifactId>
+ <version>2.5.0-SNAPSHOT</version>
+ </parent>
+ <properties>
+ <cxf.version>${project.version}</cxf.version>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <profile>
+ <id>wsn-server</id>
+ <build>
+ <defaultGoal>test</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>org.apache.cxf.wsn.services.Service</mainClass>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>client</id>
+ <build>
+ <defaultGoal>test</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <goals>
+ <goal>java</goal>
+ </goals>
+ <configuration>
+ <mainClass>demo.client.Client</mainClass>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>2.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>2.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-jetty</artifactId>
+ <version>2.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-addr</artifactId>
+ <version>2.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-policy</artifactId>
+ <version>2.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-common-utilities</artifactId>
+ <version>2.5.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.services.wsn</groupId>
+ <artifactId>cxf-services-wsn-core</artifactId>
+ <version>2.5.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
Propchange: cxf/trunk/distribution/src/main/release/samples/ws_notification/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/distribution/src/main/release/samples/ws_notification/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: cxf/trunk/distribution/src/main/release/samples/ws_notification/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/demo/client/Client.java
URL: http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/demo/client/Client.java?rev=1188341&view=auto
==============================================================================
--- cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/demo/client/Client.java (added)
+++ cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/demo/client/Client.java Mon Oct 24 20:04:04 2011
@@ -0,0 +1,79 @@
+/**
+ * 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 demo.client;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.wsn.client.Consumer;
+import org.apache.cxf.wsn.client.NotificationBroker;
+import org.apache.cxf.wsn.client.Subscription;
+import org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType;
+
+/**
+ *
+ */
+public class Client {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) throws Exception {
+ String wsnPort = "9000";
+ if (args.length > 0) {
+ wsnPort = args[0];
+ }
+
+ // Start a consumer that will listen for notification messages
+ // We'll just print the text content out for now.
+ Consumer consumer = new Consumer(new Consumer.Callback() {
+ public void notify(NotificationMessageHolderType message) {
+ Object o = message.getMessage().getAny();
+ System.out.println(message.getMessage().getAny());
+ if (o instanceof Element) {
+ System.out.println(((Element)o).getTextContent());
+ }
+ }
+ }, "http://localhost:9001/MyConsumer");
+
+
+ // Create a subscription for a Topic on the broker
+ NotificationBroker notificationBroker
+ = new NotificationBroker("http://localhost:" + wsnPort + "/wsn/NotificationBroker");
+ Subscription subscription = notificationBroker.subscribe(consumer, "MyTopic");
+
+
+ // Send a notification on the Topic
+ notificationBroker.notify("MyTopic",
+ new JAXBElement<String>(new QName("urn:test:org", "foo"),
+ String.class, "Hello World!"));
+
+ // Just sleep for a bit to make sure the notification gets delivered
+ Thread.sleep(5000);
+
+ // Cleanup and exit
+ subscription.unsubscribe();
+ consumer.stop();
+ System.exit(0);
+ }
+
+}
Propchange: cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/demo/client/Client.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/distribution/src/main/release/samples/ws_notification/src/main/java/demo/client/Client.java
------------------------------------------------------------------------------
svn:keywords = Rev Date