Author: prabath Date: Tue Dec 2 17:32:48 2008 New Revision: 25559 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=25559
Log: wsas eventing sample Added: trunk/wsas/java/carbon/samples/Eventing/ trunk/wsas/java/carbon/samples/Eventing/client/ trunk/wsas/java/carbon/samples/Eventing/client/build.xml trunk/wsas/java/carbon/samples/Eventing/client/pom.xml trunk/wsas/java/carbon/samples/Eventing/client/src/ trunk/wsas/java/carbon/samples/Eventing/client/src/org/ trunk/wsas/java/carbon/samples/Eventing/client/src/org/wso2/ trunk/wsas/java/carbon/samples/Eventing/client/src/org/wso2/wsas/ trunk/wsas/java/carbon/samples/Eventing/client/src/org/wso2/wsas/sample/ trunk/wsas/java/carbon/samples/Eventing/client/src/org/wso2/wsas/sample/eventing/ trunk/wsas/java/carbon/samples/Eventing/client/src/org/wso2/wsas/sample/eventing/Client.java trunk/wsas/java/carbon/samples/Eventing/consumer/ trunk/wsas/java/carbon/samples/Eventing/consumer/build.xml trunk/wsas/java/carbon/samples/Eventing/consumer/conf/ trunk/wsas/java/carbon/samples/Eventing/consumer/conf/services.xml trunk/wsas/java/carbon/samples/Eventing/consumer/pom.xml trunk/wsas/java/carbon/samples/Eventing/consumer/src/ trunk/wsas/java/carbon/samples/Eventing/consumer/src/org/ trunk/wsas/java/carbon/samples/Eventing/consumer/src/org/wso2/ trunk/wsas/java/carbon/samples/Eventing/consumer/src/org/wso2/wsas/ trunk/wsas/java/carbon/samples/Eventing/consumer/src/org/wso2/wsas/sample/ trunk/wsas/java/carbon/samples/Eventing/consumer/src/org/wso2/wsas/sample/eventing/ trunk/wsas/java/carbon/samples/Eventing/consumer/src/org/wso2/wsas/sample/eventing/StockQuoteConsumer.java trunk/wsas/java/carbon/samples/Eventing/pom.xml trunk/wsas/java/carbon/samples/Eventing/publisher/ trunk/wsas/java/carbon/samples/Eventing/publisher/build.xml trunk/wsas/java/carbon/samples/Eventing/publisher/conf/ trunk/wsas/java/carbon/samples/Eventing/publisher/conf/services.xml trunk/wsas/java/carbon/samples/Eventing/publisher/pom.xml trunk/wsas/java/carbon/samples/Eventing/publisher/src/ trunk/wsas/java/carbon/samples/Eventing/publisher/src/org/ trunk/wsas/java/carbon/samples/Eventing/publisher/src/org/wso2/ trunk/wsas/java/carbon/samples/Eventing/publisher/src/org/wso2/wsas/ trunk/wsas/java/carbon/samples/Eventing/publisher/src/org/wso2/wsas/sample/ trunk/wsas/java/carbon/samples/Eventing/publisher/src/org/wso2/wsas/sample/eventing/ trunk/wsas/java/carbon/samples/Eventing/publisher/src/org/wso2/wsas/sample/eventing/StockQuoteService.java Modified: trunk/wsas/java/carbon/samples/pom.xml Added: trunk/wsas/java/carbon/samples/Eventing/client/build.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/client/build.xml?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/client/build.xml Tue Dec 2 17:32:48 2008 @@ -0,0 +1,78 @@ +<!-- + ~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com) + ~ + ~ Licensed 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 default="build-all"> + + <property name="wso2wsas.home" value="../../"/> + <property name="lib" value="${wso2wsas.home}/lib"/> + <property name="repo.location" value="${wso2wsas.home}/repository"/> + <property name="temp.dir" value="temp"/> + <property name="classes" value="${temp.dir}/classes"/> + <property name="src" value="src"/> + <property name="services" value="services"/> + + <path id="axis2.class.path"> + <pathelement path="${java.class.path}"/> + <fileset dir="${wso2wsas.home}"> + <include name="lib/*.jar"/> + </fileset> + </path> + + <target name="init" depends="clean"> + <mkdir dir="${temp.dir}"/> + <mkdir dir="${classes}"/> + <mkdir dir="${services}"/> + </target> + + <target name="clean"> + <delete dir="${temp.dir}"/> + </target> + + <target name="compile-all" depends="init"> + <javac debug="on" destdir="${classes}"> + <src path="${src}"/> + <classpath refid="axis2.class.path"/> + </javac> + </target> + + <target name="build-service" depends="compile-all"> + <property name="aar.dir" value="${temp.dir}/publisher"/> + <mkdir dir="${aar.dir}"/> + + <mkdir dir="${aar.dir}/META-INF"/> + <copy file="conf/services.xml" tofile="${aar.dir}/META-INF/services.xml"/> + <copy toDir="${aar.dir}"> + <fileset dir="${classes}"> + <include name="**/*.class"/> + </fileset> + </copy> + + <jar destfile="${services}/Eventing-Publisher.aar"> + <fileset dir="${aar.dir}"/> + </jar> + </target> + + + <target name="build-all" + depends="build-service"> + <echo message="Copying the created aar files in to the repository"/> + <copy toDir="${repo.location}/services"> + <fileset dir="${services}"> + <include name="**/*.aar"/> + </fileset> + </copy> + </target> +</project> Added: trunk/wsas/java/carbon/samples/Eventing/client/pom.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/client/pom.xml?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/client/pom.xml Tue Dec 2 17:32:48 2008 @@ -0,0 +1,158 @@ +<!-- + ~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com) + ~ + ~ Licensed 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"> + + <parent> + <groupId>org.wso2.wsas</groupId> + <artifactId>wso2wsas-samples</artifactId> + <version>SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>wso2wsas-samples-eventing-client</artifactId> + <groupId>org.wso2.wsas</groupId> + <packaging>jar</packaging> + <name>Sample/Eventing/client</name> + <description>This is eventing client sample</description> + + <build> + <sourceDirectory>src</sourceDirectory> + <testSourceDirectory>test</testSourceDirectory> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.4</source> + <target>1.4</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <enableRulesSummary>false</enableRulesSummary> + </configuration> + </plugin> + <!--<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clover-plugin</artifactId> + <configuration> + <licenseLocation>${clover.license.file}</licenseLocation> + <targetPercentage>60%</targetPercentage> + <generateHtml>true</generateHtml> + <generatePdf>false</generatePdf> + <generateXml>false</generateXml> + <excludes> + <exclude>**/*TestSuite.java</exclude> + <exclude>**/*Test.java</exclude> + </excludes> + </configuration> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>aggregate</goal> + <goal>instrument</goal> + <goal>clover</goal> + </goals> + </execution> + </executions> + </plugin>--> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.axis2</artifactId> + <version>1.4.1-wso2</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.axiom</artifactId> + <version>1.2.7</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.eventing.savan</artifactId> + <version>SNAPSHOT</version> + </dependency> + </dependencies> + + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-report-plugin</artifactId> + <configuration> + <outputDirectory>../../../target/site/wso2wsas-samples/${artifactId} + </outputDirectory> + <reportsDirectory>target/surefire-reports</reportsDirectory> + <outputName>${artifactId}-test-report</outputName> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <configuration> + <outputDirectory>../../../target/site/wso2wsas-samples/${artifactId} + </outputDirectory> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>findbugs-maven-plugin</artifactId> + <version>1.1.1</version> + <configuration> + <!--<xmlOutput>true|false</xmlOutput> + <xmlOutputDirectory> + directory location of xml findbugs report + </xmlOutputDirectory> + <threshold>Normal</threshold> + <effort>Default</effort> + <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> + <includeFilterFile>findbugs-include.xml</includeFilterFile> + <visitors>FindDeadLocalStores,UnreadFields</visitors> + <omitVisitors>FindDeadLocalStores,UnreadFields</omitVisitors> + <onlyAnalyze>org.codehaus.mojo.findbugs.*</onlyAnalyze> + <pluginList>/libs/fb-contrib/fb-contrib-2.8.0.jar</pluginList> + <debug>true|false</debug> + <relaxed>true|false</relaxed>--> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + <!--<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clover-plugin</artifactId> + </plugin>--> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + </plugin> + </plugins> + </reporting> +</project> Added: trunk/wsas/java/carbon/samples/Eventing/client/src/org/wso2/wsas/sample/eventing/Client.java URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/client/src/org/wso2/wsas/sample/eventing/Client.java?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/client/src/org/wso2/wsas/sample/eventing/Client.java Tue Dec 2 17:32:48 2008 @@ -0,0 +1,156 @@ +package org.wso2.wsas.sample.eventing; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +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.AxisFault; +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 org.apache.savan.eventing.client.EventingClient; +import org.apache.savan.eventing.client.EventingClientBean; + +public class Client { + + final static String SUBSCRIBER_ID = "wso2-svan-subscriber"; + + static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); + static EventingClient eventingClient = null; + + public static void main(String[] args) throws Exception { + ServiceClient client = null; + ConfigurationContext confContext = null; + if (args.length != 2) { + System.out.println("Usage: Client <event source epr> <event sink epr>"); + return; + } + + confContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem("repo", + "repo/conf/client.axis2.xml"); + + client = new ServiceClient(confContext, null); + client.engageModule("addressing"); + int option = 0; + boolean goahead = true; + + while (goahead) { + displayMenu(); + option = getIntInput(); + switch (option) { + case 1: + startPublishing(client, args[0]); + break; + case 2: + subscribe(client, args[0], args[1]); + break; + case 3: + unsubscribe(); + break; + case 4: + stopPublishing(client, args[0]); + break; + case 5: + goahead = false; + break; + default: + goahead = false; + } + } + } + + private static void displayMenu() { + System.out.println("Press 1 to start publishing"); + System.out.println("Press 2 to subscribe"); + System.out.println("Press 3 to unsubscribe"); + System.out.println("Press 4 to stop publishing"); + System.out.println("Press 5 to Exit"); + } + + private static int getIntInput() throws IOException { + String option = reader.readLine(); + try { + return Integer.parseInt(option); + } catch (NumberFormatException e) { + // invalid option + return -1; + } + } + + private static void subscribe(ServiceClient client, String publisherEpr, String consumerEpr) + throws Exception { + + if (eventingClient != null) { + eventingClient.unsubscribe(SUBSCRIBER_ID); + } + + Options options = null; + EventingClientBean bean = null; + + options = new Options(); + options.setTo(new EndpointReference(publisherEpr)); + client.setOptions(options); + options.setManageSession(true); + + bean = new EventingClientBean(); + bean.setDeliveryEPR(new EndpointReference(consumerEpr)); + + eventingClient = new EventingClient(client); + eventingClient.subscribe(bean, SUBSCRIBER_ID); + } + + private static void unsubscribe() throws Exception { + if (eventingClient != null) { + eventingClient.unsubscribe(SUBSCRIBER_ID); + } + } + + private static void startPublishing(ServiceClient client, String epr) { + Options options = null; + + options = new Options(); + options.setAction("urn:publish"); + options.setTo(new EndpointReference(epr)); + client.setOptions(options); + options.setManageSession(true); + + try { + client.fireAndForget(getPayload("publish")); + } catch (AxisFault e) { + e.printStackTrace(); + } + } + + private static void stopPublishing(ServiceClient client, String epr) { + Options options = null; + + options = new Options(); + options.setAction("urn:stopPublishing"); + options.setTo(new EndpointReference(epr)); + client.setOptions(options); + options.setManageSession(true); + + try { + client.fireAndForget(getPayload("stopPublishing")); + } catch (AxisFault e) { + e.printStackTrace(); + } + } + + private static OMElement getPayload(String operation) { + OMFactory factory = null; + OMNamespace ns = null; + OMElement elem = null; + factory = OMAbstractFactory.getOMFactory(); + ns = factory.createOMNamespace("http://eventing.sample.wsas.wso2.org", "ns1"); + elem = factory.createOMElement(operation, ns); + return elem; + } + +} \ No newline at end of file Added: trunk/wsas/java/carbon/samples/Eventing/consumer/build.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/consumer/build.xml?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/consumer/build.xml Tue Dec 2 17:32:48 2008 @@ -0,0 +1,78 @@ +<!-- + ~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com) + ~ + ~ Licensed 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 default="build-all"> + + <property name="wso2wsas.home" value="../../"/> + <property name="lib" value="${wso2wsas.home}/lib"/> + <property name="repo.location" value="${wso2wsas.home}/repository"/> + <property name="temp.dir" value="temp"/> + <property name="classes" value="${temp.dir}/classes"/> + <property name="src" value="src"/> + <property name="services" value="services"/> + + <path id="axis2.class.path"> + <pathelement path="${java.class.path}"/> + <fileset dir="${wso2wsas.home}"> + <include name="lib/*.jar"/> + </fileset> + </path> + + <target name="init" depends="clean"> + <mkdir dir="${temp.dir}"/> + <mkdir dir="${classes}"/> + <mkdir dir="${services}"/> + </target> + + <target name="clean"> + <delete dir="${temp.dir}"/> + </target> + + <target name="compile-all" depends="init"> + <javac debug="on" destdir="${classes}"> + <src path="${src}"/> + <classpath refid="axis2.class.path"/> + </javac> + </target> + + <target name="build-service" depends="compile-all"> + <property name="aar.dir" value="${temp.dir}/publisher"/> + <mkdir dir="${aar.dir}"/> + + <mkdir dir="${aar.dir}/META-INF"/> + <copy file="conf/services.xml" tofile="${aar.dir}/META-INF/services.xml"/> + <copy toDir="${aar.dir}"> + <fileset dir="${classes}"> + <include name="**/*.class"/> + </fileset> + </copy> + + <jar destfile="${services}/Eventing-Publisher.aar"> + <fileset dir="${aar.dir}"/> + </jar> + </target> + + + <target name="build-all" + depends="build-service"> + <echo message="Copying the created aar files in to the repository"/> + <copy toDir="${repo.location}/services"> + <fileset dir="${services}"> + <include name="**/*.aar"/> + </fileset> + </copy> + </target> +</project> Added: trunk/wsas/java/carbon/samples/Eventing/consumer/conf/services.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/consumer/conf/services.xml?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/consumer/conf/services.xml Tue Dec 2 17:32:48 2008 @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<service name="StockQuoteConsumer"> + + <parameter name="ServiceClass" locked="false"> + org.wso2.wsas.sample.eventing.StockQuoteConsumer + </parameter> + + <operation name="publish" + mep="http://www.w3.org/2004/08/wsdl/in-only"> + <messageReceiver + class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" /> + </operation> + +</service> Added: trunk/wsas/java/carbon/samples/Eventing/consumer/pom.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/consumer/pom.xml?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/consumer/pom.xml Tue Dec 2 17:32:48 2008 @@ -0,0 +1,186 @@ +<!-- + ~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com) + ~ + ~ Licensed 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"> + + <parent> + <groupId>org.wso2.wsas</groupId> + <artifactId>wso2wsas-samples</artifactId> + <version>SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>wso2wsas-samples-eventing-consumer</artifactId> + <groupId>org.wso2.wsas</groupId> + <packaging>jar</packaging> + <name>Sample/Eventing/consumer</name> + <description>This is eventing consumer sample</description> + + <build> + <sourceDirectory>src</sourceDirectory> + <testSourceDirectory>test</testSourceDirectory> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.4</source> + <target>1.4</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <id>create_repo</id> + <phase>generate-test-resources</phase> + <configuration> + <tasks> + <!-- Adding the eventing sample --> + <mkdir dir="target/consumer/META-INF"/> + <copy todir="target/consumer"> + <fileset dir="target/classes"> + <include name="org/wso2/wsas/sample/eventing/**"/> + </fileset> + </copy> + <copy todir="target/consumer/META-INF"> + <fileset dir="conf"> + <include name="*.*"/> + </fileset> + </copy> + <jar destfile="target/Eventing-Consumer.aar" basedir="target/consumer"/> + <copy file="target/Eventing-Consumer.aar" + tofile="target/repository/services/Eventing-Consumer.aar"/> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <enableRulesSummary>false</enableRulesSummary> + </configuration> + </plugin> + <!--<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clover-plugin</artifactId> + <configuration> + <licenseLocation>${clover.license.file}</licenseLocation> + <targetPercentage>60%</targetPercentage> + <generateHtml>true</generateHtml> + <generatePdf>false</generatePdf> + <generateXml>false</generateXml> + <excludes> + <exclude>**/*TestSuite.java</exclude> + <exclude>**/*Test.java</exclude> + </excludes> + </configuration> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>aggregate</goal> + <goal>instrument</goal> + <goal>clover</goal> + </goals> + </execution> + </executions> + </plugin>--> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.axis2</artifactId> + <version>1.4.1-wso2</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.axiom</artifactId> + <version>1.2.7</version> + </dependency> + </dependencies> + + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-report-plugin</artifactId> + <configuration> + <outputDirectory>../../../target/site/wso2wsas-samples/${artifactId} + </outputDirectory> + <reportsDirectory>target/surefire-reports</reportsDirectory> + <outputName>${artifactId}-test-report</outputName> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <configuration> + <outputDirectory>../../../target/site/wso2wsas-samples/${artifactId} + </outputDirectory> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>findbugs-maven-plugin</artifactId> + <version>1.1.1</version> + <configuration> + <!--<xmlOutput>true|false</xmlOutput> + <xmlOutputDirectory> + directory location of xml findbugs report + </xmlOutputDirectory> + <threshold>Normal</threshold> + <effort>Default</effort> + <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> + <includeFilterFile>findbugs-include.xml</includeFilterFile> + <visitors>FindDeadLocalStores,UnreadFields</visitors> + <omitVisitors>FindDeadLocalStores,UnreadFields</omitVisitors> + <onlyAnalyze>org.codehaus.mojo.findbugs.*</onlyAnalyze> + <pluginList>/libs/fb-contrib/fb-contrib-2.8.0.jar</pluginList> + <debug>true|false</debug> + <relaxed>true|false</relaxed>--> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + <!--<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clover-plugin</artifactId> + </plugin>--> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + </plugin> + </plugins> + </reporting> +</project> Added: trunk/wsas/java/carbon/samples/Eventing/consumer/src/org/wso2/wsas/sample/eventing/StockQuoteConsumer.java URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/consumer/src/org/wso2/wsas/sample/eventing/StockQuoteConsumer.java?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/consumer/src/org/wso2/wsas/sample/eventing/StockQuoteConsumer.java Tue Dec 2 17:32:48 2008 @@ -0,0 +1,19 @@ +package org.wso2.wsas.sample.eventing; + +import org.apache.axiom.om.OMElement; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * The service implementation class + */ +public class StockQuoteConsumer { + + private static final Log log = LogFactory.getLog(StockQuoteConsumer.class); + + public void publish(OMElement param) throws Exception { + log.info("EVENT_SINK:::NOTIFIED"); + log.info(param); + } + +} \ No newline at end of file Added: trunk/wsas/java/carbon/samples/Eventing/pom.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/pom.xml?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/pom.xml Tue Dec 2 17:32:48 2008 @@ -0,0 +1,25 @@ +<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"> + + + <parent> + <groupId>org.wso2.wsas</groupId> + <artifactId>wso2wsas-samples</artifactId> + <version>SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>wso2wsas-samples-eventing</artifactId> + <groupId>org.wso2.wsas</groupId> + <name>Sample/Eventing</name> + <packaging>pom</packaging> + <description>This is eventing sample</description> + + <modules> + <module>publisher</module> + <module>consumer</module> + <module>client</module> + </modules> + +</project> Added: trunk/wsas/java/carbon/samples/Eventing/publisher/build.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/publisher/build.xml?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/publisher/build.xml Tue Dec 2 17:32:48 2008 @@ -0,0 +1,78 @@ +<!-- + ~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com) + ~ + ~ Licensed 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 default="build-all"> + + <property name="wso2wsas.home" value="../../"/> + <property name="lib" value="${wso2wsas.home}/lib"/> + <property name="repo.location" value="${wso2wsas.home}/repository"/> + <property name="temp.dir" value="temp"/> + <property name="classes" value="${temp.dir}/classes"/> + <property name="src" value="src"/> + <property name="services" value="services"/> + + <path id="axis2.class.path"> + <pathelement path="${java.class.path}"/> + <fileset dir="${wso2wsas.home}"> + <include name="lib/*.jar"/> + </fileset> + </path> + + <target name="init" depends="clean"> + <mkdir dir="${temp.dir}"/> + <mkdir dir="${classes}"/> + <mkdir dir="${services}"/> + </target> + + <target name="clean"> + <delete dir="${temp.dir}"/> + </target> + + <target name="compile-all" depends="init"> + <javac debug="on" destdir="${classes}"> + <src path="${src}"/> + <classpath refid="axis2.class.path"/> + </javac> + </target> + + <target name="build-service" depends="compile-all"> + <property name="aar.dir" value="${temp.dir}/publisher"/> + <mkdir dir="${aar.dir}"/> + + <mkdir dir="${aar.dir}/META-INF"/> + <copy file="conf/services.xml" tofile="${aar.dir}/META-INF/services.xml"/> + <copy toDir="${aar.dir}"> + <fileset dir="${classes}"> + <include name="**/*.class"/> + </fileset> + </copy> + + <jar destfile="${services}/Eventing-Publisher.aar"> + <fileset dir="${aar.dir}"/> + </jar> + </target> + + + <target name="build-all" + depends="build-service"> + <echo message="Copying the created aar files in to the repository"/> + <copy toDir="${repo.location}/services"> + <fileset dir="${services}"> + <include name="**/*.aar"/> + </fileset> + </copy> + </target> +</project> Added: trunk/wsas/java/carbon/samples/Eventing/publisher/conf/services.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/publisher/conf/services.xml?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/publisher/conf/services.xml Tue Dec 2 17:32:48 2008 @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<service name="StockQuoteService" scope="application"> + + <module ref="savan" /> + <module ref="addressing" /> + + <parameter name="ServiceClass" locked="false">org.wso2.wsas.sample.eventing.StockQuoteService</parameter> + <parameter name="serviceType">eventing</parameter> + +</service> Added: trunk/wsas/java/carbon/samples/Eventing/publisher/pom.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/publisher/pom.xml?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/publisher/pom.xml Tue Dec 2 17:32:48 2008 @@ -0,0 +1,196 @@ +<!-- + ~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com) + ~ + ~ Licensed 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"> + + <parent> + <groupId>org.wso2.wsas</groupId> + <artifactId>wso2wsas-samples</artifactId> + <version>SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>wso2wsas-samples-eventing-publisher</artifactId> + <groupId>org.wso2.wsas</groupId> + <packaging>jar</packaging> + <name>Sample/Eventing/publisher</name> + <description>This is eventing publisher sample</description> + + <build> + <sourceDirectory>src</sourceDirectory> + <testSourceDirectory>test</testSourceDirectory> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.4</source> + <target>1.4</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <id>create_repo</id> + <phase>generate-test-resources</phase> + <configuration> + <tasks> + <!-- Adding the eventing sample --> + <mkdir dir="target/publisher/META-INF"/> + <copy todir="target/publisher"> + <fileset dir="target/classes"> + <include name="org/wso2/wsas/sample/eventing/**"/> + </fileset> + </copy> + <copy todir="target/publisher/META-INF"> + <fileset dir="conf"> + <include name="*.*"/> + </fileset> + </copy> + <jar destfile="target/Eventing-Publisher.aar" basedir="target/publisher"/> + <copy file="target/Eventing-Publisher.aar" + tofile="target/repository/services/Eventing-Publisher.aar"/> + </tasks> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <configuration> + <enableRulesSummary>false</enableRulesSummary> + </configuration> + </plugin> + <!--<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clover-plugin</artifactId> + <configuration> + <licenseLocation>${clover.license.file}</licenseLocation> + <targetPercentage>60%</targetPercentage> + <generateHtml>true</generateHtml> + <generatePdf>false</generatePdf> + <generateXml>false</generateXml> + <excludes> + <exclude>**/*TestSuite.java</exclude> + <exclude>**/*Test.java</exclude> + </excludes> + </configuration> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>aggregate</goal> + <goal>instrument</goal> + <goal>clover</goal> + </goals> + </execution> + </executions> + </plugin>--> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.axis2</artifactId> + <version>1.4.1-wso2</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.axiom</artifactId> + <version>1.2.7</version> + </dependency> + <dependency> + <groupId>org.wso2.carbon</groupId> + <artifactId>org.wso2.carbon.eventing.savan</artifactId> + <version>SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate</artifactId> + <version>3.2.5.ga</version> + </dependency> + </dependencies> + + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-report-plugin</artifactId> + <configuration> + <outputDirectory>../../../target/site/wso2wsas-samples/${artifactId} + </outputDirectory> + <reportsDirectory>target/surefire-reports</reportsDirectory> + <outputName>${artifactId}-test-report</outputName> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <configuration> + <outputDirectory>../../../target/site/wso2wsas-samples/${artifactId} + </outputDirectory> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>findbugs-maven-plugin</artifactId> + <version>1.1.1</version> + <configuration> + <!--<xmlOutput>true|false</xmlOutput> + <xmlOutputDirectory> + directory location of xml findbugs report + </xmlOutputDirectory> + <threshold>Normal</threshold> + <effort>Default</effort> + <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> + <includeFilterFile>findbugs-include.xml</includeFilterFile> + <visitors>FindDeadLocalStores,UnreadFields</visitors> + <omitVisitors>FindDeadLocalStores,UnreadFields</omitVisitors> + <onlyAnalyze>org.codehaus.mojo.findbugs.*</onlyAnalyze> + <pluginList>/libs/fb-contrib/fb-contrib-2.8.0.jar</pluginList> + <debug>true|false</debug> + <relaxed>true|false</relaxed>--> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + </plugin> + <!--<plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clover-plugin</artifactId> + </plugin>--> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + </plugin> + </plugins> + </reporting> +</project> Added: trunk/wsas/java/carbon/samples/Eventing/publisher/src/org/wso2/wsas/sample/eventing/StockQuoteService.java URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/Eventing/publisher/src/org/wso2/wsas/sample/eventing/StockQuoteService.java?pathrev=25559 ============================================================================== --- (empty file) +++ trunk/wsas/java/carbon/samples/Eventing/publisher/src/org/wso2/wsas/sample/eventing/StockQuoteService.java Tue Dec 2 17:32:48 2008 @@ -0,0 +1,93 @@ +package org.wso2.wsas.sample.eventing; + +import java.util.Random; + +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.AxisFault; +import org.apache.axis2.client.Options; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.context.ServiceContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.savan.publication.client.PublicationClient; +import org.apache.savan.storage.SubscriberStore; +import org.apache.savan.util.CommonUtil; + +/** + * The service implementation class + */ +public class StockQuoteService { + + private static final Log log = LogFactory.getLog(StockQuoteService.class); + final static String STOCK = "Stock"; + final static String NAMESPACE = "eventing.sample.wsas.wso2.org"; + OMElement data = null; + Random r = new Random(); + boolean goahead = true; + + /** + * + * @throws AxisFault + */ + public void publish() throws AxisFault { + SubscriberStore store = null; + PublicationClient publicationClient = null; + ServiceContext serviceContext = null; + serviceContext = MessageContext.getCurrentMessageContext().getServiceContext(); + Options options = null; + goahead = true; + + try { + while (true && goahead) { + Thread.sleep(5000); + store = CommonUtil.getSubscriberStore(serviceContext.getAxisService()); + if (store != null) { + log.info("EVENT_SOURCE:::Publishing next publication..."); + data = getNextPublicationData(); + publicationClient = new PublicationClient(serviceContext + .getConfigurationContext()); + options = new Options(); + options.setAction("urn:publish"); + try { + publicationClient.sendPublication(data, serviceContext.getAxisService(), + null, options); + } catch (Exception e) { + // proceed with sending publications. + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void stopPublishing() throws AxisFault { + goahead = false; + } + + /** + * + * @return + */ + private OMElement getNextPublicationData() { + OMFactory factory = null; + OMNamespace namespace = null; + OMElement stockElement = null; + OMElement data = null; + + factory = OMAbstractFactory.getOMFactory(); + namespace = factory.createOMNamespace(NAMESPACE, "ns1"); + stockElement = factory.createOMElement(STOCK, namespace); + + int value = r.nextInt(); + stockElement.setText(Integer.toString(value)); + + data = factory.createOMElement("publish", namespace); + data.addChild(stockElement); + + return data; + } +} Modified: trunk/wsas/java/carbon/samples/pom.xml URL: http://wso2.org/svn/browse/wso2/trunk/wsas/java/carbon/samples/pom.xml?rev=25559&r1=25558&r2=25559&view=diff ============================================================================== --- trunk/wsas/java/carbon/samples/pom.xml (original) +++ trunk/wsas/java/carbon/samples/pom.xml Tue Dec 2 17:32:48 2008 @@ -1,76 +1,77 @@ -<!-- - ~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com) - ~ - ~ Licensed 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"> - - <parent> - <groupId>org.wso2.wsas</groupId> - <artifactId>wsas-parent</artifactId> - <version>SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <artifactId>wso2wsas-samples</artifactId> - <packaging>pom</packaging> - <name>Samples</name> - <description>All the samples contained in WSO2 WSAS</description> - - <reporting> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-report-plugin</artifactId> - <configuration> - <outputDirectory>../../target/site/${artifactId}</outputDirectory> - <reportsDirectory>target/surefire-reports</reportsDirectory> - <outputName>${artifactId}-test-report</outputName> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jxr-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-site-plugin</artifactId> - <configuration> - <outputDirectory>../../target/site/${artifactId}</outputDirectory> - </configuration> - </plugin> - </plugins> - </reporting> - - <modules> - <module>Chad</module> - <module>CommodityQuote</module> - <module>TinyURL</module> - <module>Trader</module> - <module>FlickrClient</module> - <module>DataService</module> - <module>NodeManagement</module> - <module>MEX</module> - <module>MTOM</module> - <module>XKMS</module> - <module>Xfer</module> - <module>sts-sample</module> - <module>EJBService</module> - <module>JAXWS</module> - <module>Jibx</module> - <module>HelloWorld</module> - </modules> -</project> +<!-- + ~ Copyright 2005-2007 WSO2, Inc. (http://wso2.com) + ~ + ~ Licensed 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"> + + <parent> + <groupId>org.wso2.wsas</groupId> + <artifactId>wsas-parent</artifactId> + <version>SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + <artifactId>wso2wsas-samples</artifactId> + <packaging>pom</packaging> + <name>Samples</name> + <description>All the samples contained in WSO2 WSAS</description> + + <reporting> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-report-plugin</artifactId> + <configuration> + <outputDirectory>../../target/site/${artifactId}</outputDirectory> + <reportsDirectory>target/surefire-reports</reportsDirectory> + <outputName>${artifactId}-test-report</outputName> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-site-plugin</artifactId> + <configuration> + <outputDirectory>../../target/site/${artifactId}</outputDirectory> + </configuration> + </plugin> + </plugins> + </reporting> + + <modules> + <module>Chad</module> + <module>CommodityQuote</module> + <module>TinyURL</module> + <module>Trader</module> + <module>FlickrClient</module> + <module>DataService</module> + <module>NodeManagement</module> + <module>MEX</module> + <module>MTOM</module> + <module>XKMS</module> + <module>Xfer</module> + <module>sts-sample</module> + <module>EJBService</module> + <module>JAXWS</module> + <module>Jibx</module> + <module>HelloWorld</module> + <module>Eventing</module> + </modules> +</project> _______________________________________________ Wsas-java-dev mailing list [email protected] https://wso2.org/cgi-bin/mailman/listinfo/wsas-java-dev
