axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r428956 - in /webservices/axis2/trunk/java/modules/samples/src/sample/eventing: Client.java PublisherService.java
Date Sat, 05 Aug 2006 04:31:17 GMT
Author: chamikara
Date: Fri Aug  4 21:31:16 2006
New Revision: 428956

URL: http://svn.apache.org/viewvc?rev=428956&view=rev
Log:
Updated the Client to support the getStatus message.
Some corrections to the Service Impl.

Modified:
    webservices/axis2/trunk/java/modules/samples/src/sample/eventing/Client.java
    webservices/axis2/trunk/java/modules/samples/src/sample/eventing/PublisherService.java

Modified: 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=428956&r1=428955&r2=428956&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/eventing/Client.java (original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/eventing/Client.java Fri Aug 
4 21:31:16 2006
@@ -34,16 +34,16 @@
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.axis2.databinding.types.Duration;
 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 = 6;
+    private final int MAX_OPTION = 9;
     
     private final String SUBSCRIBER_1_ID = "subscriber1";
     private final String SUBSCRIBER_2_ID = "subscriber2";
@@ -164,7 +164,6 @@
 			performAction (selectedOption);
 			
 		}
-		
 	}
 	
 	private void displayMenu () {
@@ -174,7 +173,9 @@
 		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");
+		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 {
@@ -197,7 +198,7 @@
 			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.");
+//			throw new AxisFault ("Please specify the client repository as a program argument.Use
'-h' for help.");
 		}
 		
 		ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO,AXIS2_XML);
@@ -237,6 +238,12 @@
 			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:
@@ -257,10 +264,12 @@
 		}
 	
 		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);
 		
-		Date date = new Date ();
-		date.setMinutes(date.getMinutes()+1);
-		bean.setExpirationTime(date);
 		eventingClient.subscribe(bean,ID);
 		Thread.sleep(1000);   //TODO remove if not sequired
 	}
@@ -270,6 +279,14 @@
 		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");
@@ -277,4 +294,5 @@
 
 		return dummyMethodElem;
 	}
+	
 }

Modified: 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=428956&r1=428955&r2=428956&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/src/sample/eventing/PublisherService.java
(original)
+++ webservices/axis2/trunk/java/modules/samples/src/sample/eventing/PublisherService.java
Fri Aug  4 21:31:16 2006
@@ -18,26 +18,24 @@
 
 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.SOAPEnvelope;
 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;
+import org.apache.savan.publication.client.PublicationClient;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.util.CommonUtil;
 
 public class PublisherService {
   
-	ConfigurationContext configurationContext = null;
+	ServiceContext serviceContext = null;
 	
 	public void init(ServiceContext serviceContext) throws AxisFault {
 		System.out.println("Eventing Service INIT called");
-		configurationContext = serviceContext.getConfigurationContext();
+		this.serviceContext = serviceContext;
 		
 		PublisherThread thread = new PublisherThread ();
 		thread.start();
@@ -55,32 +53,28 @@
 		
 		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 ());
+					
+					SubscriberStore store = (SubscriberStore) CommonUtil.getSubscriberStore(serviceContext.getAxisService());
+					if (store==null)
+						throw new Exception ("Cant find the Savan subscriber store");
+					
+					SOAPEnvelope envelope = getNextPublicationEnvelope ();
+					PublicationClient.sendPublication(envelope,serviceContext.getConfigurationContext(),store);
 				}
+				
 			} catch (Exception e) {
 				// TODO Auto-generated catch block
 				e.printStackTrace();
 			}
 		}
 		
-		public OMElement getNextPublicationEnvelope () {
+		public SOAPEnvelope getNextPublicationEnvelope () {
 			SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
 			OMNamespace namespace = factory.createOMNamespace(publicationNamespaceValue,"ns1");
 			OMElement publicationElement = factory.createOMElement(Publication,namespace);
@@ -91,7 +85,10 @@
 			OMElement publishMethod = factory.createOMElement("publish",namespace);
 			publishMethod.addChild(publicationElement);
 			
-			return publishMethod;
+			SOAPEnvelope envelope = factory.getDefaultEnvelope();
+			envelope.getBody().addChild(publishMethod);
+			
+			return envelope;
 		}
 	}
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message