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/07/05 08:07:37 UTC

svn commit: r419173 [1/2] - in /webservices/axis2/trunk/java/modules/savan: ./ conf/ src/org/apache/savan/ src/org/apache/savan/configuration/ src/org/apache/savan/eventing/ src/org/apache/savan/eventing/client/ src/org/apache/savan/filters/ src/org/ap...

Author: chamikara
Date: Tue Jul  4 23:07:35 2006
New Revision: 419173

URL: http://svn.apache.org/viewvc?rev=419173&view=rev
Log:
Re-structured the Savan module. Savan configurations are loaded from a savan-config.xml which can be used to define Protocols, MessageStores, Filters etc.

configuration is loaded at the module initialization and is stored in the ConfigurationContext.

Added the javadocs to explain some classes and interfaces.

Added:
    webservices/axis2/trunk/java/modules/savan/conf/savan-config.xml
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/MessageInitializer.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/ConfigurationManager.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/MappingRules.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/Protocol.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/DefaultSubscriberStore.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/SubscriberStore.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/ConfigurationManagerTest.java
Removed:
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingPublicationProcessor.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/FilterFactory.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationProcessor.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/AbstractSavanUtilFactory.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/SavanUtilFactory.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/SavanException.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanMessageContext.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/EventingMessageReceiverDeligater.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/SubscriptionResponseData.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/Filter.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/XPathBasedFilter.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanInHandler.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanOutHandler.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/MessageReceiverDeligater.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/module/SavanModule.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationReport.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/client/PublicationClient.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/src/org/apache/savan/subscription/ExpirationBean.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/RenewBean.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/SubscriptionProcessor.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/CommonUtil.java
    webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/ProtocolManager.java
    webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java

Added: 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=419173&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/conf/savan-config.xml (added)
+++ webservices/axis2/trunk/java/modules/savan/conf/savan-config.xml Tue Jul  4 23:07:35 2006
@@ -0,0 +1,33 @@
+<savan-config>
+
+    <protocols>
+        <protocol>
+        	<name>eventing</name>
+        	<utilFactory>org.apache.savan.eventing.EventingUtilFactory</utilFactory>
+        	<mapping-rules>
+                <action>http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</action>
+                <action>http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew</action>
+                <action>http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus</action>
+                <action>http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</action>
+        	</mapping-rules>
+        </protocol>
+    </protocols>
+    
+    <subscriberStores>
+    	<subscriberStore>
+    		<key>default</key>
+    		<class>org.apache.savan.storage.DefaultSubscriberStore</class>
+    	</subscriberStore>
+    </subscriberStores>
+    
+    <!--
+    <filters>
+    	<filter>
+    		<name>xpath</name>
+    		<identifier>org.apache.savan.storage.DefaultSubscriberStore</identifier>
+    		<class>org.apache.savan.storage.DefaultSubscriberStore</class>
+    	</filter>
+    </filters>
+    -->
+    
+</savan-config>
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/savan/project.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/project.xml?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/project.xml (original)
+++ webservices/axis2/trunk/java/modules/savan/project.xml Tue Jul  4 23:07:35 2006
@@ -66,12 +66,19 @@
             <version>${pom.currentVersion}</version>
         </dependency>
         
+        <dependency>
+            <groupId>axis2</groupId>
+            <artifactId>axis2-java2wsdl</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        
         <!-- Following dependency was required due to the ConverterUtil class-->
         <dependency>
             <groupId>axis2</groupId>
             <artifactId>axis2-adb</artifactId>
             <version>${pom.currentVersion}</version>
         </dependency>
