axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r421059 - in /webservices/axis2/trunk/java/modules/savan: conf/ src/org/apache/savan/configuration/ src/org/apache/savan/eventing/ src/org/apache/savan/eventing/client/ src/org/apache/savan/module/ src/org/apache/savan/util/ test-resources/...
Date Wed, 12 Jul 2006 00:57:15 GMT
Author: chamikara
Date: Tue Jul 11 17:57:14 2006
New Revision: 421059

URL: http://svn.apache.org/viewvc?rev=421059&view=rev
Log:
Updated the savan-config to include filters. The filters defined here can be used b any protocol.
Removed createFilter method from the UtilFactory

Modified:
    webservices/axis2/trunk/java/modules/savan/conf/savan-config.xml
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/ConfigurationManager.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/EventingSubscriptionProcessor.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingUtilFactory.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/EventingClient.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/SubscriptionStatus.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/UtilFactory.java
    webservices/axis2/trunk/java/modules/savan/test-resources/savan-config-test.xml
    webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java

Modified: webservices/axis2/trunk/java/modules/savan/conf/savan-config.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/conf/savan-config.xml?rev=421059&r1=421058&r2=421059&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/conf/savan-config.xml (original)
+++ webservices/axis2/trunk/java/modules/savan/conf/savan-config.xml Tue Jul 11 17:57:14 2006
@@ -20,14 +20,11 @@
     	</subscriberStore>
     </subscriberStores>
     
-    <!--
     <filters>
     	<filter>
-    		<name>xpath</name>
-    		<identifier>org.apache.savan.storage.DefaultSubscriberStore</identifier>
-    		<class>org.apache.savan.storage.DefaultSubscriberStore</class>
+    		<identifier>http://www.w3.org/TR/1999/REC-xpath-19991116</identifier>
+    		<class>org.apache.savan.filters.XPathBasedFilter</class>
     	</filter>
     </filters>
-    -->
     
 </savan-config>

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/ConfigurationManager.java?rev=421059&r1=421058&r2=421059&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/ConfigurationManager.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/ConfigurationManager.java
Tue Jul 11 17:57:14 2006
@@ -35,6 +35,7 @@
 import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
 import org.apache.savan.SavanConstants;
 import org.apache.savan.SavanException;
+import org.apache.savan.filters.Filter;
 import org.apache.savan.storage.SubscriberStore;
 import org.apache.savan.util.UtilFactory;
 
@@ -46,6 +47,7 @@
 	
 	private HashMap protocolMap = null;
 	private HashMap subscriberStoreNamesMap = null;
+	private HashMap filterMap = null;
 	
 	private final String SavanConfig = "savan-config";
 	private final String Protocols = "protocols";
@@ -57,12 +59,16 @@
 	private final String SOAPAction = "mapping-rules";
 	private final String SubscriberStores = "subscriberStores";
 	private final String SubscriberStore = "subscriberStore";
+	private final String Filters = "filters";
+	private final String Filter = "filter";
 	private final String Key = "key";
 	private final String Clazz = "class";
