You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2006/06/08 15:38:31 UTC
svn commit: r412749 - in /webservices/axis2/trunk/java/modules/samples: ./
resources/eventing/ script/eventing/ src/sample/eventing/
Author: chamikara
Date: Thu Jun 8 06:38:30 2006
New Revision: 412749
URL: http://svn.apache.org/viewvc?rev=412749&view=rev
Log:
Added the Eventing sample.
To show the eventing capability of Savan.
(Not fully developed yet)
Added:
webservices/axis2/trunk/java/modules/samples/resources/eventing/
webservices/axis2/trunk/java/modules/samples/resources/eventing/listner1.services.xml
webservices/axis2/trunk/java/modules/samples/resources/eventing/listner2.services.xml
webservices/axis2/trunk/java/modules/samples/resources/eventing/publisher.services.xml
webservices/axis2/trunk/java/modules/samples/script/eventing/
webservices/axis2/trunk/java/modules/samples/script/eventing/run.bat
webservices/axis2/trunk/java/modules/samples/script/eventing/run.sh
webservices/axis2/trunk/java/modules/samples/src/sample/eventing/
webservices/axis2/trunk/java/modules/samples/src/sample/eventing/Client.java
webservices/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService1.java
webservices/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService2.java
webservices/axis2/trunk/java/modules/samples/src/sample/eventing/PublisherService.java
Modified:
webservices/axis2/trunk/java/modules/samples/maven.xml
webservices/axis2/trunk/java/modules/samples/project.xml
Modified: webservices/axis2/trunk/java/modules/samples/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/maven.xml?rev=412749&r1=412748&r2=412749&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/maven.xml Thu Jun 8 06:38:30 2006
@@ -40,7 +40,8 @@
<attainGoal name="mtomSample"/>
<attainGoal name="groovy"/>
<attainGoal name="securitySample"/>
- <attainGoal name="sgccalculator"/>
+ <attainGoal name="sgccalculator"/>
+ <attainGoal name="eventing"/>
</goal>
<!-- ================================================================ -->
@@ -359,6 +360,76 @@
<copy toDir="${samples.dir}/SGCCalculator"
file="script/SGCCalculator/run.sh"/>
</goal>
+
+ <!-- ================================================================ -->
+ <!--- Eventing Sample -->
+ <!-- ================================================================ -->
+ <goal name="eventing">
+
+ <property name="eventing.temp.dir" value="${samples.dir}/eventing/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" />
+
+ <copy toFile="${listner1.temp.dir}/META-INF/services.xml" file="resources/eventing/listner1.services.xml"/>
+ <copy toFile="${listner2.temp.dir}/META-INF/services.xml" file="resources/eventing/listner2.services.xml"/>
+ <copy toFile="${publisher.temp.dir}/META-INF/services.xml" file="resources/eventing/publisher.services.xml"/>
+
+ <jar destfile="${samples.dir}/eventing/ListnerService1.aar">
+ <fileset dir="target/classes">
+ <include name="sample/eventing/**/**/*ListnerService1*" />
+ </fileset>
+ <fileset dir="${listner1.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="${samples.dir}/eventing/ListnerService2.aar">
+ <fileset dir="target/classes">
+ <include name="sample/eventing/**/**/*ListnerService2*" />
+ </fileset>
+ <fileset dir="${listner2.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="${samples.dir}/eventing/PublisherService.aar">
+ <fileset dir="target/classes">
+ <include name="sample/eventing/**/**/*PublisherService*" />
+ </fileset>
+ <fileset dir="${publisher.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="${samples.dir}/eventing/ListnerService1.aar">
+ <fileset dir="target/classes">
+ <include name="sample/eventing/**/**/*ListnerService1*" />
+ </fileset>
+ <fileset dir="${listner1.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="${samples.dir}/eventing/EventingSample.jar">
+ <fileset dir="target/classes">
+ <include name="sample/eventing/**"/>
+ </fileset>
+ </jar>
+
+ <ant:copy todir="${samples.dir}/eventing">
+ <ant:fileset dir="script/eventing"/>
+ </ant:copy>
+
+ </goal>
+
<preGoal name="itest:compile">
<u:file var="file" name="${maven.itest.src}"/>
@@ -366,4 +437,5 @@
<j:expr value="${context.setVariable('maven.itest.skip', 'true')}"/>
</j:if>
</preGoal>
+
</project>
Modified: webservices/axis2/trunk/java/modules/samples/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/project.xml?rev=412749&r1=412748&r2=412749&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/project.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/project.xml Thu Jun 8 06:38:30 2006
@@ -52,6 +52,11 @@
<artifactId>axis2-common</artifactId>
<version>${pom.currentVersion}</version>
</dependency>
+ <dependency>
+ <groupId>axis2</groupId>
+ <artifactId>axis2-savan</artifactId>
+ <version>${pom.currentVersion}</version>
+ </dependency>
<!-- external JARs -->
<dependency>
<groupId>commons-logging</groupId>
Added: webservices/axis2/trunk/java/modules/samples/resources/eventing/listner1.services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/resources/eventing/listner1.services.xml?rev=412749&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/resources/eventing/listner1.services.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/resources/eventing/listner1.services.xml Thu Jun 8 06:38:30 2006
@@ -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/axis2/trunk/java/modules/samples/resources/eventing/listner2.services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/resources/eventing/listner2.services.xml?rev=412749&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/resources/eventing/listner2.services.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/resources/eventing/listner2.services.xml Thu Jun 8 06:38:30 2006
@@ -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/axis2/trunk/java/modules/samples/resources/eventing/publisher.services.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/resources/eventing/publisher.services.xml?rev=412749&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/resources/eventing/publisher.services.xml (added)
+++ webservices/axis2/trunk/java/modules/samples/resources/eventing/publisher.services.xml Thu Jun 8 06:38:30 2006
@@ -0,0 +1,15 @@
+<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" />
+
+ <operation name="dummyMethod" 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/axis2/trunk/java/modules/samples/script/eventing/run.bat
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/script/eventing/run.bat?rev=412749&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/script/eventing/run.bat (added)
+++ webservices/axis2/trunk/java/modules/samples/script/eventing/run.bat Thu Jun 8 06:38:30 2006
@@ -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/axis2/trunk/java/modules/samples/script/eventing/run.sh
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/script/eventing/run.sh?rev=412749&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/script/eventing/run.sh (added)
+++ webservices/axis2/trunk/java/modules/samples/script/eventing/run.sh Thu Jun 8 06:38:30 2006
@@ -0,0 +1,12 @@
+#!/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
Added: webservices/axis2/trunk/java/modules/samples/src/sample/eventing/Client.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/src/sample/eventing/Client.java?rev=412749&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/eventing/Client.java (added)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/eventing/Client.java Thu Jun 8 06:38:30 2006
@@ -0,0 +1,205 @@
+/*
+ * 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.IOException;
+import java.io.InputStreamReader;
+
+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;
+
+public class Client {
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
+
+ private final int MIN_OPTION = 1;
+ private final int MAX_OPTION = 6;
+
+ 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 toAddress = "http://localhost:8080/axis2/services/PublisherService";
+ private String listner1Address = "http://localhost:8080/axis2/services/ListnerService1";
+ private String listner2Address = "http://localhost:8080/axis2/services/ListnerService2";
+
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String dummyMethod = "dummyMethod";
+
+ public static void main (String[] args) throws Exception {
+ Client c = new Client ();
+ c.run ();
+ }
+
+ 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 Exit");
+ }
+
+ private int getIntInput () throws IOException {
+ String option = reader.readLine();
+ try {
+ int param = Integer.parseInt(option);
+ return param;
+ } catch (NumberFormatException e) {
+ //invalid option
+ return -1;
+ }
+ }
+
+ private void initClient () throws AxisFault {
+ String CLIENT_REPO_PATH = "E:\\temp\\REPO";
+ String AXIS2_XML = "E:\\temp\\REPO\\axis2.xml";
+
+ ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,AXIS2_XML);
+ serviceClient = new ServiceClient (configContext,null); //TODO give a repo
+
+ options = new Options ();
+ serviceClient.setOptions(options);
+ serviceClient.engageModule(new QName ("addressing"));
+
+ eventingClient = new EventingClient (serviceClient);
+ 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:
+ 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 = listner1Address;
+ else if (SUBSCRIBER_2_ID.equals(ID))
+ subscribingAddress = listner2Address;
+
+ bean.setDeliveryEPR(new EndpointReference (subscribingAddress));
+
+ 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 OMElement getDummyMethodRequestElement() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
+ OMElement dummyMethodElem = fac.createOMElement(dummyMethod, namespace);
+
+ return dummyMethodElem;
+ }
+}
Added: webservices/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService1.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService1.java?rev=412749&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService1.java (added)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService1.java Thu Jun 8 06:38:30 2006
@@ -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/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService2.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService2.java?rev=412749&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService2.java (added)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/eventing/ListnerService2.java Thu Jun 8 06:38:30 2006
@@ -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/axis2/trunk/java/modules/samples/src/sample/eventing/PublisherService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/samples/src/sample/eventing/PublisherService.java?rev=412749&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/eventing/PublisherService.java (added)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/eventing/PublisherService.java Thu Jun 8 06:38:30 2006
@@ -0,0 +1,97 @@
+/*
+ * 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.util.Random;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPFactory;
+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.ServiceContext;
+
+public class PublisherService {
+
+ ConfigurationContext configurationContext = null;
+
+ public void init(ServiceContext serviceContext) throws AxisFault {
+ System.out.println("Eventing Service INIT called");
+ configurationContext = serviceContext.getConfigurationContext();
+
+ 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 {
+
+ ServiceClient sc = new ServiceClient (configurationContext,null);
+ Options options = new Options ();
+ sc.setOptions(options);
+
+ //if already engaged, axis2 will neglect this engagement.
+ sc.engageModule( new QName("savan"));
+
+ options.setTo(new EndpointReference ("http://dummyTargetEPR/"));
+ options.setAction("DummyAction");
+
+ while (true) {
+
+ Thread.sleep(5000);
+
+ //publishing
+ System.out.println("Publishing next publication...");
+ sc.fireAndForget(getNextPublicationEnvelope ());
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public OMElement getNextPublicationEnvelope () {
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ OMNamespace namespace = factory.createOMNamespace(publicationNamespaceValue,"ns1");
+ OMElement publicationElement = factory.createOMElement(Publication,namespace);
+
+ int value = r.nextInt();
+ publicationElement.setText(new Integer(value).toString());
+
+ OMElement publishMethod = factory.createOMElement("publish",namespace);
+ publishMethod.addChild(publicationElement);
+
+ return publishMethod;
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org