axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r413845 - in /webservices/axis2/trunk/java/modules/savan: ./ src/org/apache/savan/ src/org/apache/savan/eventing/ src/org/apache/savan/filters/ src/org/apache/savan/handlers/ src/org/apache/savan/publication/ src/org/apache/savan/subscriber...
Date Tue, 13 Jun 2006 09:47:27 GMT
Author: chamikara
Date: Tue Jun 13 02:47:25 2006
New Revision: 413845

URL: http://svn.apache.org/viewvc?rev=413845&view=rev
Log:
Did changes to the filter logic. New interface 'Filter' that defines the generic methods.
Currently has a one implementation XPathBasedFilter.

Changed the processers to work with the new filter logic.
Added a dependency for Jaxen.

Added:
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/Filter.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/FilterFactory.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/XPathBasedFilter.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationReport.java
    webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/XPathBasedFilterTest.java
Removed:
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/Filter.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationErrorReport.java
Modified:
    webservices/axis2/trunk/java/modules/savan/project.xml
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanConstants.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingConstants.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriber.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriptionProcessor.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanOutHandler.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationProcessor.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/CompositeSubscriber.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/LeafSubscriber.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/Subscriber.java
    webservices/axis2/trunk/java/modules/savan/test-resources/eventing-subscription.xml
    webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/CompositeSubscriberTest.java
    webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/ConpositeSubscriberTest.java
    webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java

Modified: webservices/axis2/trunk/java/modules/savan/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/project.xml?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/project.xml (original)
+++ webservices/axis2/trunk/java/modules/savan/project.xml Tue Jun 13 02:47:25 2006
@@ -49,6 +49,16 @@
                 <module>true</module>
             </properties>
         </dependency>
+        
+        <dependency>
+            <groupId>jaxen</groupId>
+            <artifactId>jaxen</artifactId>
+            <version>${jaxen.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+            <url>http://www.ibiblio.org/maven/jaxen/jars/</url>
+        </dependency>
 
         <dependency>
             <groupId>axis2</groupId>

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanConstants.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanConstants.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanConstants.java Tue
Jun 13 02:47:25 2006
@@ -42,6 +42,10 @@
 		int GET_STATUS_RESPONSE_MESSAGE = 8;
 	}
 	
+	interface FilterDialects {
+		String XPath = "http://www.w3.org/TR/1999/REC-xpath-19991116";
+	}
+	
 	String SUBSCRIBER_TABLE = "SUBSCRIBER_TABLE";
 	
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingConstants.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingConstants.java
Tue Jun 13 02:47:25 2006
@@ -17,12 +17,14 @@
 
 package org.apache.savan.eventing;
 