+        
         <!-- external JARs -->
         <dependency>
             <groupId>commons-logging</groupId>

Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/MessageInitializer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/MessageInitializer.java?rev=419173&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/MessageInitializer.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/MessageInitializer.java Tue Jul  4 23:07:35 2006
@@ -0,0 +1,26 @@
+/*
+ * 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;
+
+public class MessageInitializer {
+
+	public static void initializeMessage (SavanMessageContext smc) {
+		//TODO fill the properties in to the SMC,
+		//For e.g. UtilFactory and the SubscriberStore
+	}
+}

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=419173&r1=419172&r2=419173&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 Jul  4 23:07:35 2006
@@ -17,18 +17,29 @@
 
 package org.apache.savan;
 
+/**
+ * Contains the constants used by Savan
+ * 
+ *
+ */
 public interface SavanConstants {
 
+	String CONFIGURATION_MANAGER = "SavanConfigurationManager"; //Property name to store the CM in the ConfigCtx.
+	
 	String VALUE_TRUE = "true";
 	String VALUE_FALSE = "false";
+
+	String MESSAGE_TYPE = "SavanMessageType";
+	String PUBLICATION_MESSAGE = "SavanPublicationMessage";
 	
-	int PROTOCOL_EVENTING = 1;
-	int PROTOCOL_NOTIFICATION = 2;
+	String SUBSCRIBER_STORE = "SubscriberStore"; //AxisService property
+	String SUBSCRIBER_STORE_KEY = "SubscriberStoreKey"; //to mention the key in the services.xml
+	String PROTOCOL = "Protocol";
 	
-	String PROTOCOL_VERSION = "SavanProtocolVersion";
-	String MESSAGE_TYPE = "SavanMessageType";
+	String CONFIG_FILE = "savan-config.xml";
+	String UTIL_FACTORY = "UtilFactory";
 	
-	String PUBLICATION_MESSAGE = "SavanPublicationMessage";
+	String DEFAULT_SUBSCRIBER_STORE_KEY = "default";
 	
 	interface MessageTypes {
 		int UNKNOWN = -1;
@@ -42,10 +53,10 @@
 		int GET_STATUS_RESPONSE_MESSAGE = 8;
 	}
 	
-	interface FilterDialects {
-		String XPath = "http://www.w3.org/TR/1999/REC-xpath-19991116";
+	interface Properties {
+		String SUBSCRIBER_STORE = "SubscriberStore";
 	}
 	
-	String SUBSCRIBER_TABLE = "SUBSCRIBER_TABLE";
+
 	
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanException.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanException.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanException.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanException.java Tue Jul  4 23:07:35 2006
@@ -19,6 +19,10 @@
 
 import org.apache.axis2.AxisFault;
 
+/**
+ * To convey a exception that occured in Savan.
+ * 
+ */
 public class SavanException extends AxisFault {
 
 	public SavanException (String cause) {

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanMessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanMessageContext.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanMessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/SavanMessageContext.java Tue Jul  4 23:07:35 2006
@@ -18,9 +18,17 @@
 package org.apache.savan;
 
 import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.savan.configuration.Protocol;
+import org.apache.savan.storage.SubscriberStore;
 
+/**
+ * This encaptulates a Axis2 Message Context.
+ * Provide some easy methods to access Savan specific properties easily.
+ */
 public class SavanMessageContext {
 
 	MessageContext messageContext = null;
@@ -29,24 +37,17 @@
 		this.messageContext = messageContext;
 	}
 	
-	public int getProtocolVersion () throws SavanException {
-		Integer version = (Integer) messageContext.getProperty(SavanConstants.PROTOCOL_VERSION);
-		if (version==null)
-			throw new SavanException ("Protocol version is not set in the SavanMessageContext");
-		
-		return version.intValue();
-	}
-	
-	public void setProtocolVersion (int protocolVersion) {
-		messageContext.setProperty(SavanConstants.PROTOCOL_VERSION,new Integer (protocolVersion));
-	}
-	
 	public void setMessageType (int type) {
 		messageContext.setProperty(SavanConstants.MESSAGE_TYPE, new Integer (type));
 	}
 	
 	public int getMessageType () {
 		Integer typeInt = (Integer) messageContext.getProperty(SavanConstants.MESSAGE_TYPE);
+		if (typeInt==null) {
+			typeInt = new Integer (SavanConstants.MessageTypes.UNKNOWN);
+			messageContext.setProperty(SavanConstants.MESSAGE_TYPE,typeInt);
+		}
+		
 		return typeInt.intValue();
 	}
 	
@@ -69,4 +70,37 @@
 	public MessageContext getMessageContext () {
 		return messageContext;
 	}
+	
+	public SubscriberStore getSubscriberStore () {
+		Parameter parameter = messageContext.getParameter(SavanConstants.SUBSCRIBER_STORE);
+		SubscriberStore subscriberStore = null;
+		if (parameter!=null) {
+			parameter = messageContext.getParameter(SavanConstants.SUBSCRIBER_STORE);
+			subscriberStore = (SubscriberStore) parameter.getValue();
+		}
+		
+		return subscriberStore;
+	}
+	
+	public void setSubscriberStore (SubscriberStore store) throws SavanException  {
+		Parameter parameter = new Parameter ();
+		parameter.setName(SavanConstants.SUBSCRIBER_STORE);
+		parameter.setValue(store);
+		
+		try {
+			messageContext.getAxisService().addParameter(parameter);
+		} catch (AxisFault e) {
+			String message = "Could not add the Subscriber Store parameter";
+			throw new SavanException (message,e);
+		}
+	}
+	
+	public void setProtocol (Protocol protocol) {
+		messageContext.setProperty(SavanConstants.PROTOCOL, protocol);
+	}
+	
+	public Protocol getProtocol () {
+		return (Protocol) messageContext.getProperty(SavanConstants.PROTOCOL);
+	}
+	
 }

Added: 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=419173&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/ConfigurationManager.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/ConfigurationManager.java Tue Jul  4 23:07:35 2006
@@ -0,0 +1,247 @@
+/*
+ * 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.configuration;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.util.UtilFactory;
+
+/**
+ * This is responsible for loading Savan configuration data from a resource
+ * for e.g. from a savan-config.xml fie
+ */
+public class ConfigurationManager {
+	
+	private HashMap protocolMap = null;
+	private HashMap subscriberStoreNamesMap = null;
+	
+	private final String SavanConfig = "savan-config";
+	private final String Protocols = "protocols";
+	private final String Protocol = "protocol";
+	private final String Name = "name";
+	private final String UtilFactory = "utilFactory";
+	private final String MappingRules = "mapping-rules";
+	private final String Action = "mapping-rules";
+	private final String SOAPAction = "mapping-rules";
+	private final String SubscriberStores = "subscriberStores";
+	private final String SubscriberStore = "subscriberStore";
+	private final String Key = "key";
+	private final String Clazz = "class";
+	
+	public ConfigurationManager () {
+		protocolMap = new HashMap ();
+		subscriberStoreNamesMap = new HashMap ();
+	}
+	
+	/**
+	 * To load configurations from a savan-config.xml file in the classpath.
+	 * 
+	 * @throws SavanException
+	 */
+	public void configure () throws SavanException {
+		InputStream in = Thread.currentThread().getContextClassLoader().
+					getResourceAsStream(SavanConstants.CONFIG_FILE);
+
+		configure(in);
+	}
+	
+	/**
+	 * To Load configurations from a file.
+	 * 
+	 * @param file
+	 * @throws SavanException
+	 */
+	public void configure (File file) throws SavanException {
+		try {
+			InputStream in = new FileInputStream (file);
+			configure(in);
+		} catch (IOException e) {
+			throw new SavanException (e);
+		}
+	}
+	
+	/**
+	 * To load configurations from a InputStream.
+	 * 
+	 * @param in
+	 * @throws SavanException
+	 */
+	public void configure (InputStream in) throws SavanException {
+
+		if (in==null) {
+			String message = "Cant create an InputStream from the property file";
+			throw new SavanException (message);
+		}
+		
+		try {
+			XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in);
+			OMFactory factory = OMAbstractFactory.getOMFactory();
+			
+			StAXOMBuilder builder = OMXMLBuilderFactory.createStAXOMBuilder(factory,parser);
+			OMElement document = builder.getDocumentElement();
+			
+			if (document==null) {
+				throw new SavanException ("Configuration XML does not have a document element");
+			}
+			
+			processSavanConfig(document);
+		} catch (Exception e) {
+			throw new SavanException (e);
+		} 
+	}
+	
+	
+	private void processSavanConfig (OMElement element) throws SavanException {
+		if (!SavanConfig.equals(element.getLocalName())) {
+			throw new SavanException ("'savan-config'should be the document element of the savan configuration xml file");
+		}
+		
+		OMElement protocolsElement = element.getFirstChildWithName(new QName (Protocols));
+		if (protocolsElement==null) {
+			throw new SavanException ("'protocols' element should be present, as a sub-element of the 'savan-config' element");
+		}
+		processProtocols(protocolsElement);
+		
+		OMElement subscriberStoresElement = element.getFirstChildWithName(new QName (SubscriberStores));
+		if (subscriberStoresElement==null) {
+			throw new SavanException ("'subscriberStores' element should be present, as a sub-element of the 'savan-config' element");
+		}
+		processSubscriberStores(subscriberStoresElement);
+	}
+	
+	private void processProtocols (OMElement element) throws SavanException {
+		Iterator protocolElementsIterator = element.getChildrenWithName(new QName (Protocol));
+		while (protocolElementsIterator.hasNext()) {
+			OMElement protocolElement = (OMElement) protocolElementsIterator.next();
+			processProtocol(protocolElement);
+		}
+	}
+	
+	private void processProtocol (OMElement element) throws SavanException {
+		Protocol protocol = new Protocol ();
+		
+		OMElement nameElement = element.getFirstChildWithName(new QName (Name));
+		if (nameElement==null)
+			throw new SavanException ("Protocol must have a 'Name' subelement");
+		String name = nameElement.getText();
+		protocol.setName(name);
+		
+		OMElement utilFactoryNameElement = element.getFirstChildWithName(new QName (UtilFactory));
+		if (utilFactoryNameElement==null)
+			throw new SavanException ("Protocol must have a 'UtilFactory' subelement");
+		String utilFactoryName = utilFactoryNameElement.getText();
+		Object obj = getObject(utilFactoryName);
+		if (!(obj instanceof UtilFactory))
+			throw new SavanException ("UtilFactory element" + utilFactoryName + "is not a subtype of the UtilFactory class");
+		protocol.setUtilFactory((UtilFactory) obj);
+		
+		OMElement mappingRulesElement = element.getFirstChildWithName(new QName (MappingRules));
+		if (mappingRulesElement==null)
+			throw new SavanException ("Protocol must have a 'MappingRules' subelement");
+		processMappingRules (mappingRulesElement,protocol);
+		
+		protocolMap.put(protocol.getName(),protocol);
+		
+	}
+	
+	private void processMappingRules (OMElement element, Protocol protocol) {
+		
+		MappingRules mappingRules = new MappingRules ();
+		
+		Iterator actionsIterator = element.getChildrenWithName(new QName (Action));
+		while (actionsIterator.hasNext()) {
+			OMElement actionElement = (OMElement) actionsIterator.next();
+			String action = actionElement.getText();
+			mappingRules.addAction(action);
+		}
+		
+		Iterator SOAPActionsIterator = element.getChildrenWithName(new QName (SOAPAction));
+		while (SOAPActionsIterator.hasNext()) {
+			OMElement SOAPactionElement = (OMElement) SOAPActionsIterator.next();
+			String SOAPaction = SOAPactionElement.getText();
+			mappingRules.addAction(SOAPaction);
+		}
+	}
+	
+	private void processSubscriberStores (OMElement element) throws SavanException {
+		Iterator subscriberStoreElementsIterator = element.getChildrenWithName(new QName (SubscriberStore));
+		while (subscriberStoreElementsIterator.hasNext()) {
+			OMElement subscriberStoreElement = (OMElement) subscriberStoreElementsIterator.next();
+			processSubscriberStore(subscriberStoreElement);
+		}
+	}
+	
+	private void processSubscriberStore (OMElement element) throws SavanException {
+		OMElement keyElement = element.getFirstChildWithName(new QName (Key));
+		if (keyElement==null)
+			throw new SavanException ("SubscriberStore must have a 'key' subelement");
+		String key = keyElement.getText();
+		
+		OMElement classElement = element.getFirstChildWithName(new QName (Clazz));
+		if (classElement==null)
+			throw new SavanException ("SubscriberStore must have a 'Clazz' subelement'");
+		
+		String clazz = classElement.getText();
+		subscriberStoreNamesMap.put(key,clazz);
+	}
+
+	public HashMap getProtocolMap () {
+		return protocolMap;
+	}
+	
+	public HashMap getSubscriberStoreNamesMap () {
+		return subscriberStoreNamesMap;
+	}
+	
+	public SubscriberStore getSubscriberStoreInstance (String key) throws SavanException {
+		String name = (String) subscriberStoreNamesMap.get(key);
+		return (SubscriberStore) getObject(name);
+	}
+	
+	private Object getObject (String className) throws SavanException {
+	
+		Object obj;
+		try {
+			Class c = Class.forName (className);
+			 obj = c.newInstance();
+		} catch (Exception e) {
+			String message = "Can't instantiate the class:" + className;
+			throw new SavanException (message,e);
+		}
+		 
+		return obj;
+	}
+	
+}

Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/MappingRules.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/MappingRules.java?rev=419173&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/MappingRules.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/MappingRules.java Tue Jul  4 23:07:35 2006
@@ -0,0 +1,52 @@
+/*
+ * 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.configuration;
+
+import java.util.ArrayList;
+
+/**
+ *Encapsulates a date of a set of Mapping-Rules as defined by Savan configurations. 
+ *(probably from a savan-config.xml file).
+ */
+public class MappingRules {
+
+	private ArrayList actionMap = null;
+	private ArrayList SOAPActionMap = null;
+	
+	public MappingRules () {
+		actionMap = new ArrayList ();
+		SOAPActionMap = new ArrayList ();
+	}
+	
+	public void addAction (String action) {
+		actionMap.add(action);
+	}
+	
+	public boolean isActionPresent (String action) {
+		return actionMap.contains(action);
+	}
+	
+	public void addSOAPAction (String SOAPAction) {
+		SOAPActionMap.add(SOAPAction);
+	}
+	
+	public boolean isSOAPActionPresent (String SOAPAction) {
+		return SOAPActionMap.contains(SOAPAction);
+	}
+	
+}

Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/Protocol.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/Protocol.java?rev=419173&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/Protocol.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/configuration/Protocol.java Tue Jul  4 23:07:35 2006
@@ -0,0 +1,55 @@
+/*
+ * 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.configuration;
+
+import org.apache.savan.util.UtilFactory;
+
+/**
+ *Encapsulates a date of a Protocol as defined by Savan configurations. 
+ *(probably from a savan-config.xml file).
+ */
+public class Protocol {
+
+	private String name;
+	private UtilFactory utilFactory;
+	private MappingRules mappingRules;
+	
+	public String getName() {
+		return name;
+	}
+	
+	public UtilFactory getUtilFactory() {
+		return utilFactory;
+	}
+	
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	public void setUtilFactory(UtilFactory utilFactory) {
+		this.utilFactory = utilFactory;
+	}
+
+	public MappingRules getMappingRules() {
+		return mappingRules;
+	}
+
+	public void setMappingRules(MappingRules mappingRule) {
+		this.mappingRules = mappingRule;
+	}
+}

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=419173&r1=419172&r2=419173&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  4 23:07:35 2006
@@ -17,14 +17,12 @@
 
 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 = SavanConstants.FilterDialects.XPath;
+	String DEFAULT_FILTER_DIALECT = FilterDialects.XPath;
 	
 	interface TransferedProperties {
 		String SUBSCRIBER_UUID = "SAVAN_EVENTING_SUBSCRIBER_UUID";
@@ -58,5 +56,13 @@
 		String UnsubscribeResponse = "http://schemas.xmlsoap.org/ws/2004/08/eventing/UnsubscribeResponse";
 		String GetStatus = "http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus";
 		String GetStatusResponse = "http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatusResponse";
+	}
+	
+	interface Properties {
+		String SOAPVersion = "SOAPVersion";
+	}
+	
+	interface FilterDialects {
+		String XPath = "http://www.w3.org/TR/1999/REC-xpath-19991116";
 	}
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingMessageReceiverDeligater.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingMessageReceiverDeligater.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingMessageReceiverDeligater.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/EventingMessageReceiverDeligater.java Tue Jul  4 23:07:35 2006
@@ -19,23 +19,22 @@
 
 import java.util.Calendar;
 import java.util.Date;
-import java.util.HashMap;
-
 import javax.xml.namespace.QName;
-
 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.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.databinding.utils.ConverterUtil;
 import org.apache.savan.SavanConstants;
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
 import org.apache.savan.messagereceiver.MessageReceiverDeligater;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.util.CommonUtil;
 
 
 public class EventingMessageReceiverDeligater implements MessageReceiverDeligater {
@@ -90,6 +89,9 @@
 		subscribeResponseElement.addChild(subscriptionManagerElement);
 		outMessageEnvelope.getBody().addChild(subscribeResponseElement);
 		
+		//setting the message type
+		outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new Integer (SavanConstants.MessageTypes.SUBSCRIPTION_RESPONSE_MESSAGE));
+		
 	}
 	
 	public void handleRenewRequest(SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException {
@@ -127,10 +129,10 @@
 			String message = "SubscriberID TransferedProperty is not set";
 			throw new SavanException (message);
 		}
-		
-		ConfigurationContext configurationContext = renewMessage.getConfigurationContext();
-		HashMap subscribers = (HashMap) configurationContext.getProperty(SavanConstants.SUBSCRIBER_TABLE);
-		EventingSubscriber eventingSubscriber = (EventingSubscriber) subscribers.get(subscriberID);
+
+		SubscriberStore store = CommonUtil.getSubscriberStore(renewMessage.getMessageContext().getAxisService());
+		Subscriber subscriber = store.retrieve(subscriberID);
+		EventingSubscriber eventingSubscriber = (EventingSubscriber) subscriber;
 		if (eventingSubscriber==null) {
 			String message = "Cannot find the Subscriber with the given ID";
 			throw new SavanException (message);
@@ -148,6 +150,9 @@
 		}
 		
 		outMessageEnvelope.getBody().addChild(renewResponseElement);
+		
+		//setting the message type
+		outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new Integer (SavanConstants.MessageTypes.RENEW_RESPONSE_MESSAGE));
 	}
 
 	public void handleEndSubscriptionRequest(SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException {
@@ -174,7 +179,10 @@
 			} catch (AxisFault e) {
 				throw new SavanException (e);
 			}
-		}		
+		}	
+		
+		//setting the message type
+		outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new Integer (SavanConstants.MessageTypes.UNSUBSCRIPTION_RESPONSE_MESSAGE));
 	}
 
 	public void handleGetStatusRequest(SavanMessageContext getStatusMessage, MessageContext outMessage) throws SavanException {
@@ -207,36 +215,35 @@
 			}
 		}
 		
