* Scope the publisher service so that it starts up at server startup

* Rejigger sample Client so events go back to it for ListenerService1; need to fix this
  so namespaces are right for both listeners...


diff --git a/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java b/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java
index 5672a89..dc3385e 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java
@@ -53,7 +53,8 @@
     private class PublisherThread extends Thread {

 

         String Publication = "Publication";

-        String publicationNamespaceValue = "http://tempuri/publication/";

+//        String publicationNamespaceValue = "http://tempuri/publication/";

+        String publicationNamespaceValue = "http://eventing.sample";

         Random r = new Random();

 

         public void run() {

@@ -65,14 +66,13 @@
 

                     SubscriberStore store =

                             CommonUtil.getSubscriberStore(serviceContext.getAxisService());

-                    if (store == null)

-                        throw new Exception("Cant find the Savan subscriber store");

-

-                    OMElement envelope = getNextPublicationEvent();

-                    PublicationClient client =

-                            new PublicationClient(serviceContext.getConfigurationContext());

-                    client.sendPublication(envelope, serviceContext.getAxisService(), null);

-                    Thread.sleep(10000);

+                    if (store != null) {

+                        OMElement envelope = getNextPublicationEvent();

+                        PublicationClient client =

+                                new PublicationClient(serviceContext.getConfigurationContext());

+                        client.sendPublication(envelope, serviceContext.getAxisService(), null);

+                        Thread.sleep(10000);

+                    }

                 }

 

             } catch (Exception e) {

diff --git a/modules/samples/eventing/publisher.services.xml b/modules/samples/eventing/publisher.services.xml
index 39d9495..a892b92 100644
--- a/modules/samples/eventing/publisher.services.xml
+++ b/modules/samples/eventing/publisher.services.xml
@@ -1,4 +1,4 @@
-<service name="PublisherService">

+<service name="PublisherService" scope="application">

 

   <parameter name="ServiceClass" locked="xsd:false">sample.eventing.PublisherService</parameter>

 

diff --git a/modules/samples/eventing/src/sample/eventing/Client.java b/modules/samples/eventing/src/sample/eventing/Client.java
index 936d771..d0e7545 100644
--- a/modules/samples/eventing/src/sample/eventing/Client.java
+++ b/modules/samples/eventing/src/sample/eventing/Client.java
@@ -17,6 +17,10 @@
 package sample.eventing;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.axis2.engine.AxisServer;
+import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.client.ServiceClient;
@@ -48,9 +52,6 @@
     private String listener1AddressPart = "/axis2/services/ListenerService1";
     private String listener2AddressPart = "/axis2/services/ListenerService2";
 
-//    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";
@@ -91,6 +92,20 @@
         System.out.println("Set the server port using the parameter -p");
     }
 
+    static void foo() throws Exception {
+        ConfigurationContext ctx = ConfigurationContextFactory.createDefaultConfigurationContext();
+        SimpleHTTPServer server = new SimpleHTTPServer(ctx, 7071);
+        AxisConfiguration axisConfig = ctx.getAxisConfiguration();
+
+//        AxisService service = new AxisService("ListenerService1");
+//        svc.addParameter("ServiceClass", ListenerService1.class.getName());
+
+        AxisService service = AxisService.createService(ListenerService1.class.getName(),
+                                                        axisConfig);
+        axisConfig.addService(service);
+        server.start();
+    }
+
     /**
      * This will check the given parameter in the array and will return, if available
      *
@@ -118,6 +133,8 @@
         System.out.println("Welcome to Axis2 Eventing Sample");
         System.out.println("================================\n");
 
+        foo();
+        
         boolean validOptionSelected = false;
         int selectedOption = -1;
         while (!validOptionSelected) {
@@ -244,7 +261,7 @@
 
         String subscribingAddress = null;
         if (SUBSCRIBER_1_ID.equals(ID)) {
-            subscribingAddress = "http://" + serverIP + ":" + port + listener1AddressPart;
+            subscribingAddress = "http://" + serverIP + ":" + 7070 + listener1AddressPart;
         } else if (SUBSCRIBER_2_ID.equals(ID)) {
             subscribingAddress = "http://" + serverIP + ":" + port + listener2AddressPart;
         }
diff --git a/modules/samples/eventing/src/sample/eventing/PublisherService.java b/modules/samples/eventing/src/sample/eventing/PublisherService.java
index 0f02141..a845c97 100644
--- a/modules/samples/eventing/src/sample/eventing/PublisherService.java
+++ b/modules/samples/eventing/src/sample/eventing/PublisherService.java
@@ -41,13 +41,14 @@
     }
 
     public void dummyMethod(OMElement param) throws Exception {
-        System.out.println("Eventing Service dummy method called");
+        System.out.println("Eventing Service dummy method called, woo!");
     }
 
     private class PublisherThread extends Thread {
 
         String Publication = "Publication";
-        String publicationNamespaceValue = "http://tempuri/publication/";
+//        String publicationNamespaceValue = "http://tempuri/publication/";
+        String publicationNamespaceValue = "http://eventing.sample";
         Random r = new Random();
 
         public void run() {
@@ -57,18 +58,17 @@
                     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);
+                    if (store != null) {
+                        System.out.println("Publishing next publication...");
+                        OMElement data = getNextPublicationData();
+                        PublicationClient publicationClient =
+                                new PublicationClient(serviceContext.getConfigurationContext());
+                        publicationClient.sendPublication(data, serviceContext.getAxisService(),
+                                                          null);
+                    }
                 }
             } catch (Exception e) {
                 // TODO Auto-generated catch block