+	private final String Identifier = "identifier";
 	
 	public ConfigurationManager () {
 		protocolMap = new HashMap ();
 		subscriberStoreNamesMap = new HashMap ();
+		filterMap = new HashMap ();
 	}
 	
 	/**
@@ -139,6 +145,12 @@
 			throw new SavanException ("'subscriberStores' element should be present, as a sub-element
of the 'savan-config' element");
 		}
 		processSubscriberStores(subscriberStoresElement);
+		
+		OMElement filtersElement = element.getFirstChildWithName(new QName (Filters));
+		if (subscriberStoresElement==null) {
+			throw new SavanException ("'Filters' element should be present, as a sub-element of the
'savan-config' element");
+		}
+		processFilters (filtersElement);
 	}
 	
 	private void processProtocols (OMElement element) throws SavanException {
@@ -230,6 +242,14 @@
 		return (SubscriberStore) getObject(name);
 	}
 	
+	public Filter getFilterInstance (String key) throws SavanException {
+		String filterClass = (String) filterMap.get(key);
+		if (filterClass==null)
+			return null;
+		
+		return (Filter) getObject(filterClass);
+	}
+	
 	private Object getObject (String className) throws SavanException {
 	
 		Object obj;
@@ -242,6 +262,29 @@
 		}
 		 
 		return obj;
+	}
+	
+	private void processFilters (OMElement element) throws SavanException {
+		Iterator filterElementsIterator = element.getChildrenWithName(new QName (Filter));
+		while (filterElementsIterator.hasNext()) {
+			OMElement filterElement = (OMElement) filterElementsIterator.next();
+			processFilter (filterElement);
+		}
+	}
+	
+	private void processFilter (OMElement element) throws SavanException {
+		OMElement identifierElement = element.getFirstChildWithName(new QName (Identifier));
+		OMElement classElement = element.getFirstChildWithName(new QName (Clazz));
+		
+		if (identifierElement==null)
+			throw new SavanException ("Identifier element is not present within the Filter");
+		if (classElement==null)
+			throw new SavanException ("Class element is not present within the Filter");
+		
+		String identifier = identifierElement.getText();
+		String clazz = classElement.getText();
+		
+		filterMap.put(identifier,clazz);
 	}
 	
 }

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=421059&r1=421058&r2=421059&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 Jul 11 17:57:14 2006
@@ -22,7 +22,7 @@
 	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 = FilterDialects.XPath;
+	String DEFAULT_FILTER_IDENTIFIER = FilterDialects.XPath;
 	
 	interface TransferedProperties {
 		String SUBSCRIBER_UUID = "SAVAN_EVENTING_SUBSCRIBER_UUID";

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=421059&r1=421058&r2=421059&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 Jul 11 17:57:14 2006
@@ -35,8 +35,10 @@
 import org.apache.axis2.databinding.types.Duration;
 import org.apache.axis2.databinding.utils.ConverterUtil;
 import org.apache.axis2.util.UUIDGenerator;
+import org.apache.savan.SavanConstants;
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
+import org.apache.savan.configuration.ConfigurationManager;
 import org.apache.savan.configuration.Protocol;
 import org.apache.savan.filters.Filter;
 import org.apache.savan.subscribers.Subscriber;
@@ -58,6 +60,10 @@
 	
 	public Subscriber getSubscriberFromMessage(SavanMessageContext smc) throws SavanException
{
 
+		ConfigurationManager configurationManager = (ConfigurationManager) smc.getConfigurationContext().getProperty(SavanConstants.CONFIGURATION_MANAGER);
+		if (configurationManager==null)
+			throw new SavanException ("Configuration Manager not set");
+		
 		Protocol protocol = smc.getProtocol();
 		if (protocol==null)
 			throw new SavanException ("Protocol not found");
@@ -112,6 +118,10 @@
 			deliveryMode = EventingConstants.DEFAULT_DELIVERY_MODE;
 		}
 		
+		if (!deliveryModesupported()) {
+			//TODO throw unsupported delivery mode fault.
+		}
+		
 		Delivery delivery = new Delivery ();
 		delivery.setDeliveryEPR(notifyToEPr);
 		delivery.setDeliveryMode(deliveryMode);
@@ -152,13 +162,14 @@
 			OMNode filterNode = filterElement.getFirstOMChild();
 			OMAttribute dialectAttr = filterElement.getAttribute(new QName (EventingConstants.ElementNames.Dialect));
 			Filter filter = null;
-			if (dialectAttr==null) {
-				filter = utilFactory.createFilter (EventingConstants.DEFAULT_FILTER_DIALECT);
-			} else {
-				filter = utilFactory.createFilter (dialectAttr.getAttributeValue());
+			
+			String filterKey = EventingConstants.DEFAULT_FILTER_IDENTIFIER;
+			if (dialectAttr!=null) {
+				filterKey = dialectAttr.getAttributeValue();
 			}
+			filter = configurationManager.getFilterInstance(filterKey);
 			if (filter==null)
-				throw new SavanException ("Cant find a suitable message filter");
+				throw new SavanException ("The Filter defined by the dialect is not available");
 			
 			filter.setUp (filterNode);
 			
@@ -253,6 +264,19 @@
 			}
 		}
 		
+		boolean invalidExpirationTime = false;
+		if (bean.isDuration()) {
+			if (isInvalidDiration (bean.getDurationValue()))
+				invalidExpirationTime = true;
+		} else {
+			if (isDateInThePast (bean.getDateValue())) 
+				invalidExpirationTime = true;
+		}
+		
+		if (invalidExpirationTime) {
+			//TODO throw Invalid Expiration Time fault
+		}
+		
 		return bean;
 	}
 
@@ -270,7 +294,22 @@
 			throw new SavanException ("The subscriber has a unknown SOAP version property set");
 		
 		SOAPEnvelope envelope = factory.getDefaultEnvelope();
-		
-		
 	}
+	
+	private boolean deliveryModesupported() {
+		return true;
+	}
+	
+	private boolean isInvalidDiration (Duration duration) {
+		return false;
+	}
+	
+	private boolean isDateInThePast (Date date) {
+		return false;
+	}
+	
+	private boolean filterDilalectSupported (String filterDialect){ 
+		return true;
+	}
+	
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingUtilFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingUtilFactory.java?rev=421059&r1=421058&r2=421059&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingUtilFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingUtilFactory.java
Tue Jul 11 17:57:14 2006
@@ -20,8 +20,6 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.savan.SavanConstants;
 import org.apache.savan.SavanMessageContext;
-import org.apache.savan.filters.Filter;
-import org.apache.savan.filters.XPathBasedFilter;
 import org.apache.savan.messagereceiver.MessageReceiverDeligater;
 import org.apache.savan.subscribers.Subscriber;
 import org.apache.savan.subscription.SubscriptionProcessor;
@@ -63,13 +61,6 @@
 	
 	public MessageReceiverDeligater createMessageReceiverDeligater() {
 		return new EventingMessageReceiverDeligater ();
-	}
-
-	public Filter createFilter (String dialect) {
-		if (EventingConstants.FilterDialects.XPath.equals(dialect))
-			return new XPathBasedFilter ();
-		else
-			return null;
 	}
 
 	public Subscriber createSubscriber() {

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/EventingClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/EventingClient.java?rev=421059&r1=421058&r2=421059&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/EventingClient.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/EventingClient.java
Tue Jul 11 17:57:14 2006
@@ -143,7 +143,8 @@
 		options.setTo(managerEPR);
 		
 		OMElement unsubscribeResponse =  serviceClient.sendReceive (envelope.getBody().getFirstElement());
-
+		//TODO process unsubscriber response
+		
 		options.setAction(oldAction);
 		options.setTo(oldTo);
 	}
@@ -217,8 +218,8 @@
 		OMElement expiresElementElement = getStatusResponseElement.getFirstChildWithName(new QName
(EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Expires));
 		if (expiresElementElement!=null) {
 			String valueStr = expiresElementElement.getText();
-			long expires = Long.parseLong(valueStr);
-			subscriptionStatus.setExpirationTime(expires);
+//			long expires = Long.parseLong(valueStr);
+			subscriptionStatus.setExpirationValue(valueStr);
 		}
 		
 		return subscriptionStatus;

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/SubscriptionStatus.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/SubscriptionStatus.java?rev=421059&r1=421058&r2=421059&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/SubscriptionStatus.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/SubscriptionStatus.java
Tue Jul 11 17:57:14 2006
@@ -18,15 +18,17 @@
 
 public class SubscriptionStatus {
 
-	long expirationTime = -1;
-
-	public long getExpirationTime() {
-		return expirationTime;
+	String expirationValue;
+
+	public String getExpirationValue() {
+		return expirationValue;
+	}
+
+	public void setExpirationValue(String expirationValue) {
+		this.expirationValue = expirationValue;
 	}
 
-	public void setExpirationTime(long expirationTime) {
-		this.expirationTime = expirationTime;
-	}
+	
 	
 	
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java?rev=421059&r1=421058&r2=421059&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java
Tue Jul 11 17:57:14 2006
@@ -44,7 +44,7 @@
 		try {
 			configurationManager.configure();
 		} catch (SavanException e) {
-			log.debug("Exception thrown while trying to configure the Savan module",e);
+			log.error ("Exception thrown while trying to configure the Savan module",e);
 		}
 		
 		configContext.setProperty(SavanConstants.CONFIGURATION_MANAGER,configurationManager);

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/UtilFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/UtilFactory.java?rev=421059&r1=421058&r2=421059&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/UtilFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/UtilFactory.java
Tue Jul 11 17:57:14 2006
@@ -33,7 +33,6 @@
 	public abstract SavanMessageContext initializeMessage (SavanMessageContext messageContext);
 	public abstract SubscriptionProcessor createSubscriptionProcessor ();
 	public abstract MessageReceiverDeligater createMessageReceiverDeligater ();
-	public abstract Filter createFilter (String dialect);
 	public abstract Subscriber createSubscriber ();
 	
 }

Modified: webservices/axis2/trunk/java/modules/savan/test-resources/savan-config-test.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/test-resources/savan-config-test.xml?rev=421059&r1=421058&r2=421059&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/test-resources/savan-config-test.xml (original)
+++ webservices/axis2/trunk/java/modules/savan/test-resources/savan-config-test.xml Tue Jul
11 17:57:14 2006
@@ -21,4 +21,12 @@
     	</subscriberStore>
     </subscriberStores>
     
+    <filters>
+    	<filter>
+    		<identifier>http://www.w3.org/TR/1999/REC-xpath-19991116</identifier>
+    		<class>org.apache.savan.filters.XPathBasedFilter</class>
+    	</filter>
+    </filters>
+    
+    
 </savan-config>

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=421059&r1=421058&r2=421059&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 Jul 11 17:57:14 2006
@@ -11,10 +11,14 @@
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.Options;
+import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.databinding.utils.ConverterUtil;
 import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.savan.SavanConstants;
 import org.apache.savan.SavanMessageContext;
+import org.apache.savan.configuration.ConfigurationManager;
 import org.apache.savan.configuration.Protocol;
 import org.apache.savan.eventing.EventingConstants;
 import org.apache.savan.eventing.EventingSubscriber;
@@ -27,6 +31,8 @@
 
 public class EventingSubscripitonProcessorTest extends TestCase {
 
+	private final String TEST_SAVAN_CONFIG = "savan-config-test.xml";
+	
 	public void testSubscriberExtraction () throws Exception {
 		SavanMessageContext smc = getSubscriptionMessage();
 		
@@ -76,10 +82,15 @@
 
 		SOAPEnvelope envelope = CommonUtil.getTestEnvelopeFromFile(testRource,"eventing-subscription.xml");
 		
+		AxisConfiguration axisConfiguration = new AxisConfiguration ();
+		ConfigurationContext configurationContext = new ConfigurationContext (axisConfiguration);
+		
 		MessageContext mc = new MessageContext ();
 		SavanMessageContext smc = new SavanMessageContext (mc);
 		mc.setEnvelope(envelope);
 		
+		mc.setConfigurationContext(configurationContext);
+		
 		Options options = new Options ();
 		options.setTo(new EndpointReference ("http://DummyToAddress/"));
 		
@@ -91,6 +102,16 @@
 		mc.setAxisService(new AxisService ("DummyService"));
 		
 		options.setAction("urn:uuid:DummyAction");
+		
+		String savan_concig_file = testRource + File.separator + TEST_SAVAN_CONFIG;
+		File file = new File (savan_concig_file);
+		if (!file.exists())
+			throw new IOException (TEST_SAVAN_CONFIG + " file is not available in test-resources.");
+		
+		ConfigurationManager configurationManager = new ConfigurationManager ();
+		configurationManager.configure(file);
+		
+		configurationContext.setProperty(SavanConstants.CONFIGURATION_MANAGER,configurationManager);
 		
 		return smc;
 	}



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