+import org.apache.savan.SavanConstants;
+
 public interface EventingConstants {
 
 	String EVENTING_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/08/eventing";
 	String EVENTING_PREFIX = "wse";
 	String DEFAULT_DELIVERY_MODE = "http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push";
-	String DEFAULT_FILTER_DIALECT = "http://www.w3.org/TR/1999/REC-xpath-19991116";
+	String DEFAULT_FILTER_DIALECT = SavanConstants.FilterDialects.XPath;
 	
 	interface TransferedProperties {
 		String SUBSCRIBER_UUID = "SAVAN_EVENTING_SUBSCRIBER_UUID";

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriber.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriber.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriber.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriber.java
Tue Jun 13 02:47:25 2006
@@ -33,8 +33,6 @@
 	
 	private Delivery delivery;
 	
-	private Filter filter;
-	
 	public Delivery getDelivery() {
 		return delivery;
 	}
@@ -43,10 +41,6 @@
 		return endToEPr;
 	}
 
-	public Filter getFilter() {
-		return filter;
-	}
-
 	public void setDelivery(Delivery delivery) {
 		this.delivery = delivery;
 	}
@@ -54,33 +48,26 @@
 	public void setEndToEPr(EndpointReference errorReportingEPR) {
 		this.endToEPr = errorReportingEPR;
 	}
-
-	public void setFilter(Filter filter) {
-		this.filter = filter;
-	}
 	
-	public void doProtocolSpecificNotification(SavanMessageContext notificationMessage) throws
SavanException {
+	public void doProtocolSpecificPublication(SavanMessageContext publication) throws SavanException
{
 		
 		EndpointReference deliveryEPR  = delivery.getDeliveryEPR();
 		
 		try {
 			ServiceClient sc = new ServiceClient (null,null);
 			
-			Options options = notificationMessage.getMessageContext().getOptions();
+			Options options = publication.getMessageContext().getOptions();
 			if (options==null) {
 				options = new Options ();
 			}
 			
 			sc.setOptions(options);
-			
 			options.setTo(deliveryEPR);
-			
 			MessageContext mc = new MessageContext ();
-			mc.setEnvelope(notificationMessage.getEnvelope());
+			mc.setEnvelope(publication.getEnvelope());
 			OperationClient client = sc.createClient(ServiceClient.ANON_OUT_ONLY_OP);
 			client.addMessageContext(mc);
 			client.execute(true);
-			
 		} catch (AxisFault e) {
 			throw new SavanException (e);
 		}

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriptionProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriptionProcessor.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriptionProcessor.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingSubscriptionProcessor.java
Tue Jun 13 02:47:25 2006
@@ -35,6 +35,8 @@
 import org.apache.axis2.util.UUIDGenerator;
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.filters.FilterFactory;
 import org.apache.savan.subscribers.Subscriber;
 import org.apache.savan.subscription.ExpirationBean;
 import org.apache.savan.subscription.SubscriptionProcessor;
@@ -134,20 +136,18 @@
 		
 		OMElement filterElement = subscribeElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Filter));
 		if (filterElement!=null) {
-			Filter filter = new Filter ();
-			
 			OMNode filterNode = filterElement.getFirstOMChild();
-			filter.setFilter(filterNode);
-			
 			OMAttribute dialectAttr = filterElement.getAttribute(new QName (EventingConstants.ElementNames.Dialect));
-			
-			if (dialectAttr!=null) {
-				String dilect = dialectAttr.getAttributeValue().trim();
-				filter.setFilterType(dilect);
+			Filter filter = null;
+			if (dialectAttr==null) {
+				filter = FilterFactory.getFilter(EventingConstants.DEFAULT_FILTER_DIALECT);
 			} else {
-				//setting the default finter dialect.
-				filter.setFilterType(EventingConstants.DEFAULT_FILTER_DIALECT);
+				filter = FilterFactory.getFilter(dialectAttr.getAttributeValue());
 			}
+			if (filter==null)
+				throw new SavanException ("Cant find a suitable message filter");
+			
+			filter.setUp (filterNode);
 			
 			subscriber.setFilter(filter);
 		}

Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/Filter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/Filter.java?rev=413845&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/Filter.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/Filter.java Tue
Jun 13 02:47:25 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright  1999-2004 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 org.apache.savan.filters;
+
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.savan.SavanException;
+
+public abstract class Filter {
+	public abstract boolean checkEnvelopeCompliance (SOAPEnvelope envelope) throws SavanException;
+	public abstract void setUp (OMNode element);
+}

Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/FilterFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/FilterFactory.java?rev=413845&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/FilterFactory.java
(added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/FilterFactory.java
Tue Jun 13 02:47:25 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright  1999-2004 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 org.apache.savan.filters;
+
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+
+public class FilterFactory {
+
+	public static Filter getFilter (String type) throws SavanException {
+		if (SavanConstants.FilterDialects.XPath.equals(type))
+			return new XPathBasedFilter ();
+		else
+			return null;
+	}
+}

Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/XPathBasedFilter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/XPathBasedFilter.java?rev=413845&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/XPathBasedFilter.java
(added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/XPathBasedFilter.java
Tue Jun 13 02:47:25 2006
@@ -0,0 +1,91 @@
+/*
+ * Copyright  1999-2004 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 org.apache.savan.filters;
+
+import java.util.List;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.savan.SavanException;
+/*
+ * Copyright  1999-2004 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.
+ *
+ */
+
+import org.jaxen.JaxenException;
+
+public class XPathBasedFilter extends Filter {
+
+	private String XPathString = null;
+	
+	public String getXPathString() {
+		return XPathString;
+	}
+
+	public void setXPathString(String XPathString) {
+		this.XPathString = XPathString;
+	}
+
+	/**
+	 * This method may fail due to the JIRA issues WS-Commons(40) amd WS-Commons (41)
+	 */
+	public boolean checkEnvelopeCompliance(SOAPEnvelope envelope) throws SavanException {
+		OMElement firstChild = envelope.getBody().getFirstElement();
+		if (firstChild==null)
+			return false;
+		
+		if (XPathString==null)
+			return true;
+		
+		try {
+			AXIOMXPath xpath = new AXIOMXPath (XPathString);
+			List resultList = xpath.selectNodes(firstChild);
+			
+			if (resultList.size()>0)
+				return true;
+			else 
+				return false;
+		} catch (JaxenException e) {
+			throw new SavanException (e);
+		}
+	}
+
+	public void setUp(OMNode element) {
+		if (!(element instanceof OMText))
+			throw new IllegalArgumentException ("Cannot determine a valid XPath string");
+		
+		OMText text = (OMText) element;
+		XPathString = text.getText();
+	}
+
+}

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanOutHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanOutHandler.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanOutHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanOutHandler.java
Tue Jun 13 02:47:25 2006
@@ -21,7 +21,7 @@
 import org.apache.axis2.handlers.AbstractHandler;
 import org.apache.savan.SavanConstants;
 import org.apache.savan.SavanMessageContext;
-import org.apache.savan.publication.PublicationErrorReport;
+import org.apache.savan.publication.PublicationReport;
 import org.apache.savan.publication.PublicationProcessor;
 import org.apache.savan.util.AbstractSavanUtilFactory;
 import org.apache.savan.util.ProtocolManager;
@@ -47,7 +47,7 @@
 		int messagetype = smc.getMessageType();		
 		
 		if (messagetype==SavanConstants.MessageTypes.UNKNOWN) {
-			PublicationErrorReport report = processor.notifyListners (smc);
+			PublicationReport report = processor.notifyListners (smc);
 			
 			//TODO use the report to inform abt the errors.
 			

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationProcessor.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationProcessor.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationProcessor.java
Tue Jun 13 02:47:25 2006
@@ -29,22 +29,21 @@
 
 public abstract class PublicationProcessor {
 
-	public PublicationErrorReport notifyListners (SavanMessageContext messageToBeNotified) {
+	public PublicationReport notifyListners (SavanMessageContext messageToBeNotified) {
 		ConfigurationContext configurationContext = messageToBeNotified.getConfigurationContext();
 		HashMap subscribers = (HashMap) configurationContext.getProperty(SavanConstants.SUBSCRIBER_TABLE);
 		
-		PublicationErrorReport report = new PublicationErrorReport ();
+		PublicationReport report = new PublicationReport ();
 		
 		updatePublication (messageToBeNotified);
 		
 		for (Iterator it=subscribers.keySet().iterator();it.hasNext();) {
 			Subscriber subscriber = (Subscriber) subscribers.get(it.next());
 			
-			//TODO check weather the this subscriber is within the given filter
 			try {
-				subscriber.sendNotification(messageToBeNotified);
+				subscriber.processPublication(messageToBeNotified,report);
 			} catch (SavanException e) {
-				report.addReportEntry(subscriber.getId(),e);
+				report.addErrorReportEntry (subscriber.getId(),e);
 			}
 		}
 		

Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationReport.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationReport.java?rev=413845&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationReport.java
(added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationReport.java
Tue Jun 13 02:47:25 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright  1999-2004 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 org.apache.savan.publication;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.apache.savan.SavanException;
+
+
+public class PublicationReport {
+
+	private Hashtable errors = null;
+	private ArrayList notifiedSubscribers;
+	
+	public PublicationReport () {
+		errors = new Hashtable ();
+		notifiedSubscribers = new ArrayList ();
+	}
+	
+	public void addErrorReportEntry (String id, SavanException reason) {
+		errors.put(id,reason);
+	}
+	
+	public void addNotifiedSubscriber (String subscriberID) {
+		notifiedSubscribers.add(subscriberID);
+	}
+
+	public Hashtable getErrors() {
+		return errors;
+	}
+
+	public ArrayList getNotifiedSubscribers() {
+		return notifiedSubscribers;
+	}
+	
+	
+}

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/CompositeSubscriber.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/CompositeSubscriber.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/CompositeSubscriber.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/CompositeSubscriber.java
Tue Jun 13 02:47:25 2006
@@ -20,10 +20,9 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
-
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
-import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.publication.PublicationReport;
 import org.apache.savan.subscription.ExpirationBean;
 
 
@@ -39,10 +38,10 @@
 		subscribers.add(subscriber);
 	}
 	
-	public void sendNotification(SavanMessageContext notificationMessage)  throws SavanException
{
+	public void sendPublication(SavanMessageContext publication, PublicationReport report) 
throws SavanException {
 		for (Iterator it = subscribers.iterator();it.hasNext();) {
 			Subscriber subscriber = (Subscriber) it.next();
-			subscriber.sendNotification(notificationMessage);
+			subscriber.processPublication(publication,report);
 		}
 	}
 
@@ -59,7 +58,5 @@
 			subscriber.setSubscriptionEndingTime(subscriptionEndingTime);
 		}
 	}
-	
-	
 
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/LeafSubscriber.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/LeafSubscriber.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/LeafSubscriber.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/LeafSubscriber.java
Tue Jun 13 02:47:25 2006
@@ -22,6 +22,7 @@
 
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
+import org.apache.savan.publication.PublicationReport;
 import org.apache.savan.subscription.ExpirationBean;
 import org.apache.savan.util.CommonUtil;
 
@@ -54,7 +55,7 @@
 		
 	}
 	
-	public void sendNotification(SavanMessageContext notificationMessage) throws SavanException
{
+	public void sendPublication(SavanMessageContext publication,PublicationReport report) throws
SavanException {
 		Date date = new Date ();
 		
 		boolean expired = false;
@@ -66,7 +67,7 @@
 			throw new SavanException (message);
 		}
 		
-		doProtocolSpecificNotification (notificationMessage);
+		doProtocolSpecificPublication (publication);
 	}
 	
 	
@@ -75,5 +76,5 @@
 		this.subscriptionEndingTime = subscriptionEndingTime;
 	}
 
-	public abstract void doProtocolSpecificNotification (SavanMessageContext notificationMessage)
throws SavanException;
+	public abstract void doProtocolSpecificPublication (SavanMessageContext publication) throws
SavanException;
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/Subscriber.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/Subscriber.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/Subscriber.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/Subscriber.java
Tue Jun 13 02:47:25 2006
@@ -19,23 +19,68 @@
 
 import java.util.Date;
 
+import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.publication.PublicationReport;
 import org.apache.savan.subscription.ExpirationBean;
 
 public abstract class Subscriber {
 
 	String id;
+	Filter filter = null;
 	
+	public Filter getFilter() {
+		return filter;
+	}
+
+	public void setFilter(Filter filter) {
+		this.filter = filter;
+	}
+
 	public String getId() {
 		return id;
 	}
+	
 	public void setId(String id) {
 		this.id = id;
 	}
 	
+	public boolean doesMessageBelongToTheFilter(SavanMessageContext smc) throws SavanException
{
+		if (filter!=null) {
+			SOAPEnvelope envelope = smc.getEnvelope();
+			return filter.checkEnvelopeCompliance(envelope);
+		} else 
+			return true;
+	}
+	
+	/**
+	 * This method first checks weather the passed message complies with the current filter.
+	 * If so message is sent, and the subscriberID is added to the PublicationReport.
+	 * Else message is ignored.
+	 * 
+	 * @param smc
+	 * @param report
+	 * @throws SavanException
+	 */
+	public void processPublication (SavanMessageContext publication,PublicationReport report)
throws SavanException {
+		if (doesMessageBelongToTheFilter(publication)) {
+			sendPublication(publication,report);
+			if (getId()!=null)
+				report.addNotifiedSubscriber(getId());
+		}
+	}
+	
 	public abstract void setSubscriptionEndingTime (Date subscriptionEndingTime);
 	public abstract void renewSubscription (ExpirationBean bean);
-	public abstract void sendNotification (SavanMessageContext notificationMessage) throws SavanException;
-
+	
+	/**
+	 * This should be used by based classes to sendThe publication in its own manner
+	 * 
+	 * @param publication
+	 * @param report
+	 * @throws SavanException
+	 */
+	public abstract void sendPublication (SavanMessageContext publication,PublicationReport
report) throws SavanException;
 }

Modified: webservices/axis2/trunk/java/modules/savan/test-resources/eventing-subscription.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/test-resources/eventing-subscription.xml?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/test-resources/eventing-subscription.xml (original)
+++ webservices/axis2/trunk/java/modules/savan/test-resources/eventing-subscription.xml Tue
Jun 13 02:47:25 2006
@@ -22,9 +22,7 @@
  		</wse:Delivery> 
  		<wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires> 
  		<wse:Filter xmlns:ow='http://www.example.org/oceanwatch' 
- 		Dialect='http://www.example.org/topicFilter' > 
- 			weather.storms 
- 		</wse:Filter> 
+ 		Dialect='http://www.w3.org/TR/1999/REC-xpath-19991116'>/</wse:Filter> 
  	</wse:Subscribe> 
  </s12:Body> 
  </s12:Envelope>

Modified: webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/CompositeSubscriberTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/CompositeSubscriberTest.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/CompositeSubscriberTest.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/CompositeSubscriberTest.java
Tue Jun 13 02:47:25 2006
@@ -1,13 +1,14 @@
 package org.apache.axis2.savan;
 
+import junit.framework.TestCase;
+
 import org.apache.axis2.context.MessageContext;
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
+import org.apache.savan.publication.PublicationReport;
 import org.apache.savan.subscribers.CompositeSubscriber;
 import org.apache.savan.subscribers.LeafSubscriber;
 
-import junit.framework.TestCase;
-
 public class CompositeSubscriberTest extends TestCase {
 
 	public void testSubscribers () throws SavanException {
@@ -22,7 +23,8 @@
 		compositeSubscriber.addSubscriber(leafSubscriber1);
 		compositeSubscriber.addSubscriber(leafSubscriber2);
 		
-		compositeSubscriber.sendNotification(smc);
+		PublicationReport report = new PublicationReport ();
+		compositeSubscriber.sendPublication(smc,report);
 		assertTrue(leafSubscriber1.isNotified());
 		assertTrue(leafSubscriber2.isNotified());
 	}
@@ -31,7 +33,7 @@
 		
 		boolean notified = false;
 		
-		public void doProtocolSpecificNotification(SavanMessageContext notificationMessage) {
+		public void doProtocolSpecificPublication(SavanMessageContext notificationMessage) {
 			notified = true;
 		}
 		

Modified: webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/ConpositeSubscriberTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/ConpositeSubscriberTest.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/ConpositeSubscriberTest.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/ConpositeSubscriberTest.java
Tue Jun 13 02:47:25 2006
@@ -33,7 +33,7 @@
 		compositeSubscriber.addSubscriber(leafSubscriber1);
 		compositeSubscriber.addSubscriber(leafSubscriber2);
 		
-		compositeSubscriber.sendNotification(null);
+		compositeSubscriber.sendPublication(null,null);
 		assertTrue(leafSubscriber1.isNotified());
 		assertTrue(leafSubscriber2.isNotified());
 	}
@@ -42,7 +42,7 @@
 		
 		boolean notified = false;
 		
-		public void doProtocolSpecificNotification(SavanMessageContext notificationMessage) {
+		public void doProtocolSpecificPublication(SavanMessageContext notificationMessage) {
 			notified = true;
 		}
 		

Modified: webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java?rev=413845&r1=413844&r2=413845&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java
Tue Jun 13 02:47:25 2006
@@ -3,12 +3,8 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.Date;
-
 import javax.xml.namespace.QName;
-
 import junit.framework.TestCase;
-
-import org.apache.axiom.om.OMText;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
@@ -40,9 +36,6 @@
 		
 		assertEquals(eventingSubscriber.getDelivery().getDeliveryEPR().getAddress() ,"http://www.other.example.com/OnStormWarning");
 		assertEquals(eventingSubscriber.getEndToEPr().getAddress(),"http://www.example.com/MyEventSink");
-		assertEquals(eventingSubscriber.getFilter().getFilterType(),"http://www.example.org/topicFilter");
-		assertEquals(((OMText) eventingSubscriber.getFilter().getFilter()).getText().trim(),"weather.storms");
-		
 		Date date = ConverterUtil.convertTodateTime("2004-06-26T21:07:00.000-08:00").getTime();
 		assertEquals(eventingSubscriber.getSubscriptionEndingTime(),date);
 	}

Added: webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/XPathBasedFilterTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/XPathBasedFilterTest.java?rev=413845&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/XPathBasedFilterTest.java
(added)
+++ webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/XPathBasedFilterTest.java
Tue Jun 13 02:47:25 2006
@@ -0,0 +1,69 @@
+/*
+ * Copyright  1999-2004 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 org.apache.axis2.savan;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.filters.XPathBasedFilter;
+
+public class XPathBasedFilterTest extends TestCase {
+
+	String filterString = "//elem1";
+	
+	public void testMessageFiltering () throws AxisFault {
+		SOAPEnvelope envelope = createTestEnvelope ();
+		
+		OMNode filterNode = getFilterElement ();
+		Filter filter = new XPathBasedFilter ();
+		filter.setUp(filterNode);
+		
+		assertTrue (filter.checkEnvelopeCompliance(envelope));
+	}
+	
+	private SOAPEnvelope createTestEnvelope () {
+		SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+		SOAPEnvelope envelope = factory.getDefaultEnvelope();
+		
+		OMElement elem1 = factory.createOMElement("elem1",null);
+		OMElement elem2 = factory.createOMElement("elem2",null);
+		OMElement elem3 = factory.createOMElement("elem3",null);
+
+		elem2.addChild(elem3);
+		elem1.addChild(elem2);
+		
+		envelope.getBody().addChild(elem1);
+		factory.createOMDocument().addChild(envelope);
+		
+		return envelope;
+	}
+	
+	private OMNode getFilterElement () {
+		SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+		OMText text = factory.createOMText(filterString);
+		return text;
+	}
+	
+}



---------------------------------------------------------------------
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