[esb-java-dev] svn commit r24363 - in branches/synapse/1.2.wso2v1: modules/core/src/main/java/org/apache/synapse/eventing modules/samples/src/main/java/samples/userguide modules/samples/src/main/scripts repository/conf
asankaa at wso2.com
asankaa at wso2.com
Thu Nov 20 07:53:15 PST 2008
Author: asankaa
Date: Thu Nov 20 07:53:14 2008
New Revision: 24363
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=24363
Log:
adding samples to test
Added:
branches/synapse/1.2.wso2v1/modules/samples/src/main/java/samples/userguide/EventSender.java
branches/synapse/1.2.wso2v1/modules/samples/src/main/java/samples/userguide/EventSubscriber.java
Modified:
branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventingMessageReceiver.java
branches/synapse/1.2.wso2v1/modules/samples/src/main/scripts/build.xml
branches/synapse/1.2.wso2v1/repository/conf/synapse.xml
Modified: branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventingMessageReceiver.java
URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventingMessageReceiver.java?rev=24363&r1=24362&r2=24363&view=diff
==============================================================================
--- branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventingMessageReceiver.java (original)
+++ branches/synapse/1.2.wso2v1/modules/core/src/main/java/org/apache/synapse/eventing/EventingMessageReceiver.java Thu Nov 20 07:53:14 2008
@@ -50,6 +50,7 @@
if (EventingConstants.SUBSCRIBE_ACTION.equals(mc.getWSAAction())) {
Subscription subscription = SubscriptionFactory.createSubscription(smc);
eventSource.getSubscriptionManager().addSubscription(subscription);
+ String replyAddress = mc.getOptions().getTo().getAddress();
} else {
List<Subscription> subscribers = eventSource.getSubscriptionManager().getMatchingSubscribers(smc);
for (Subscription subscription : subscribers) {
Added: branches/synapse/1.2.wso2v1/modules/samples/src/main/java/samples/userguide/EventSender.java
URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/samples/src/main/java/samples/userguide/EventSender.java?pathrev=24363
==============================================================================
--- (empty file)
+++ branches/synapse/1.2.wso2v1/modules/samples/src/main/java/samples/userguide/EventSender.java Thu Nov 20 07:53:14 2008
@@ -0,0 +1,113 @@
+/*
+* 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 samples.userguide;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.impl.llom.util.AXIOMUtil;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+
+import java.io.File;
+
+
+public class EventSender {
+
+ public static void main(String[] args) {
+ try {
+ executeClient();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static String getProperty(String name, String def) {
+ String result = System.getProperty(name);
+ if (result == null || result.length() == 0) {
+ result = def;
+ }
+ return result;
+ }
+
+ public static void executeClient() throws Exception {
+ Options options = new Options();
+ ServiceClient serviceClient;
+ ConfigurationContext configContext = null;
+
+ String addUrl = getProperty("addurl", "http://localhost:8280/soap/eventing");
+ String trpUrl = getProperty("trpurl", null);
+ String prxUrl = getProperty("prxurl", null);
+ String repo = getProperty("repository", "client_repo");
+ String symbol = getProperty("symbol", "GOOG");
+ String price = getProperty("price", "10.10");
+ String qty = getProperty("qty", "1000");
+ String topic = getProperty("topic", "wso2/event/test");
+ String action = getProperty("action", "urn:event");
+ String topicns = getProperty("topicns","http://wso2.com/aip");
+
+ if (repo != null && !"null".equals(repo)) {
+ configContext =
+ ConfigurationContextFactory.
+ createConfigurationContextFromFileSystem(repo,
+ repo + File.separator + "conf" + File.separator + "axis2.xml");
+ serviceClient = new ServiceClient(configContext, null);
+ } else {
+ serviceClient = new ServiceClient();
+ }
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+
+ OMNamespace nsaip = factory.createOMNamespace(topicns, "aip");
+
+ // set the target topic
+ OMElement topicOm = factory.createOMElement("Topic", nsaip);
+ factory.createOMText(topicOm, topic);
+
+ // set addressing, transport and proxy url
+
+ serviceClient.engageModule("addressing");
+ options.setTo(new EndpointReference(addUrl));
+ options.setAction(action);
+ serviceClient.setOptions(options);
+ serviceClient.addHeader(topicOm);
+ OMElement payload = AXIOMUtil.stringToOM("<m:placeOrder xmlns:m=\"http://services.samples/xsd\">\n" +
+ " <m:order>\n" +
+ " <m:price>" + price + "</m:price>\n" +
+ " <m:quantity>" + qty + "</m:quantity>\n" +
+ " <m:symbol>" + symbol + "</m:symbol>\n" +
+ " </m:order>\n" +
+ "</m:placeOrder>");
+
+ System.out.println("Sending Event : \n" + payload.toString());
+ try {
+ serviceClient.sendRobust(payload);
+ System.out.println("Event sent to topic " + topic);
+ if (configContext != null) {
+ configContext.terminate();
+ }
+ } catch (Exception ignore) {
+ }
+
+ }
+}
\ No newline at end of file
Added: branches/synapse/1.2.wso2v1/modules/samples/src/main/java/samples/userguide/EventSubscriber.java
URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/samples/src/main/java/samples/userguide/EventSubscriber.java?pathrev=24363
==============================================================================
--- (empty file)
+++ branches/synapse/1.2.wso2v1/modules/samples/src/main/java/samples/userguide/EventSubscriber.java Thu Nov 20 07:53:14 2008
@@ -0,0 +1,121 @@
+/*
+* 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 samples.userguide;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+
+import java.io.File;
+import java.util.Date;
+
+
+public class EventSubscriber {
+
+ public static void main(String[] args) {
+ try {
+ executeClient();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static String getProperty(String name, String def) {
+ String result = System.getProperty(name);
+ if (result == null || result.length() == 0) {
+ result = def;
+ }
+ return result;
+ }
+
+ public static void executeClient() throws Exception {
+ Options options = new Options();
+ ServiceClient serviceClient;
+ ConfigurationContext configContext = null;
+
+ String addUrl = getProperty("addurl", "http://localhost:8280/soap/eventing");
+ String trpUrl = getProperty("trpurl", null);
+ String prxUrl = getProperty("prxurl", null);
+ String repo = getProperty("repository", "client_repo");
+ String topic = getProperty("topic", "wso2/event/test");
+ String address = getProperty("address", "http://localhost:9000/soap/SimpleStockQuoteService");
+
+
+ if (repo != null && !"null".equals(repo)) {
+ configContext =
+ ConfigurationContextFactory.
+ createConfigurationContextFromFileSystem(repo,
+ repo + File.separator + "conf" + File.separator + "axis2.xml");
+ serviceClient = new ServiceClient(configContext, null);
+ } else {
+ serviceClient = new ServiceClient();
+ }
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMElement message = factory.createOMElement("message", null);
+
+ OMNamespace nsxmlins = factory.createOMNamespace("http://www.w3.org/2001/XMLSchema", "xmlns");
+ OMNamespace nss11 = factory.createOMNamespace("http://schemas.xmlsoap.org/soap/envelope", "s11");
+ OMNamespace nswsa = factory.createOMNamespace("http://schemas.xmlsoap.org/ws/2004/08/addressing", "wsa");
+ OMNamespace nswse = factory.createOMNamespace("http://schemas.xmlsoap.org/ws/2004/08/eventing", "wse");
+
+
+ OMElement subscribeOm = factory.createOMElement("Subscribe", nswse);
+ OMElement deliveryOm = factory.createOMElement("Delivery", nswse);
+ deliveryOm.addAttribute(factory.createOMAttribute("Mode", null, "http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push"));
+ OMElement notifyToOm = factory.createOMElement("NotifyTo", nswse);
+ OMElement addressOm = factory.createOMElement("Address", nswsa);
+ factory.createOMText(addressOm, address);
+ OMElement expiresOm = factory.createOMElement("Expires", nswse);
+ factory.createOMText(expiresOm, "2008-12-26T21:07:00.000-08:00");
+ OMElement filterOm = factory.createOMElement("Filter", nswse);
+ filterOm.addAttribute(factory.createOMAttribute("Dialect", null, "http://synapse.apache.org/eventing/dialect/topicFilter"));
+ factory.createOMText(filterOm, topic);
+
+
+ notifyToOm.addChild(addressOm);
+ deliveryOm.addChild(notifyToOm);
+ subscribeOm.addChild(deliveryOm);
+ subscribeOm.addChild(expiresOm);
+ subscribeOm.addChild(filterOm);
+
+ // set addressing, transport and proxy url
+
+ serviceClient.engageModule("addressing");
+ options.setTo(new EndpointReference(addUrl));
+
+ options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe");
+ serviceClient.setOptions(options);
+ System.out.println("Subscribing \n"+subscribeOm.toString());
+ serviceClient.sendRobust(subscribeOm);
+ System.out.println("Subscribed to topic "+topic);
+ try {
+ if (configContext != null) {
+ configContext.terminate();
+ }
+ } catch (Exception ignore) {
+ }
+ }
+}
\ No newline at end of file
Modified: branches/synapse/1.2.wso2v1/modules/samples/src/main/scripts/build.xml
URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/modules/samples/src/main/scripts/build.xml?rev=24363&r1=24362&r2=24363&view=diff
==============================================================================
--- branches/synapse/1.2.wso2v1/modules/samples/src/main/scripts/build.xml (original)
+++ branches/synapse/1.2.wso2v1/modules/samples/src/main/scripts/build.xml Thu Nov 20 07:53:14 2008
@@ -90,6 +90,11 @@
<property name="opt_file" value=""/>
<property name="class.dir" value="target/classes"/>
<property name="qty" value=""/>
+ <property name="price" value=""/>
+ <property name="topic" value=""/>
+ <property name="address" value=""/>
+ <property name="action" value=""/>
+ <property name="topicns" value=""/>
<target name="clean">
<delete dir="target" quiet="true"/>
@@ -159,6 +164,36 @@
</java>
</target>
+ <target name="eventsubscriber" depends="compile">
+ <java classname="samples.userguide.EventSubscriber"
+ classpathref="javac.classpath" fork="true">
+ <sysproperty key="addurl" value="${addurl}"/>
+ <sysproperty key="trpurl" value="${trpurl}"/>
+ <sysproperty key="prxurl" value="${prxurl}"/>
+ <sysproperty key="topic" value="${topic}"/>
+ <sysproperty key="address" value="${address}"/>
+ <sysproperty key="repository" value="${repository}"/>
+ <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
+ </java>
+ </target>
+
+ <target name="eventsender" depends="compile">
+ <java classname="samples.userguide.EventSender"
+ classpathref="javac.classpath" fork="true">
+ <sysproperty key="symbol" value="${symbol}"/>
+ <sysproperty key="price" value="${price}"/>
+ <sysproperty key="addurl" value="${addurl}"/>
+ <sysproperty key="trpurl" value="${trpurl}"/>
+ <sysproperty key="prxurl" value="${prxurl}"/>
+ <sysproperty key="qty" value="${qty}"/>
+ <sysproperty key="repository" value="${repository}"/>
+ <sysproperty key="java.io.tmpdir" value="./../../work/temp/sampleClient"/>
+ <sysproperty key="topic" value="${topic}"/>
+ <sysproperty key="action" value="${action}"/>
+ <sysproperty key="topicns" value="${topicns}"/>
+ </java>
+ </target>
+
<target name="optimizeclient" depends="compile">
<java classname="samples.userguide.MTOMSwAClient"
classpathref="javac.classpath" fork="true">
Modified: branches/synapse/1.2.wso2v1/repository/conf/synapse.xml
URL: http://wso2.org/svn/browse/wso2/branches/synapse/1.2.wso2v1/repository/conf/synapse.xml?rev=24363&r1=24362&r2=24363&view=diff
==============================================================================
--- branches/synapse/1.2.wso2v1/repository/conf/synapse.xml (original)
+++ branches/synapse/1.2.wso2v1/repository/conf/synapse.xml Thu Nov 20 07:53:14 2008
@@ -19,14 +19,18 @@
<!-- A simple Synapse configuration -->
<definitions xmlns="http://ws.apache.org/ns/synapse">
- <eventSource name="eventing">
- <subscriptionManager class="org.apache.synapse.eventing.managers.RegistryBasedSubscriptionManager">
- <property name="registryURL" value="http://localhost:8180/wso2registry"/>
- <property name="username" value="admin"/>
- <property name="password" value="admin"/>
- <property name="topicHeaderName" value="Topic"/>
- <property name="topicHeaderNS" value="http://wso2.com/aip"/>
- </subscriptionManager>
- </eventSource>
- <log level="full"/>
-</definitions>
+ <in>
+ <!-- Log all messages passing through -->
+ <log level="full"/>
+
+ <!-- ensure that the default configuration only sends if it is one of samples -->
+ <!-- Otherwise Synapse would be an open proxy by default (BAD!) -->
+ <filter source="get-property('To')" regex="http://localhost:9000.*">
+ <!-- Send the messages where they have been sent (i.e. implicit "To" EPR) -->
+ <send/>
+ </filter>
+ </in>
+ <out>
+ <send/>
+ </out>
+</definitions>
\ No newline at end of file
More information about the Esb-java-dev
mailing list