-		ConfigurationContext configurationContext = getStatusMessage.getConfigurationContext();
-		HashMap subscribers = (HashMap) configurationContext.getProperty(SavanConstants.SUBSCRIBER_TABLE);
+		SubscriberStore store = CommonUtil.getSubscriberStore(getStatusMessage.getMessageContext().getAxisService());
 		
-		if (subscribers==null) {
-			throw new SavanException ("Subscriber not found");
+		
+		if (store==null) {
+			throw new SavanException ("Subscriber Store was not found");
 		}
 		
-		EventingSubscriber subscriber = (EventingSubscriber) subscribers.get(id);
+		EventingSubscriber subscriber = (EventingSubscriber) store.retrieve(id);
 		if (subscriber==null) {
 			throw new SavanException ("Subscriber not found");
 		}
 		
 		OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,EventingConstants.EVENTING_PREFIX);
-
 		OMElement getStatusResponseElement = factory.createOMElement(EventingConstants.ElementNames.GetStatusResponse,ens);
 		
 		Date expires = subscriber.getSubscriptionEndingTime();
 		if (expires!=null) {
 			OMElement expiresElement = factory.createOMElement(EventingConstants.ElementNames.Expires,ens);
-			
 			Calendar calendar = Calendar.getInstance();
 			calendar.setTime(expires);
 			String expirationString = ConverterUtil.convertToString(calendar);
-			
 			expiresElement.setText(expirationString.toString());
-			
 			getStatusResponseElement.addChild(expiresElement);
 		}
 		
 		outMessageEnvelope.getBody().addChild(getStatusResponseElement);
