You are viewing a plain text version of this content. The canonical link for it is here.
Posted to savan-dev@ws.apache.org by ch...@apache.org on 2007/05/22 07:44:16 UTC
svn commit: r540427 - in /webservices/savan/trunk/java: ./ modules/
modules/core/ modules/core/src/ modules/core/src/main/resources/META-INF/
modules/mar/ modules/samples/ modules/samples/eventing/
modules/samples/eventing/src/ modules/samples/eventing...
Author: chamikara
Date: Mon May 21 22:44:15 2007
New Revision: 540427
URL: http://svn.apache.org/viewvc?view=rev&rev=540427
Log:
Made Savan a multi module project.
Changed the package name to org.apache.ws.savan
Created modules - core,mar,samples
Added:
webservices/savan/trunk/java/modules/
webservices/savan/trunk/java/modules/core/
webservices/savan/trunk/java/modules/core/pom.xml
webservices/savan/trunk/java/modules/core/src/
- copied from r540418, webservices/savan/trunk/java/src/
webservices/savan/trunk/java/modules/mar/
webservices/savan/trunk/java/modules/mar/module.xml
webservices/savan/trunk/java/modules/mar/pom.xml
webservices/savan/trunk/java/modules/samples/
webservices/savan/trunk/java/modules/samples/eventing/
webservices/savan/trunk/java/modules/samples/eventing/build.xml
webservices/savan/trunk/java/modules/samples/eventing/listner1.services.xml
webservices/savan/trunk/java/modules/samples/eventing/listner2.services.xml
webservices/savan/trunk/java/modules/samples/eventing/publisher.services.xml
webservices/savan/trunk/java/modules/samples/eventing/readme.txt
webservices/savan/trunk/java/modules/samples/eventing/run.bat
webservices/savan/trunk/java/modules/samples/eventing/run.sh (with props)
webservices/savan/trunk/java/modules/samples/eventing/src/
webservices/savan/trunk/java/modules/samples/eventing/src/sample/
webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/
webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/Client.java
webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService1.java
webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService2.java
webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/PublisherService.java
Removed:
webservices/savan/trunk/java/modules/core/src/main/resources/META-INF/
webservices/savan/trunk/java/src/
Modified:
webservices/savan/trunk/java/pom.xml
Added: webservices/savan/trunk/java/modules/core/pom.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/core/pom.xml?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/core/pom.xml (added)
+++ webservices/savan/trunk/java/modules/core/pom.xml Mon May 21 22:44:15 2007
@@ -0,0 +1,37 @@
+<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.apache.ws.savan</groupId>
+ <artifactId>savan-parent</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ws.savan</groupId>
+ <artifactId>savan-core</artifactId>
+ <packaging>jar</packaging>
+ <name>Savan - Core</name>
+
+ <build>
+ <sourceDirectory>src/main/java</sourceDirectory>
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: webservices/savan/trunk/java/modules/mar/module.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/mar/module.xml?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/mar/module.xml (added)
+++ webservices/savan/trunk/java/modules/mar/module.xml Mon May 21 22:44:15 2007
@@ -0,0 +1,12 @@
+<module name="Savan" class="org.apache.savan.module.SavanModule">
+
+ <operation name="SavanInOutOperation" mep="http://www.w3.org/2004/08/wsdl/in-out">
+ <messageReceiver class="org.apache.savan.messagereceiver.SavanInOutMessageReceiver"/>
+
+ <actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</actionMapping>
+ <actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew</actionMapping>
+ <actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus</actionMapping>
+ <actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</actionMapping>
+ </operation>
+
+</module>
Added: webservices/savan/trunk/java/modules/mar/pom.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/mar/pom.xml?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/mar/pom.xml (added)
+++ webservices/savan/trunk/java/modules/mar/pom.xml Mon May 21 22:44:15 2007
@@ -0,0 +1,83 @@
+<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.apache.ws.savan</groupId>
+ <artifactId>savan-parent</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ws.savan</groupId>
+ <artifactId>savan</artifactId>
+ <packaging>mar</packaging>
+ <name>Savan - Mar</name>
+
+ <build>
+ <sourceDirectory>src/main/java</sourceDirectory>
+ <testSourceDirectory>src/main/java</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>create-test-resources</id>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <tasks>
+ <!--copying classes from the core module-->
+ <copydir src="../core/target/classes"
+ dest="target/classes"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ <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.axis2</groupId>
+ <artifactId>axis2-mar-maven-plugin</artifactId>
+ <version>SNAPSHOT</version>
+ <extensions>true</extensions>
+
+ <configuration>
+ <includeDependencies>false</includeDependencies>
+ <moduleXmlFile>module.xml</moduleXmlFile>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.sandesha2</groupId>
+ <artifactId>sandesha2-core</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
Added: webservices/savan/trunk/java/modules/samples/eventing/build.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/build.xml?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/build.xml (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/build.xml Mon May 21 22:44:15 2007
@@ -0,0 +1,86 @@
+<project default="build.sample">
+
+
+ <!--<classpath id="classpath1">
+ <pathelement location="lib/*.jar"/>
+ </classpath>-->
+
+ <target name="build.sample">
+ <property name="eventing.temp.dir" value="build/temp" />
+ <property name="listner1.temp.dir" value="${eventing.temp.dir}/listner1" />
+ <property name="listner2.temp.dir" value="${eventing.temp.dir}/listner2" />
+ <property name="publisher.temp.dir" value="${eventing.temp.dir}/publisher" />
+
+ <mkdir dir="${listner1.temp.dir}" />
+ <mkdir dir="${listner1.temp.dir}/META-INF" />
+ <mkdir dir="${listner2.temp.dir}" />
+ <mkdir dir="${listner2.temp.dir}/META-INF" />
+ <mkdir dir="${publisher.temp.dir}" />
+ <mkdir dir="${publisher.temp.dir}/META-INF" />
+
+ <mkdir dir="build/classes" />
+ <mkdir dir="build/lib" />
+
+ <javac srcdir="src" destdir="build/classes">
+ <classpath>
+ <fileset dir="build/lib">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </javac>
+
+ <copy toFile="${listner1.temp.dir}/META-INF/services.xml" file="listner1.services.xml"/>
+ <copy toFile="${listner2.temp.dir}/META-INF/services.xml" file="listner2.services.xml"/>
+ <copy toFile="${publisher.temp.dir}/META-INF/services.xml" file="publisher.services.xml"/>
+
+ <jar destfile="build/ListnerService1.aar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**/**/*ListnerService1*" />
+ </fileset>
+ <fileset dir="${listner1.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="build/ListnerService2.aar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**/**/*ListnerService2*" />
+ </fileset>
+ <fileset dir="${listner2.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="build/PublisherService.aar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**/**/*PublisherService*" />
+ </fileset>
+ <fileset dir="${publisher.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="build/ListnerService1.aar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**/**/*ListnerService1*" />
+ </fileset>
+ <fileset dir="${listner1.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="build/EventingSample.jar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**"/>
+ </fileset>
+ </jar>
+
+ <copy todir="build">
+ <fileset dir=".">
+ <include name="*.sh"/>
+ <include name="*.bat"/>
+ </fileset>
+ </copy>
+ </target>
+
+</project>
\ No newline at end of file
Added: webservices/savan/trunk/java/modules/samples/eventing/listner1.services.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/listner1.services.xml?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/listner1.services.xml (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/listner1.services.xml Mon May 21 22:44:15 2007
@@ -0,0 +1,13 @@
+<service name="ListnerService1">
+
+ <parameter name="ServiceClass" locked="xsd:false">sample.eventing.ListnerService1</parameter>
+
+ <description>
+ The Listner Service 1 of the Axis2 Eventing sample.
+ </description>
+
+ <operation name="publish" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
+ </operation>
+
+</service>
\ No newline at end of file
Added: webservices/savan/trunk/java/modules/samples/eventing/listner2.services.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/listner2.services.xml?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/listner2.services.xml (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/listner2.services.xml Mon May 21 22:44:15 2007
@@ -0,0 +1,13 @@
+<service name="ListnerService2">
+
+ <parameter name="ServiceClass" locked="xsd:false">sample.eventing.ListnerService2</parameter>
+
+ <description>
+ The Listner Service 2 of the Axis2 Eventing sample.
+ </description>
+
+ <operation name="publish" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
+ </operation>
+
+</service>
\ No newline at end of file
Added: webservices/savan/trunk/java/modules/samples/eventing/publisher.services.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/publisher.services.xml?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/publisher.services.xml (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/publisher.services.xml Mon May 21 22:44:15 2007
@@ -0,0 +1,17 @@
+<service name="PublisherService">
+
+ <parameter name="ServiceClass" locked="xsd:false">sample.eventing.PublisherService</parameter>
+
+ <description>
+ The Publisher Service of the Axis2 Eventing sample.
+ </description>
+
+ <module ref="savan" />
+ <module ref="addressing" />
+
+ <operation name="dummyMethod" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
+ <actionMapping>uuid:DummyMethodAction</actionMapping>
+ </operation>
+
+</service>
\ No newline at end of file
Added: webservices/savan/trunk/java/modules/samples/eventing/readme.txt
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/readme.txt?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/readme.txt (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/readme.txt Mon May 21 22:44:15 2007
@@ -0,0 +1,19 @@
+Steps to build and run the Savan-Eventing sample
+------------------------------------------------
+
+To build
+--------
+
+1. Move to the sample folder.
+2. Create a subfolders 'build/lib'.
+3. Copy all the jars from a compatible Axis2 distribution to 'build/lib'.
+4. Copy the savan jar file to 'build/lib'.
+5. Run 'ant' to build the sample.
+
+
+To run
+------
+1. Start a Axis2 server.
+2. Deploy savan and addressing modules.
+3. Deploy the three services that were created in the 'build' folder.
+4. Run the 'samples.eventing.Client' class, you can pass the repository with a '-r' parameter and the server port with a '-p' parameter.
Added: webservices/savan/trunk/java/modules/samples/eventing/run.bat
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/run.bat?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/run.bat (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/run.bat Mon May 21 22:44:15 2007
@@ -0,0 +1,40 @@
+@echo off
+rem ---------------------------------------------------------------------------
+rem Start script for running the Eventing Sample Client
+rem
+rem ---------------------------------------------------------------------------
+
+rem store the current directory
+set CURRENT_DIR=%cd%
+
+rem check the AXIS2_HOME environment variable
+if not "%AXIS2_HOME%" == "" goto gotHome
+
+rem guess the home. Jump two directories up and take that as the home
+cd ..
+cd ..
+set AXIS2_HOME=%cd%
+
+echo using Axis Home %AXIS2_HOME%
+
+
+:gotHome
+if EXIST "%AXIS2_HOME%\lib\axis2*.jar" goto okHome
+echo The AXIS2_HOME environment variable seems not to point to the correct loaction!
+echo This environment variable is needed to run this program
+pause
+goto end
+
+:okHome
+cd %CURRENT_DIR%
+
+setlocal EnableDelayedExpansion
+rem loop through the libs and add them to the class path
+set AXIS2_CLASS_PATH=%AXIS2_HOME%
+FOR %%c in (%AXIS2_HOME%\lib\*.jar) DO set AXIS2_CLASS_PATH=!AXIS2_CLASS_PATH!;%%c
+
+set AXIS2_CLASS_PATH=%AXIS2_CLASS_PATH%;"%CURRENT_DIR%\EventingSample.jar"
+
+java -cp %AXIS2_CLASS_PATH% -Daxis2.repo=%AXIS2_HOME% sample.eventing.Client
+endlocal
+:end
\ No newline at end of file
Added: webservices/savan/trunk/java/modules/samples/eventing/run.sh
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/run.sh?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/run.sh (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/run.sh Mon May 21 22:44:15 2007
@@ -0,0 +1,11 @@
+#!/bin/sh
+export AXIS2_HOME=../..
+AXIS2_CLASSPATH=$AXIS2_CLASSPATH:SGCCalculator.jar
+for f in $AXIS2_HOME/lib/*.jar
+do
+ AXIS2_CLASSPATH=$AXIS2_CLASSPATH:$f
+done
+export AXIS2_CLASSPATH
+echo classpath: $AXIS2_CLASSPATH
+
+java -classpath $AXIS2_CLASSPATH -Daxis2.repo=$AXIS2_HOME sample.sgccalculator.CalcClient
Propchange: webservices/savan/trunk/java/modules/samples/eventing/run.sh
------------------------------------------------------------------------------
svn:executable = *
Added: webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/Client.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/Client.java?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/Client.java (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/Client.java Mon May 21 22:44:15 2007
@@ -0,0 +1,293 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+package sample.eventing;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+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;
+import org.apache.savan.eventing.client.SubscriptionStatus;
+
+public class Client {
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+
+ private final int MIN_OPTION = 1;
+ private final int MAX_OPTION = 9;
+
+ private final String SUBSCRIBER_1_ID = "subscriber1";
+ private final String SUBSCRIBER_2_ID = "subscriber2";
+
+ private ServiceClient serviceClient = null;
+ private Options options = null;
+ private EventingClient eventingClient = null;
+
+ private String toAddressPart = "/axis2/services/PublisherService";
+ private String listner1AddressPart = "/axis2/services/ListnerService1";
+ private String listner2AddressPart = "/axis2/services/ListnerService2";
+
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String dummyMethod = "dummyMethod";
+
+ private static String repo = null;
+ private static int port = 8080;
+ private static String serverIP = "127.0.0.1";
+
+ private static final String portParam = "-p";
+ private static final String repoParam = "-r";
+ private static final String helpParam = "-h";
+
+ public static void main (String[] args) throws Exception {
+
+ for (int i=0;i<args.length;i++) {
+ if (helpParam.equalsIgnoreCase(args[i])) {
+ displayHelp ();
+ System.exit(0);
+ }
+ }
+
+ String portStr = getParam(portParam,args);
+ if (portStr!=null) {
+ port = Integer.parseInt(portStr);
+ System.out.println("Server Port was set to:" + port);
+ }
+
+ String repoStr = getParam(repoParam,args);
+ if (repoStr!=null) {
+ repo = repoStr;
+ System.out.println("Client Repository was set to:" + repo);
+ }
+
+ Client c = new Client ();
+ c.run ();
+ }
+
+ private static void displayHelp () {
+ System.out.println("Help page for the Eventing Client");
+ System.out.println("---------------------------------");
+ System.out.println("Set the client reposiory using the parameter -r");
+ System.out.println("Set the server port using the parameter -p");
+ }
+
+ /**
+ * This will check the given parameter in the array and will return, if available
+ *
+ * @param param
+ * @param args
+ * @return
+ */
+ private static String getParam(String param, String[] args) {
+ if (param == null || "".equals(param)) {
+ return null;
+ }
+
+ for (int i = 0; i < args.length; i = i + 2) {
+ String arg = args[i];
+ if (param.equalsIgnoreCase(arg) && (args.length >= (i + 1))) {
+ return args[i + 1];
+ }
+ }
+ return null;
+ }
+
+ public void run () throws Exception {
+
+ System.out.println("\n");
+ System.out.println("Welcome to Axis2 Eventing Sample");
+ System.out.println("================================\n");
+
+ boolean validOptionSelected = false;
+ int selectedOption = -1;
+ while (!validOptionSelected) {
+ displayMenu();
+ selectedOption = getIntInput();
+ if (selectedOption>=MIN_OPTION && selectedOption<=MAX_OPTION)
+ validOptionSelected = true;
+ else
+ System.out.println("\nInvalid Option \n\n");
+ }
+
+ initClient ();
+ performAction (selectedOption);
+
+ //TODO publish
+
+ System.out.println("Press enter to initialize the publisher service.");
+ reader.readLine();
+
+ options.setAction("uuid:DummyMethodAction");
+ serviceClient.fireAndForget(getDummyMethodRequestElement ());
+
+ while (true) {
+
+ validOptionSelected = false;
+ selectedOption = -1;
+ while (!validOptionSelected) {
+ displayMenu();
+ selectedOption = getIntInput();
+ if (selectedOption>=MIN_OPTION && selectedOption<=MAX_OPTION)
+ validOptionSelected = true;
+ else
+ System.out.println("\nInvalid Option \n\n");
+ }
+
+ performAction (selectedOption);
+
+ }
+ }
+
+ private void displayMenu () {
+ System.out.println("Press 1 to subscribe Listner Service 1");
+ System.out.println("Press 2 to subscribe Listner Service 2");
+ System.out.println("Press 3 to subscribe both listner services");
+ System.out.println("Press 4 to unsubscribe Listner Service 1");
+ System.out.println("Press 5 to unsubscribe Listner Service 2");
+ System.out.println("Press 6 to unsubscribe both listner services");
+ System.out.println("Press 7 to to get the status of the subscription to Service 1");
+ System.out.println("Press 8 to to get the status of the subscription to Service 2");
+ System.out.println("Press 9 to Exit");
+ }
+
+ private int getIntInput () throws IOException {
+ String option = reader.readLine();
+ try {
+ return Integer.parseInt(option);
+ } catch (NumberFormatException e) {
+ //invalid option
+ return -1;
+ }
+ }
+
+ private void initClient () throws AxisFault {
+
+ String CLIENT_REPO = null;
+ String AXIS2_XML = null;
+
+ if (repo!=null) {
+ CLIENT_REPO = repo;
+ AXIS2_XML = repo + File.separator + "axis2.xml";
+ } else {
+// throw new AxisFault ("Please specify the client repository as a program argument.Use '-h' for help.");
+ }
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO,null);
+ serviceClient = new ServiceClient (configContext,null); //TODO give a repo
+
+ options = new Options ();
+ serviceClient.setOptions(options);
+ serviceClient.engageModule(new QName ("addressing"));
+
+ eventingClient = new EventingClient (serviceClient);
+
+ String toAddress = "http://" + serverIP + ":" + port + toAddressPart;
+ options.setTo(new EndpointReference (toAddress));
+ }
+
+ private void performAction (int action) throws Exception {
+
+ switch (action) {
+ case 1:
+ doSubscribe(SUBSCRIBER_1_ID);
+ break;
+ case 2:
+ doSubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 3:
+ doSubscribe(SUBSCRIBER_1_ID);
+ doSubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 4:
+ doUnsubscribe(SUBSCRIBER_1_ID);
+ break;
+ case 5:
+ doUnsubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 6:
+ doUnsubscribe(SUBSCRIBER_1_ID);
+ doUnsubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 7:
+ doGetStatus(SUBSCRIBER_1_ID);
+ break;
+ case 8:
+ doGetStatus(SUBSCRIBER_2_ID);
+ break;
+ case 9:
+ System.exit(0);
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void doSubscribe (String ID) throws Exception {
+ EventingClientBean bean = new EventingClientBean ();
+
+ String subscribingAddress = null;
+ if (SUBSCRIBER_1_ID.equals(ID)) {
+ subscribingAddress = "http://" + serverIP + ":" + port + listner1AddressPart;
+ } else if (SUBSCRIBER_2_ID.equals(ID)) {
+ subscribingAddress = "http://" + serverIP + ":" + port + listner2AddressPart;
+ }
+
+ bean.setDeliveryEPR(new EndpointReference (subscribingAddress));
+
+ //uncomment following to set an expiration time of 10 minutes.
+// Date date = new Date ();
+// date.setMinutes(date.getMinutes()+10);
+// bean.setExpirationTime(date);
+
+ eventingClient.subscribe(bean,ID);
+ Thread.sleep(1000); //TODO remove if not sequired
+ }
+
+ private void doUnsubscribe (String ID) throws Exception {
+ eventingClient.unsubscribe(ID);
+ Thread.sleep(1000); //TODO remove if not sequired
+ }
+
+ private void doGetStatus (String ID) throws Exception {
+ SubscriptionStatus status = eventingClient.getSubscriptionStatus(ID);
+ Thread.sleep(1000); //TODO remove if not sequired
+
+ String statusValue = status.getExpirationValue();
+ System.out.println("Status of the subscriber '" + ID +"' is" + statusValue);
+ }
+
+ private OMElement getDummyMethodRequestElement() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ return fac.createOMElement(dummyMethod, namespace);
+ }
+
+}
Added: webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService1.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService1.java?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService1.java (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService1.java Mon May 21 22:44:15 2007
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+package sample.eventing;
+
+import org.apache.axiom.om.OMElement;
+
+public class ListnerService1 {
+
+ String name = "ListnerService1";
+
+ public void publish(OMElement param) throws Exception {
+ System.out.println("\n");
+ System.out.println("'" + name + "' got a new publication...");
+ System.out.println(param);
+ System.out.println("\n");
+ }
+
+}
Added: webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService2.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService2.java?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService2.java (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/ListnerService2.java Mon May 21 22:44:15 2007
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+package sample.eventing;
+
+import org.apache.axiom.om.OMElement;
+
+public class ListnerService2 {
+
+ String name = "ListnerService2";
+
+ public void publish(OMElement param) throws Exception {
+ System.out.println("\n");
+ System.out.println("'" + name + "' got a new publication...");
+ System.out.println(param);
+ System.out.println("\n");
+ }
+
+}
Added: webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/PublisherService.java
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/PublisherService.java?view=auto&rev=540427
==============================================================================
--- webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/PublisherService.java (added)
+++ webservices/savan/trunk/java/modules/samples/eventing/src/sample/eventing/PublisherService.java Mon May 21 22:44:15 2007
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+package sample.eventing;
+
+import java.net.URI;
+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.context.ServiceContext;
+import org.apache.savan.publication.client.PublicationClient;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.util.CommonUtil;
+
+public class PublisherService {
+
+ ServiceContext serviceContext = null;
+
+ public void init(ServiceContext serviceContext) throws AxisFault {
+ System.out.println("Eventing Service INIT called");
+ this.serviceContext = serviceContext;
+
+ PublisherThread thread = new PublisherThread ();
+ thread.start();
+ }
+
+ public void dummyMethod(OMElement param) throws Exception {
+ System.out.println("Eventing Service dummy method called");
+ }
+
+ private class PublisherThread extends Thread {
+
+ String Publication = "Publication";
+ String publicationNamespaceValue = "http://tempuri/publication/";
+ Random r = new Random ();
+
+ public void run () {
+ try {
+ while (true) {
+
+ Thread.sleep(5000);
+
+ //publishing
+ System.out.println("Publishing next publication...");
+
+ SubscriberStore store = CommonUtil.getSubscriberStore(serviceContext.getAxisService());
+ if (store==null)
+ throw new Exception ("Cant find the Savan subscriber store");
+
+ OMElement data = getNextPublicationData ();
+
+ PublicationClient publicationClient = new PublicationClient (serviceContext.getConfigurationContext());
+ publicationClient.sendPublication(data,serviceContext.getAxisService(),null);
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public OMElement getNextPublicationData () {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = factory.createOMNamespace(publicationNamespaceValue,"ns1");
+ OMElement publicationElement = factory.createOMElement(Publication,namespace);
+
+ int value = r.nextInt();
+ publicationElement.setText(Integer.toString(value));
+
+ OMElement data = factory.createOMElement("publish",namespace);
+ data.addChild(publicationElement);
+
+
+ return data;
+ }
+ }
+}
Modified: webservices/savan/trunk/java/pom.xml
URL: http://svn.apache.org/viewvc/webservices/savan/trunk/java/pom.xml?view=diff&rev=540427&r1=540426&r2=540427
==============================================================================
--- webservices/savan/trunk/java/pom.xml (original)
+++ webservices/savan/trunk/java/pom.xml Mon May 21 22:44:15 2007
@@ -3,10 +3,10 @@
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">
- <groupId>org.apache.savan</groupId>
+ <groupId>org.apache.ws.savan</groupId>
<modelVersion>4.0.0</modelVersion>
- <artifactId>savan</artifactId>
- <packaging>jar</packaging>
+ <artifactId>savan-parent</artifactId>
+ <packaging>pom</packaging>
<version>SNAPSHOT</version>
<name>Apache Savan</name>
@@ -103,6 +103,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>2.2</version>
</plugin>
+ <!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
@@ -145,6 +146,7 @@
</execution>
</executions>
</plugin>
+ -->
</plugins>
</build>
@@ -224,6 +226,14 @@
</site>
</distributionManagement>
+
+ <modules>
+ <module>modules/core</module>
+ <module>modules/mar</module>
+ <!-- <module>modules/samples</module> -->
+<!-- <module>modules/eventing-client</module>
+ <module>modules/distribution</module>-->
+ </modules>
<properties>
<axis2.version>1.2</axis2.version>