+		
+		//setting the message type
+		outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new Integer (SavanConstants.MessageTypes.GET_STATUS_RESPONSE_MESSAGE));
 	}
 	
 	

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=419173&r1=419172&r2=419173&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  4 23:07:35 2006
@@ -17,29 +17,32 @@
 
 package org.apache.savan.eventing;
 
-
 import java.util.Calendar;
 import java.util.Date;
-
 import javax.xml.namespace.QName;
-
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.databinding.types.Duration;
 import org.apache.axis2.databinding.utils.ConverterUtil;
 import org.apache.axis2.util.UUIDGenerator;
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
+import org.apache.savan.configuration.Protocol;
 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;
+import org.apache.savan.util.UtilFactory;
 import org.apache.savan.util.CommonUtil;
 
 public class EventingSubscriptionProcessor extends SubscriptionProcessor {
@@ -51,21 +54,31 @@
 		if (id!=null) {
 			smc.setProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID,id);
 		}
-		
 	}
 	
 	public Subscriber getSubscriberFromMessage(SavanMessageContext smc) throws SavanException {
 
+		Protocol protocol = smc.getProtocol();
+		if (protocol==null)
+			throw new SavanException ("Protocol not found");
+		
+		UtilFactory utilFactory = protocol.getUtilFactory();
+		
 		SOAPEnvelope envelope = smc.getEnvelope();
 		if (envelope==null)
 			return null;
 		
-		EventingSubscriber subscriber = new EventingSubscriber ();  //eventing only works on leaf subscriber for now.
+		Subscriber subscriber = utilFactory.createSubscriber();  //eventing only works on leaf subscriber for now.
+		if (!(subscriber instanceof EventingSubscriber)) {
+			String message = "Eventing protocol only support EventingSubscribers (or subtypes) as Subscribers";
+			throw new SavanException (message);
+		}
 		
+		EventingSubscriber eventingSubscriber = (EventingSubscriber) subscriber;
 		String id = UUIDGenerator.getUUID();
 		smc.setProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID,id);
 	
-		subscriber.setId(id);
+		eventingSubscriber.setId(id);
 		
 		SOAPBody body = envelope.getBody();
 		OMElement subscribeElement = body.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Subscribe));
@@ -77,7 +90,7 @@
 			EndpointReference endToEPR = new EndpointReference ("");
 			endToEPR.fromOM(endToElement);
 			
-			subscriber.setEndToEPr(endToEPR);
+			eventingSubscriber.setEndToEPr(endToEPR);
 		}
 		
 		OMElement deliveryElement = subscribeElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Delivery));
@@ -103,7 +116,7 @@
 		delivery.setDeliveryEPR(notifyToEPr);
 		delivery.setDeliveryMode(deliveryMode);
 		
-		subscriber.setDelivery(delivery);
+		eventingSubscriber.setDelivery(delivery);
 		
 		OMElement expiresElement = subscribeElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Expires));
 		if (expiresElement!=null) {
@@ -131,7 +144,7 @@
 				throw new SavanException (message);
 			}
 			
-			subscriber.setSubscriptionEndingTime(expiration);
+			eventingSubscriber.setSubscriptionEndingTime(expiration);
 		}
 		
 		OMElement filterElement = subscribeElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Filter));
@@ -140,19 +153,19 @@
 			OMAttribute dialectAttr = filterElement.getAttribute(new QName (EventingConstants.ElementNames.Dialect));
 			Filter filter = null;
 			if (dialectAttr==null) {
-				filter = FilterFactory.getFilter(EventingConstants.DEFAULT_FILTER_DIALECT);
+				filter = utilFactory.createFilter (EventingConstants.DEFAULT_FILTER_DIALECT);
 			} else {
-				filter = FilterFactory.getFilter(dialectAttr.getAttributeValue());
+				filter = utilFactory.createFilter (dialectAttr.getAttributeValue());
 			}
 			if (filter==null)
 				throw new SavanException ("Cant find a suitable message filter");
 			
 			filter.setUp (filterNode);
 			
-			subscriber.setFilter(filter);
+			eventingSubscriber.setFilter(filter);
 		}
 		
-		return subscriber;
+		return eventingSubscriber;
 	}
 
 	public void pauseSubscription(SavanMessageContext pauseSubscriptionMessage) throws SavanException {
@@ -242,7 +255,22 @@
 		
 		return bean;
 	}
-	
-	
 
+	public void doProtocolSpecificEndSubscription(Subscriber subscriber, String reason, ConfigurationContext configurationContext) throws SavanException {
+		String SOAPVersion = (String) subscriber.getProperty(EventingConstants.Properties.SOAPVersion);
+		if (SOAPVersion==null) 
+			throw new SavanException ("Cant find the SOAP version of the subscriber");
+		
+		SOAPFactory factory = null;
+		if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(SOAPVersion))
+			factory = OMAbstractFactory.getSOAP11Factory();
+		else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(SOAPVersion))
+			factory = OMAbstractFactory.getSOAP12Factory();
+		else
+			throw new SavanException ("The subscriber has a unknown SOAP version property set");
+		
+		SOAPEnvelope envelope = factory.getDefaultEnvelope();
+		
+		
+	}
 }

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=419173&r1=419172&r2=419173&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  4 23:07:35 2006
@@ -20,16 +20,18 @@
 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.publication.PublicationProcessor;
+import org.apache.savan.subscribers.Subscriber;
 import org.apache.savan.subscription.SubscriptionProcessor;
-import org.apache.savan.util.SavanUtilFactory;
+import org.apache.savan.util.UtilFactory;
 
-public class EventingUtilFactory implements SavanUtilFactory {
+public class EventingUtilFactory implements UtilFactory {
 
-	public SavanMessageContext createSavanMessageContext(MessageContext messageContext) {
+	public SavanMessageContext initializeMessage(SavanMessageContext smc) {
 		
-		SavanMessageContext smc = new SavanMessageContext (messageContext);
+		MessageContext messageContext = smc.getMessageContext();
 		
 		//setting the message type.
 		String action = messageContext.getOptions().getAction();
@@ -59,14 +61,19 @@
 		return new EventingSubscriptionProcessor ();
 	}
 	
-	public PublicationProcessor createPublicationProcessor() {
-		return new EventingPublicationProcessor ();
-	}
-
 	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() {
+		return new EventingSubscriber ();
+	}
+	
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/SubscriptionResponseData.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/SubscriptionResponseData.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/SubscriptionResponseData.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/eventing/client/SubscriptionResponseData.java Tue Jul  4 23:07:35 2006
@@ -1,3 +1,20 @@
+/*
+ * 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.eventing.client;
 
 import org.apache.axis2.addressing.EndpointReference;

Modified: 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=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/Filter.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/Filter.java Tue Jul  4 23:07:35 2006
@@ -21,7 +21,32 @@
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.savan.SavanException;
 
+/**
+ * Defines a filter used by Savan. 
+ *
+ */
 public abstract class Filter {
+	
+	/**
+	 * To check weather the passed envelope is compliant with the current filter.
+	 * @param envelope
+	 * @return
+	 * @throws SavanException
+	 */
 	public abstract boolean checkEnvelopeCompliance (SOAPEnvelope envelope) throws SavanException;
+	
+	/**
+	 * To initialize the filter. The filter value should be sent to the argument
+	 * (for e.g. As a OMText for a String)
+	 * 
+	 * @param element
+	 */
 	public abstract void setUp (OMNode element);
+	
+	/**
+	 * Returns a previously set filter value.
+	 * 
+	 * @return
+	 */
+	public abstract Object getFilterValue ();
 }

Modified: 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=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/XPathBasedFilter.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/filters/XPathBasedFilter.java Tue Jul  4 23:07:35 2006
@@ -44,6 +44,10 @@
 
 import org.jaxen.JaxenException;
 
+/**
+ * A filter that does filtering of messages based on a XPath string.
+ * 
+ */
 public class XPathBasedFilter extends Filter {
 
 	private String XPathString = null;
@@ -88,4 +92,9 @@
 		XPathString = text.getText();
 	}
 
+	public Object getFilterValue() {
+		return XPathString;
+	}
+
+	
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanInHandler.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanInHandler.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/handlers/SavanInHandler.java Tue Jul  4 23:07:35 2006
@@ -19,24 +19,47 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.handlers.AbstractHandler;
 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.storage.SubscriberStore;
 import org.apache.savan.subscription.SubscriptionProcessor;
-import org.apache.savan.util.AbstractSavanUtilFactory;
+import org.apache.savan.util.UtilFactory;
 import org.apache.savan.util.ProtocolManager;
-import org.apache.savan.util.SavanUtilFactory;
-
 
+/**
+ * The handler of Savan in the InFlow.
+ * Will handle the control messages like subscription, renew, unsubscription.
+ * 
+ */
 public class SavanInHandler extends AbstractHandler  {
 
 	public void invoke(MessageContext msgContext) throws AxisFault {
 		
-		int protocolVersion = ProtocolManager.getMessageProtocol (msgContext);
-		SavanUtilFactory utilFactory = AbstractSavanUtilFactory.getUtilFactory(protocolVersion);
+		SavanMessageContext smc = new SavanMessageContext (msgContext);
+		
+		//setting the Protocol
+		Protocol protocol = ProtocolManager.getMessageProtocol(smc);
+		smc.setProtocol(protocol);
+		
+		AxisService axisService = msgContext.getAxisService();
+		if (axisService==null)
+			throw new SavanException ("Service context is null");
+		
+		//setting the Subscriber Store
+		Parameter parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
+		if (parameter==null){
+			setSubscriberStore (smc);
+			parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
+		}
 		
-		SavanMessageContext smc = utilFactory.createSavanMessageContext (msgContext); 
-		smc.setProtocolVersion(protocolVersion);
+		UtilFactory utilFactory = smc.getProtocol().getUtilFactory();
+		utilFactory.initializeMessage (smc);
 		
 		int messageType = smc.getMessageType ();
 
@@ -48,6 +71,29 @@
 			processor.unsubscribe(smc);
 		} else if (messageType==SavanConstants.MessageTypes.RENEW_MESSAGE) {
 			processor.renewSubscription(smc);
+		}
+	}
+	
+	private void setSubscriberStore (SavanMessageContext smc) throws SavanException {
+		MessageContext msgContext = smc.getMessageContext();
+		AxisService axisService = msgContext.getAxisService();
+		
+		Parameter parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE_KEY);
+		String subscriberStoreKey = SavanConstants.DEFAULT_SUBSCRIBER_STORE_KEY;
+		if (parameter!=null)
+			subscriberStoreKey = (String) parameter.getValue();
+		
+		ConfigurationManager configurationManager = (ConfigurationManager) smc.getConfigurationContext().getProperty(SavanConstants.CONFIGURATION_MANAGER);
+		SubscriberStore store = configurationManager.getSubscriberStoreInstance(subscriberStoreKey);
+
+		parameter = new Parameter ();
+		parameter.setName(SavanConstants.SUBSCRIBER_STORE);
+		parameter.setValue(store);
+		
+		try {
+			axisService.addParameter(parameter);
+		} catch (AxisFault e) {
+			throw new SavanException (e);
 		}
 		
 	}

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=419173&r1=419172&r2=419173&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 Jul  4 23:07:35 2006
@@ -1,61 +1,77 @@
 /*
-* 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 org.apache.savan.handlers;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.savan.SavanConstants;
-import org.apache.savan.SavanMessageContext;
-import org.apache.savan.publication.PublicationReport;
-import org.apache.savan.publication.PublicationProcessor;
-import org.apache.savan.util.AbstractSavanUtilFactory;
-import org.apache.savan.util.ProtocolManager;
-import org.apache.savan.util.SavanUtilFactory;
-
-public class SavanOutHandler extends AbstractHandler {
-
-	public void invoke(MessageContext msgContext) throws AxisFault {
-
-		int protocolVersion = ProtocolManager.getMessageProtocol (msgContext);
-		SavanUtilFactory utilFactory = AbstractSavanUtilFactory.getUtilFactory(protocolVersion);
-		
-		SavanMessageContext smc = utilFactory.createSavanMessageContext (msgContext); 
-		smc.setProtocolVersion(protocolVersion);
-		
-		PublicationProcessor processor = utilFactory.createPublicationProcessor();
-
-		String publicationProperty = (String) smc.getProperty(SavanConstants.PUBLICATION_MESSAGE);
-		boolean publication = false;
-		if (publicationProperty!=null && SavanConstants.VALUE_TRUE.equalsIgnoreCase(publicationProperty))
-			publication = true;
-		
-		int messagetype = smc.getMessageType();		
-		
-		if (messagetype==SavanConstants.MessageTypes.UNKNOWN) {
-			PublicationReport report = processor.notifyListners (smc);
-			
-			//TODO use the report to inform abt the errors.
-			
-			//stopping the message from going further.
-			msgContext.pause();
-		}
-		
-
-	}
-
-}
+ * 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 org.apache.savan.handlers;
+
+import java.util.Iterator;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.publication.PublicationReport;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.util.CommonUtil;
+
+/**
+ * Handler of Savan in the outFlow.
+ * Notification messages should go through this handler and this will sent them to
+ * each subscriber based on their filter.
+ * 
+ */
+public class SavanOutHandler extends AbstractHandler {
+
+	Log log = LogFactory.getLog(SavanOutHandler.class);
+	
+	public void invoke(MessageContext msgContext) throws AxisFault {
+
+		SavanMessageContext smc = new SavanMessageContext (msgContext);
+		int messagetype = smc.getMessageType();
+	
+		//TODO hv a better method to identify publication messages
+		if (messagetype == SavanConstants.MessageTypes.UNKNOWN) {
+			SavanMessageContext publication = new SavanMessageContext(msgContext);
+			SubscriberStore store = (SubscriberStore) CommonUtil.getSubscriberStore(msgContext.getAxisService());
+			if (store != null) {
+				PublicationReport report = new PublicationReport();
+				Iterator iterator = store.retrieveAll();
+				while (iterator.hasNext()) {
+					Subscriber subscriber = (Subscriber) iterator.next();
+					try {
+						subscriber.processPublication (publication, report);
+					} catch (SavanException e) {
+						report.addErrorReportEntry(subscriber.getId(),e);
+					}
+					
+					//TODO do something with the report.
+				}
+			} else {
+				String message = "Couldnt send the message since the subscriber storage was not found";
+				log.debug(message);
+				throw new SavanException (message);
+			}
+			
+			msgContext.pause();
+		}
+
+	}
+
+}

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/MessageReceiverDeligater.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/MessageReceiverDeligater.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/MessageReceiverDeligater.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/MessageReceiverDeligater.java Tue Jul  4 23:07:35 2006
@@ -21,11 +21,49 @@
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
 
-
+/**
+ * Provide abstract functions that may be done by protocols at the MessageReceiver level.
+ *
+ */
 public interface MessageReceiverDeligater {
 	
+	/**
+	 * Handles a subscription request at the MessageReceiver level.
+	 * (may possibly send a subscription response).
+	 * 
+	 * @param subscriptionMessage
+	 * @param outMessage
+	 * @throws SavanException
+	 */
 	void handleSubscriptionRequest (SavanMessageContext subscriptionMessage, MessageContext outMessage) throws SavanException ;
+	
+	/**
+	 * Handles a renew request at the MessageReceiver level.
+	 * (may possibly send a renew response)
+	 * 
+	 * @param renewMessage
+	 * @param outMessage
+	 * @throws SavanException
+	 */
 	void handleRenewRequest(SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException;
+	
+	/**
+	 * Handles an EndSubscription request at the MessageReceiver level.
+	 * (may possibly send a EndSubscription response)
+	 * 
+	 * @param renewMessage
+	 * @param outMessage
+	 * @throws SavanException
+	 */
 	void handleEndSubscriptionRequest(SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException;
+	
+	/**
+	 * Handles a GetStatus request at the MessageReceiver level.
+	 * (may possibly send a GetStatus response).
+	 * 
+	 * @param renewMessage
+	 * @param outMessage
+	 * @throws SavanException
+	 */
 	void handleGetStatusRequest (SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException;
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java Tue Jul  4 23:07:35 2006
@@ -21,6 +21,11 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.receivers.AbstractInMessageReceiver;
 
+/**
+ * InOnly message deceiver for Savan. 
+ * May get called for control messages depending on the protocol.
+ *
+ */
 public class SavanInOnlyMessageReceiver extends AbstractInMessageReceiver {
 
 	public void invokeBusinessLogic(MessageContext inMessage) throws AxisFault {

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java Tue Jul  4 23:07:35 2006
@@ -21,20 +21,30 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
 import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
-import org.apache.savan.util.AbstractSavanUtilFactory;
-import org.apache.savan.util.SavanUtilFactory;
-
+import org.apache.savan.configuration.Protocol;
+import org.apache.savan.util.UtilFactory;
 
+/**
+ * InOut message deceiver for Savan. 
+ * May get called for control messages depending on the protocol.
+ */
 public class SavanInOutMessageReceiver extends AbstractInOutSyncMessageReceiver {
 
 	public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
 
 		SavanMessageContext savanInMessage = new SavanMessageContext (inMessage);
 		
-		Integer protocolVersion = (Integer) inMessage.getProperty(SavanConstants.PROTOCOL_VERSION);
-		SavanUtilFactory utilFactory = AbstractSavanUtilFactory.getUtilFactory(protocolVersion.intValue());
+//		Integer protocolVersion = (Integer) inMessage.getProperty(SavanConstants.PROTOCOL_VERSION);
+//		UtilFactory utilFactory = AbstractSavanUtilFactory.getUtilFactory(protocolVersion.intValue());
+		
+		Protocol protocol = savanInMessage.getProtocol();
+		if (protocol==null) {
+			throw new SavanException ("Protocol not found");
+		}
 		
+		UtilFactory utilFactory = protocol.getUtilFactory();
 		MessageReceiverDeligater deligator = utilFactory.createMessageReceiverDeligater();
 
 		int messageType = savanInMessage.getMessageType();

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=419173&r1=419172&r2=419173&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  4 23:07:35 2006
@@ -22,13 +22,32 @@
 import org.apache.axis2.description.AxisDescription;
 import org.apache.axis2.description.AxisModule;
 import org.apache.axis2.modules.Module;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.configuration.ConfigurationManager;
 
+/**
+ * Savan Module class. 
+ *
+ */
 public class SavanModule implements Module  {
 
+	private static final Log log = LogFactory.getLog(SavanModule.class);
+	
 	public void engageNotify(AxisDescription axisDescription) throws AxisFault {
 	}
 
 	public void init(ConfigurationContext configContext, AxisModule module) throws AxisFault {
+		ConfigurationManager configurationManager = new ConfigurationManager ();
+		try {
+			configurationManager.configure();
+		} catch (SavanException e) {
+			log.debug("Exception thrown while trying to configure the Savan module",e);
+		}
+		
+		configContext.setProperty(SavanConstants.CONFIGURATION_MANAGER,configurationManager);
 	}
 
 	public void shutdown(ConfigurationContext configurationContext) throws AxisFault {

Modified: 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=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationReport.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/PublicationReport.java Tue Jul  4 23:07:35 2006
@@ -22,10 +22,22 @@
 
 import org.apache.savan.SavanException;
 
-
+/**
+ * This will encapsulate error information of a specific publication.
+ * Probably will contain details of each subscriber to which the message could not
+ * be delivered successfully. 
+ */
 public class PublicationReport {
 
+	/**
+	 * The susbscribers to which this msg could not be sent. Probably their ID and the
+	 * Exception that occured.
+	 */
 	private Hashtable errors = null;
+	
+	/**
+	 * Ids of the subscribers to which this msg could be sent successfully.
+	 */
 	private ArrayList notifiedSubscribers;
 	
 	public PublicationReport () {

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/client/PublicationClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/client/PublicationClient.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/client/PublicationClient.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/publication/client/PublicationClient.java Tue Jul  4 23:07:35 2006
@@ -27,11 +27,19 @@
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.savan.SavanConstants;
 import org.apache.savan.SavanException;
+import org.apache.savan.storage.SubscriberStore;
 
+/**
+ * This can be used to make the Publication Process easy.
+ * Handle things like engaging the savan module correctly and setting the
+ * correct subscriber store.
+ */
 public class PublicationClient {
-
-	public static void sendPublication (SOAPEnvelope publication,ConfigurationContext configurationContext) throws SavanException {
+	
+	public static void sendPublication (SOAPEnvelope publication,ConfigurationContext configurationContext, SubscriberStore store) throws SavanException {
 		
 		try {
 			ServiceClient sc = new ServiceClient (configurationContext,null);
@@ -41,6 +49,12 @@
 			options.setAction("UUID:TempPublicationAction");
 			sc.setOptions(options);
 			
+			//this will not be required when the 
+			Parameter parameter = new Parameter ();
+			parameter.setName(SavanConstants.SUBSCRIBER_STORE);
+			parameter.setValue(store);
+			sc.getAxisService().addParameter(parameter);
+			
 			//if already engaged, axis2 will neglect this engagement.
 			sc.engageModule( new QName("savan"));
 			
@@ -53,6 +67,9 @@
 			String message = "Could not send the publication";
 			throw new SavanException (message,e);
 		}
+	}
+	
+	public static void endSubscription (String subscriberID) {
 		
 	}
 }

Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/DefaultSubscriberStore.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/DefaultSubscriberStore.java?rev=419173&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/DefaultSubscriberStore.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/DefaultSubscriberStore.java Tue Jul  4 23:07:35 2006
@@ -0,0 +1,62 @@
+/*
+ * 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.storage;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.savan.SavanException;
+import org.apache.savan.subscribers.Subscriber;
+
+public class DefaultSubscriberStore implements SubscriberStore {
+
+	private HashMap subscriberMap = null;
+	
+	public DefaultSubscriberStore () {
+		subscriberMap = new HashMap ();
+	}
+	
+	public void init(ConfigurationContext configurationContext) throws SavanException {
+		// TODO Auto-generated method stub
+	}
+
+	public Subscriber retrieve(String id) {
+		return (Subscriber) subscriberMap.get(id);
+	}
+
+	public void store(Subscriber s) {
+		subscriberMap.put(s.getId(),s);
+	}
+
+	public void delete(String subscriberID) {
+		subscriberMap.remove(subscriberID);
+	}
+
+	public Iterator retrieveAll() {
+		ArrayList allSubscribers = new ArrayList ();
+		for (Iterator iter=subscriberMap.keySet().iterator();iter.hasNext();) {
+			Object key = iter.next();
+			allSubscribers.add(subscriberMap.get(key));
+		}
+		return allSubscribers.iterator();
+	}
+
+	
+}

Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/SubscriberStore.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/SubscriberStore.java?rev=419173&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/SubscriberStore.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/storage/SubscriberStore.java Tue Jul  4 23:07:35 2006
@@ -0,0 +1,70 @@
+/*
+ * 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 org.apache.savan.storage;
+
+import java.util.Iterator;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.savan.SavanException;
+import org.apache.savan.subscribers.Subscriber;
+
+/**
+ * Defines the Storage for storing subscribers. 
+ */
+public interface SubscriberStore {
+
+	/**
+	 * To Initialize the storage.
+	 * 
+	 * @param configurationContext
+	 * @throws SavanException
+	 */
+	void init (ConfigurationContext configurationContext) throws SavanException;
+	
+	/**
+	 * To store the subscriber.
+	 * 
+	 * @param s
+	 * @throws SavanException
+	 */
+	void store (Subscriber s) throws SavanException;
+	
+	/**
+	 * To retrieve a previously stored subscriber.
+	 * 
+	 * @param subscriberID
+	 * @return
+	 * @throws SavanException
+	 */
+	Subscriber retrieve (String subscriberID) throws SavanException;
+	
+	/**
+	 * To retrieve all subscribers stored upto now.
+	 * 
+	 * @return
+	 * @throws SavanException
+	 */
+	Iterator retrieveAll () throws SavanException;
+	
+	/**
+	 * To delete a previously stored subscriber.
+	 * 
+	 * @param subscriberID
+	 * @throws SavanException
+	 */
+	void delete (String subscriberID) throws SavanException;
+}

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=419173&r1=419172&r2=419173&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 Jul  4 23:07:35 2006
@@ -25,7 +25,10 @@
 import org.apache.savan.publication.PublicationReport;
 import org.apache.savan.subscription.ExpirationBean;
 
-
+/**
+ * Defines a set of subscribers that are acting as a group or a Topic.
+ *
+ */
 public class CompositeSubscriber extends Subscriber {
 
 	ArrayList subscribers = null;

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=419173&r1=419172&r2=419173&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 Jul  4 23:07:35 2006
@@ -26,9 +26,16 @@
 import org.apache.savan.subscription.ExpirationBean;
 import org.apache.savan.util.CommonUtil;
 
-
+/**
+ *Defines a single node subscriber. 
+ *
+ */
 public abstract class LeafSubscriber extends Subscriber {
 	
+	/**
+	 * The time at which further notification of messages should be avaoded
+	 * to this subscriber.
+	 */
 	private Date subscriptionEndingTime = null;
 	
 	public void renewSubscription (ExpirationBean bean) {

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=419173&r1=419172&r2=419173&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 Jul  4 23:07:35 2006
@@ -18,6 +18,7 @@
 package org.apache.savan.subscribers;
 
 import java.util.Date;
+import java.util.HashMap;
 
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.savan.SavanException;
@@ -26,10 +27,28 @@
 import org.apache.savan.publication.PublicationReport;
 import org.apache.savan.subscription.ExpirationBean;
 
+/**
+ * Defines a subscriber which is the entity that define a specific subscription 
+ * in savan. Independent of the protocol type.
+ *
+ */
 public abstract class Subscriber {
 
 	String id;
 	Filter filter = null;
+	HashMap properties = null;
+	
+	public Subscriber () {
+		properties = new HashMap ();
+	}
+	
+	public void addProperty (String key, Object value) {
+		properties.put(key,value);
+	}
+	
+	public Object getProperty (String key) {
+		return properties.get(key);
+	}
 	
 	public Filter getFilter() {
 		return filter;
@@ -82,5 +101,5 @@
 	 * @param report
 	 * @throws SavanException
 	 */
-	public abstract void sendPublication (SavanMessageContext publication,PublicationReport report) throws SavanException;
+	protected abstract void sendPublication (SavanMessageContext publication,PublicationReport report) throws SavanException;
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/ExpirationBean.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/ExpirationBean.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/ExpirationBean.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/ExpirationBean.java Tue Jul  4 23:07:35 2006
@@ -21,6 +21,9 @@
 
 import org.apache.axis2.databinding.types.Duration;
 
+/**
+ * Defines a expiration. Could be based on a specific time in the future or a duration.
+ */
 public class ExpirationBean {
 
 	Date dateValue;

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/RenewBean.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/RenewBean.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/RenewBean.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/RenewBean.java Tue Jul  4 23:07:35 2006
@@ -17,6 +17,9 @@
 
 package org.apache.savan.subscription;
 
+/**
+ * Encapsulates a data for a subscrpition renewal.
+ */
 public class RenewBean {
 
 	long renewMount;

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/SubscriptionProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/SubscriptionProcessor.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/SubscriptionProcessor.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/SubscriptionProcessor.java Tue Jul  4 23:07:35 2006
@@ -17,44 +17,43 @@
 
 package org.apache.savan.subscription;
 
-import java.util.HashMap;
 import org.apache.axis2.context.ConfigurationContext;
-import org.apache.savan.SavanConstants;
+import org.apache.axis2.context.ServiceContext;
 import org.apache.savan.SavanException;
 import org.apache.savan.SavanMessageContext;
+import org.apache.savan.storage.SubscriberStore;
 import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.util.CommonUtil;
 
+/**
+ * Abstractly defines subscription methods.
+ * Each protocol may extend this to add its own work.
+ */
 public abstract class SubscriptionProcessor {
 	
 	public abstract void init (SavanMessageContext smc) throws SavanException;
 	
 	public void unsubscribe(SavanMessageContext endSubscriptionMessage)  throws SavanException {
-		ConfigurationContext configurationContext = endSubscriptionMessage.getConfigurationContext();
-		HashMap subscribers = (HashMap) configurationContext.getProperty(SavanConstants.SUBSCRIBER_TABLE);
-		if (subscribers==null) {
-			subscribers = new HashMap ();
-			configurationContext.setProperty(SavanConstants.SUBSCRIBER_TABLE,subscribers);
-		}
-		
 		String subscriberID = getSubscriberID (endSubscriptionMessage);
 		if (subscriberID==null) {
 			String message = "Cannot find the subscriber ID";
 			throw new SavanException (message);
 		}
 		
-		subscribers.remove(subscriberID);
+		SubscriberStore store = endSubscriptionMessage.getSubscriberStore();
+		if (store==null)
+			throw new SavanException ("Subscriber store not found");
+		
+		store.delete (subscriberID);
 	}
 
 	public void renewSubscription(SavanMessageContext renewMessage)  throws SavanException {
-
-		ConfigurationContext configurationContext = renewMessage.getConfigurationContext();
-		HashMap subscribers = (HashMap) configurationContext.getProperty(SavanConstants.SUBSCRIBER_TABLE);
-		if (subscribers==null) {
-			throw new SavanException ("Given subscriber is not present");
-		}
+		SubscriberStore store = renewMessage.getSubscriberStore();
+		if (store==null)
+			throw new SavanException ("Subscriber store not found");
 			
 		ExpirationBean bean = getExpirationBean(renewMessage);
-		Subscriber subscriber = (Subscriber) subscribers.get(bean.getSubscriberID());
+		Subscriber subscriber = (Subscriber) store.retrieve(bean.getSubscriberID());
 		if (subscriber==null) {
 			throw new SavanException ("Given subscriber is not present");
 		}
@@ -63,15 +62,28 @@
 	}
 
 	public void subscribe(SavanMessageContext subscriptionMessage) throws SavanException {
-		ConfigurationContext configurationContext = subscriptionMessage.getConfigurationContext();
-		HashMap subscribers = (HashMap) configurationContext.getProperty(SavanConstants.SUBSCRIBER_TABLE);
-		if (subscribers==null) {
-			subscribers = new HashMap ();
-			configurationContext.setProperty(SavanConstants.SUBSCRIBER_TABLE,subscribers);
-		}
+		SubscriberStore store = subscriptionMessage.getSubscriberStore();
+		if (store==null)
+			throw new SavanException ("Subscriber store not found");
+			
+		if (store==null)
+			throw new SavanException ("Sabscriber store not found");
 		
 		Subscriber subscriber = getSubscriberFromMessage (subscriptionMessage);
-		subscribers.put(subscriber.getId(),subscriber);
+		store.store (subscriber);
+	}
+	
+	public void endSubscription(String subscriberID,String reason,ServiceContext serviceContext)  throws SavanException {
+		
+		SubscriberStore store =CommonUtil.getSubscriberStore(serviceContext.getAxisService());
+		if (store==null) {
+			//TODO do something
+		}
+		
+		Subscriber subscriber = store.retrieve(subscriberID);
+		doProtocolSpecificEndSubscription(subscriber,reason,serviceContext.getConfigurationContext());
+		
+		store.delete(subscriberID);
 	}
 	
 	public abstract void pauseSubscription (SavanMessageContext pauseSubscriptionMessage) throws SavanException;
@@ -83,5 +95,7 @@
 	public abstract ExpirationBean getExpirationBean (SavanMessageContext renewMessage) throws SavanException;
 	
 	public abstract String getSubscriberID (SavanMessageContext smc) throws SavanException;
+	
+	public abstract void doProtocolSpecificEndSubscription (Subscriber subscriber,String reason,ConfigurationContext configurationContext) throws SavanException;
 
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/CommonUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/CommonUtil.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/CommonUtil.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/CommonUtil.java Tue Jul  4 23:07:35 2006
@@ -31,7 +31,14 @@
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.apache.axis2.databinding.types.Duration;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.storage.SubscriberStore;
 
+/**
+ * A common set of methods that may be used in various places of Savan.
+ */
 public class CommonUtil {
 
 	public static Calendar addDurationToCalendar (Calendar calendar,Duration duration) {
@@ -72,5 +79,13 @@
 			return true;
 		
 		return false;
+	}
+	
+	public static SubscriberStore getSubscriberStore (AxisService axisService) {
+		Parameter parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
+		if (parameter==null)
+			return null;
+		
+		return (SubscriberStore) parameter.getValue();
 	}
 }

Modified: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/ProtocolManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/ProtocolManager.java?rev=419173&r1=419172&r2=419173&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/ProtocolManager.java (original)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/ProtocolManager.java Tue Jul  4 23:07:35 2006
@@ -17,15 +17,27 @@
 
 package org.apache.savan.util;
 
-import org.apache.axis2.context.MessageContext;
 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;
 
-
+/**
+ * Utility class to extract the Protocol type from a MessageContext
+ */
 public class ProtocolManager {
 
-	public static int getMessageProtocol (MessageContext messageContext) {
-		//TODO to this depending on the message
-		return SavanConstants.PROTOCOL_EVENTING;
+	public static Protocol getMessageProtocol (SavanMessageContext smc) throws SavanException {
+		//TODO to this depending on Protocol rules. //TODO make this algorithm efficient
+		
+		ConfigurationManager configurationManager = (ConfigurationManager) smc.getConfigurationContext().getProperty(SavanConstants.CONFIGURATION_MANAGER);
+		if (configurationManager==null)
+			throw new SavanException ("Cant find the Configuration Manager");
+		
+		Protocol protocol = (Protocol) configurationManager.getProtocolMap().get("eventing");
+		
+		return protocol;
 	}
 	
 }

Added: 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=419173&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/UtilFactory.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/UtilFactory.java Tue Jul  4 23:07:35 2006
@@ -0,0 +1,39 @@
+/*
+ * 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.util;
+
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.messagereceiver.MessageReceiverDeligater;
+import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.subscription.SubscriptionProcessor;
+
+/**
+ * Defines a Utility Factory in Savan. Each Protocol will provide its own set of 
+ * utilities.
+ * These utilities will be used in various levels in Savan.
+ */
+public interface UtilFactory {
+	
+	public abstract SavanMessageContext initializeMessage (SavanMessageContext messageContext);
+	public abstract SubscriptionProcessor createSubscriptionProcessor ();
+	public abstract MessageReceiverDeligater createMessageReceiverDeligater ();
+	public abstract Filter createFilter (String dialect);
+	public abstract Subscriber createSubscriber ();
+	
+}



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