This is an automated email from the ASF dual-hosted git repository.

billblough pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-savan.git

commit 9894fb2237ea3c78ad35d43c2fe9d36b2c37f7dc
Author: Hemapani Srinath Perera <hemap...@apache.org>
AuthorDate: Wed May 23 10:23:33 2007 +0000

    initial version for the Savan Atom support
---
 modules/core/pom.xml                               |  39 +++
 modules/core/src/main/config/savan-config.xml      |  15 +
 .../java/org/apache/savan/atom/AtomConstants.java  |  70 ++++
 .../org/apache/savan/atom/AtomEventingClient.java  |  78 +++++
 .../savan/atom/AtomMessageReceiverDeligater.java   | 274 ++++++++++++++++
 .../java/org/apache/savan/atom/AtomSubscriber.java | 126 +++++++
 .../savan/atom/AtomSubscriptionProcessor.java      | 363 +++++++++++++++++++++
 .../org/apache/savan/atom/AtomUtilFactory.java     |  70 ++++
 .../src/main/java/org/apache/savan/atom/Feed.java  | 110 +++++++
 .../java/org/apache/savan/util/CommonUtil.java     |   8 +
 modules/mar/module.xml                             |   5 +-
 pom.xml                                            |   7 +
 12 files changed, 1164 insertions(+), 1 deletion(-)

diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 3ba8b93..0dd4d8c 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -31,6 +31,45 @@
                     <target>1.4</target>
                 </configuration>
             </plugin>
+<plugin>
+               <groupId>org.apache.maven.plugins</groupId>
+               <artifactId>maven-antrun-plugin</artifactId>
+               <version>1.1</version>
+               <executions>
+                   <execution>
+                       <id>generate-sources</id>
+                       <phase>generate-sources</phase>
+                       <configuration>
+                           <tasks>
+                              <property name="schema.out" 
value="target/tmp/schema"  />
+                                                       <mkdir 
dir="${schema.out}"/>
+                                                       <mkdir 
dir="${schema.out}/src"/>
+                                                       <taskdef name="xmlbean" 
classname="org.apache.xmlbeans.impl.tool.XMLBean">
+                                                 <classpath 
refid="maven.dependency.classpath"/>
+                              <classpath refid="maven.compile.classpath"/>
+                              <classpath refid="maven.runtime.classpath"/>
+                                                       </taskdef>
+                                                                    
+                                                       <xmlbean debug="true" 
download="true"
+                                                    
srcgendir="${schema.out}/src"
+                                                    srconly="false"
+                                                    
typesystemname="intercepter"
+                                                            
destfile="${schema.out}/savan_types-0.1.jar">
+
+                                                 <classpath 
refid="maven.dependency.classpath"/>
+                              <classpath refid="maven.compile.classpath"/>
+                              <classpath refid="maven.runtime.classpath"/>
+                                                 <fileset 
dir="src/main/resources/" includes="*"/>
+                                               </xmlbean>
+                                               <unzip dest="target/classes" 
src="${schema.out}/savan_types-0.1.jar"></unzip>
+                           </tasks>
+                       </configuration>
+                       <goals>
+                           <goal>run</goal>
+                       </goals>
+                   </execution>
+               </executions>
+           </plugin>            
         </plugins>
     </build>
 
diff --git a/modules/core/src/main/config/savan-config.xml 
b/modules/core/src/main/config/savan-config.xml
index f3e5760..484aae9 100644
--- a/modules/core/src/main/config/savan-config.xml
+++ b/modules/core/src/main/config/savan-config.xml
@@ -21,6 +21,17 @@
                </parameters>
                -->
         </protocol>
+               <protocol>
+               <name>atom</name>
+               <utilFactory>org.apache.savan.atom.AtomUtilFactory</utilFactory>
+               <mapping-rules>
+                <action>http://wso2.com/eventing/Subscribe</action>
+                <action>http://wso2.com/eventing/Renew</action>
+                <action>http://wso2.com/eventing/Unsubscribe</action>
+               </mapping-rules>
+               <defaultSubscriber>atom-subscriber</defaultSubscriber>
+               <defaultFilter>empty</defaultFilter>
+        </protocol>        
     </protocols>
     
     <subscriberStores>
@@ -48,6 +59,10 @@
                <name>eventing</name>
                
<class>org.apache.savan.eventing.subscribers.EventingSubscriber</class>
        </subscriber>
+               <subscriber>
+               <name>atom-subscriber</name>
+               <class>org.apache.savan.atom.AtomSubscriber</class>
+       </subscriber>           
     </subscribers>
     
 </savan-config>
\ No newline at end of file
diff --git 
a/modules/core/src/main/java/org/apache/savan/atom/AtomConstants.java 
b/modules/core/src/main/java/org/apache/savan/atom/AtomConstants.java
new file mode 100644
index 0000000..851dcc3
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomConstants.java
@@ -0,0 +1,70 @@
+
+package org.apache.savan.atom;
+
+public class AtomConstants {
+       public static String ATOM_NAMESPACE = "http://www.w3.org/2005/Atom";;
+       public static String ATOM_PREFIX = "atom";
+       
+       public static String ATOM_MSG_NAMESPACE = 
"http://wso2.com/eventing/atom/";;
+       
+       public static String ENDTO_ELEMENT = "EndTo";
+       public static String EXPIRES_ELEMENT = "Expires";
+       public static String FILTER_ELEMENT = "Filter";
+       public static String TITLE_ELEMENT = "title";
+       public static String ID_ELEMENT = "id";
+       public static String AUTHOR_ELEMENT = "author";
+       public static String DIALECT_ELEMENT = "Dialect";
+       
+       public static String RENEW_FEED = "renewFeed";
+       public static String IDEDNTIFIER_ELEMENT = "Identifier";
+       
+       public static String DEFAULT_FILTER_IDENTIFIER = FilterDialects.XPath;
+       
+       interface FilterDialects {
+               String XPath = "http://www.w3.org/TR/1999/REC-xpath-19991116";;
+       }
+       
+       
+       interface Actions {
+               String Subscribe = "http://wso2.com/eventing/Subscribe";;
+               String SubscribeResponse = 
"http://wso2.com/eventing/SubscribeResponse";;
+               String Renew = "http://wso2.com/eventing/Renew";;
+               String RenewResponse = "http://wso2.com/eventing/RenewResponse";;
+               String Unsubscribe = "http://wso2.com/eventing/Unsubscribe";;
+               String UnsubscribeResponse = 
"http://wso2.com/eventing/UnsubscribeResponse";;
+               String GetStatus = "http://wso2.com/eventing/GetStatus";;
+               String GetStatusResponse = 
"http://wso2.com/eventing/GetStatusResponse";;
+       }
+       
+       interface TransferedProperties {
+               String SUBSCRIBER_UUID = "SAVAN_EVENTING_SUBSCRIBER_UUID";
+       }
+       
+       interface ElementNames {
+               String Subscribe = "Subscribe";
+               String EndTo = "EndTo";
+               String Delivery = "Delivery";
+               String Mode = "Mode";
+               String NotifyTo = "NotifyTo";
+               String Expires = "Expires";
+               String Filter = "Filter";
+               String Dialect = "Dialect";
+               String SubscribeResponse = "SubscribeResponse";
+               String SubscriptionManager = "SubscriptionManager";
+               String Renew = "Renew";
+               String RenewResponse = "RenewResponse";
+               String Identifier = "Identifier";
+               String Unsubscribe = "Unsubscribe";
+               String GetStatus = "GetStatus";
+               String GetStatusResponse = "GetStatusResponse";
+               String FeedUrl = "FeedUrl";
+               
+               String deleteFeedResponse = "DeleteFeedResponse";
+       }
+       
+       interface Properties {
+               String SOAPVersion = "SOAPVersion";
+               String feedUrl = "feedUrl";
+       }
+       
+}
diff --git 
a/modules/core/src/main/java/org/apache/savan/atom/AtomEventingClient.java 
b/modules/core/src/main/java/org/apache/savan/atom/AtomEventingClient.java
new file mode 100644
index 0000000..46ff65f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomEventingClient.java
@@ -0,0 +1,78 @@
+package org.apache.savan.atom;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.savan.util.CommonUtil;
+import org.apache.xmlbeans.XmlException;
+
+import com.wso2.eventing.atom.CreateFeedDocument;
+import com.wso2.eventing.atom.CreateFeedResponseDocument;
+import com.wso2.eventing.atom.CreateFeedDocument.CreateFeed;
+import com.wso2.eventing.atom.CreateFeedResponseDocument.CreateFeedResponse;
+
+public class AtomEventingClient {
+       private ServiceClient serviceClient = null;
+       private EndpointReference feedEpr;
+       
+       public AtomEventingClient(ServiceClient serviceClient){
+               this.serviceClient = serviceClient;
+       }
+       public CreateFeedResponse createFeed(String title,String author) throws 
AxisFault{
+               try {
+                       
serviceClient.getOptions().setAction(AtomConstants.Actions.Subscribe);
+                       
+                       CreateFeedDocument createFeedDocument = 
CreateFeedDocument.Factory.newInstance();
+                       CreateFeed createFeed = 
createFeedDocument.addNewCreateFeed();
+                       
+                       createFeed.setAuthor(author);
+                       createFeed.setTitle(title);
+                       //createFeed.setId("foo");
+                       
+                       OMElement request = CommonUtil.toOM(createFeedDocument);
+                       request.build();
+                       OMElement element = serviceClient.sendReceive(request);
+                       CreateFeedResponseDocument createFeedResponseDocument = 
CreateFeedResponseDocument.Factory.parse(element.getXMLStreamReader());
+                       System.out.println(createFeedDocument.xmlText());
+
+                       //read epr for subscription from response and store it
+                       OMElement responseAsOM = 
CommonUtil.toOM(createFeedResponseDocument);
+                       OMElement eprAsOM = 
responseAsOM.getFirstChildWithName(new 
QName(AtomConstants.ATOM_MSG_NAMESPACE,"SubscriptionManager"));
+                       
+                       feedEpr = new 
EndpointReference(eprAsOM.getFirstElement().getText());
+                       OMElement referanceParameters = 
eprAsOM.getFirstChildWithName(new 
QName(eprAsOM.getFirstElement().getNamespace().getNamespaceURI(),
+                                       
AddressingConstants.EPR_REFERENCE_PARAMETERS));
+                       Iterator refparams = 
referanceParameters.getChildElements();
+                       while(refparams.hasNext()){
+                               
feedEpr.addReferenceParameter((OMElement)refparams.next());     
+                       }
+                       
+                       return 
createFeedResponseDocument.getCreateFeedResponse();
+               } catch (XmlException e) {
+                       throw new AxisFault(e);
+               } 
+       }
+       
+       public void deleteFeed(EndpointReference epr)throws AxisFault{
+               
serviceClient.getOptions().setAction(AtomConstants.Actions.Unsubscribe);
+               serviceClient.getOptions().setTo(epr);
+               
+               OMElement request = 
OMAbstractFactory.getOMFactory().createOMElement(new 
QName(AtomConstants.ATOM_MSG_NAMESPACE,"DeleteFeed"));
+               serviceClient.sendReceive(request);
+       }
+       
+       public void deleteFeed()throws AxisFault{
+               if(feedEpr != null){
+                       deleteFeed(feedEpr);
+               }else{
+                       throw new AxisFault("No feed epr alreday stored, you 
must have create a feed using same AtomEventingClient Object");
+               }
+       }
+}
diff --git 
a/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiverDeligater.java
 
b/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiverDeligater.java
new file mode 100644
index 0000000..ecf9d96
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiverDeligater.java
@@ -0,0 +1,274 @@
+/*
+ * 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.atom;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPProcessingException;
+import org.apache.axis2.AxisFault;
+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;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.w3.x2005.x08.addressing.EndpointReferenceType;
+
+import com.wso2.eventing.atom.CreateFeedResponseDocument;
+import com.wso2.eventing.atom.RenewFeedResponseDocument;
+import com.wso2.eventing.atom.CreateFeedResponseDocument.CreateFeedResponse;
+
+
+public class AtomMessageReceiverDeligater extends MessageReceiverDeligater {
+       private SOAPEnvelope findOrCreateSoapEnvelope(SavanMessageContext 
subscriptionMessage, MessageContext outMessage) throws AxisFault{
+               MessageContext subscriptionMsgCtx = 
subscriptionMessage.getMessageContext();
+               
+               SOAPEnvelope outMessageEnvelope = outMessage.getEnvelope();
+               SOAPFactory factory = null;
+               
+               if (outMessageEnvelope!=null) {
+                       factory = (SOAPFactory) 
outMessageEnvelope.getOMFactory();
+               } else {
+                       factory = (SOAPFactory) 
subscriptionMsgCtx.getEnvelope().getOMFactory();
+                       outMessageEnvelope = factory.getDefaultEnvelope();
+                       outMessage.setEnvelope(outMessageEnvelope);
+               }
+               return outMessageEnvelope;
+       }
+       
+       
+
+       public void handleSubscriptionRequest(SavanMessageContext 
subscriptionMessage, MessageContext outMessage) throws SavanException {
+               try {
+                       if (outMessage != null){
+                               MessageContext subscriptionMsgCtx = 
subscriptionMessage.getMessageContext();
+                               
+                               SOAPEnvelope outMessageEnvelope = 
findOrCreateSoapEnvelope(subscriptionMessage, outMessage);
+                               //setting the action
+                               
outMessage.getOptions().setAction(AtomConstants.Actions.SubscribeResponse);
+
+                               CreateFeedResponseDocument 
createFeedResponseDocument = CreateFeedResponseDocument.Factory.newInstance();
+                               CreateFeedResponse createFeedResponse = 
createFeedResponseDocument.addNewCreateFeedResponse();
+                               EndpointReferenceType savenEpr = 
createFeedResponse.addNewSubscriptionManager();
+                               
savenEpr.addNewAddress().setStringValue(subscriptionMsgCtx.getOptions().getTo().getAddress());
+                               
+                               String id = (String) 
subscriptionMessage.getProperty(AtomConstants.TransferedProperties.SUBSCRIBER_UUID);
+                               if (id != null){
+                                       XmlCursor c = 
savenEpr.addNewReferenceParameters().newCursor();
+                                       c.toNextToken();
+                                       addNameValuePair(c,new 
QName(AtomConstants.ATOM_NAMESPACE,AtomConstants.ElementNames.Identifier), id); 
 
+                               }else{
+                                       throw new SavanException ("Subscription 
UUID is not set");
+                               }
+                               
+//                             HttpServletRequest request = 
(HttpServletRequest) 
subscriptionMessage.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
+//                             request.getServerPort()
+                               
+                               
+                               
+                               
createFeedResponse.setFeedUrl((String)subscriptionMessage.getProperty(AtomConstants.Properties.feedUrl));
+                               
outMessageEnvelope.getBody().addChild(CommonUtil.toOM(createFeedResponseDocument));
+                       }else{
+                               throw new SavanException ("Eventing protocol 
need to sent the SubscriptionResponseMessage. But the outMessage is null");
+                       }
+                       //setting the message type
+                       outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new 
Integer (SavanConstants.MessageTypes.SUBSCRIPTION_RESPONSE_MESSAGE));
+               } catch (SOAPProcessingException e) {
+                       throw new SavanException(e);
+               } catch (AxisFault e) {
+                       throw new SavanException(e);
+               } catch (OMException e) {
+                       throw new SavanException(e);
+               }
+       }
+       
+       public void handleRenewRequest(SavanMessageContext renewMessage, 
MessageContext outMessage) throws SavanException {
+               
+               try {
+                       if (outMessage==null)
+                               throw new SavanException ("Eventing protocol 
need to sent the SubscriptionResponseMessage. But the outMessage is null");
+                       
+                       SOAPEnvelope outMessageEnvelope = 
findOrCreateSoapEnvelope(renewMessage, outMessage);
+                       RenewFeedResponseDocument renewFeedResponseDocument = 
RenewFeedResponseDocument.Factory.newInstance();
+                       
+                       
+                       //setting the action
+                       
outMessage.getOptions().setAction(AtomConstants.Actions.RenewResponse);
+                       String subscriberID = (String) 
renewMessage.getProperty(AtomConstants.TransferedProperties.SUBSCRIBER_UUID);
+                       if (subscriberID==null) {
+                               String message = "SubscriberID 
TransferedProperty is not set";
+                               throw new SavanException (message);
+                       }
+
+                       SubscriberStore store = 
CommonUtil.getSubscriberStore(renewMessage.getMessageContext().getAxisService());
+                       Subscriber subscriber = store.retrieve(subscriberID);
+                       AtomSubscriber atomSubscriber = (AtomSubscriber) 
subscriber;
+                       if (atomSubscriber==null) {
+                               String message = "Cannot find the 
AbstractSubscriber with the given ID";
+                               throw new SavanException (message);
+                       }
+                       
+                       Date expiration = 
atomSubscriber.getSubscriptionEndingTime();
+                       Calendar calendar = Calendar.getInstance();
+                       calendar.setTime(expiration);
+                       
renewFeedResponseDocument.addNewRenewFeedResponse().setExpires(calendar);
+                       
outMessageEnvelope.getBody().addChild(CommonUtil.toOM(renewFeedResponseDocument));
+                       //setting the message type
+                       outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new 
Integer (SavanConstants.MessageTypes.RENEW_RESPONSE_MESSAGE));
+               } catch (AxisFault e) {
+                       throw new SavanException(e);
+               }
+       }
+
+       public void handleEndSubscriptionRequest(SavanMessageContext 
renewMessage, MessageContext outMessage) throws SavanException {
+               try {
+                       if (outMessage==null)
+                               throw new SavanException ("Eventing protocol 
need to sent the SubscriptionResponseMessage. But the outMessage is null");
+                       //setting the action
+                       
outMessage.getOptions().setAction(AtomConstants.Actions.UnsubscribeResponse);
+                       SOAPEnvelope outMessageEnvelope = 
findOrCreateSoapEnvelope(renewMessage, outMessage);
+                       
outMessageEnvelope.getBody().addChild(OMAbstractFactory.getOMFactory().createOMElement(new
 
QName(AtomConstants.ATOM_MSG_NAMESPACE,AtomConstants.ElementNames.deleteFeedResponse)));
+                       outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new 
Integer (SavanConstants.MessageTypes.UNSUBSCRIPTION_RESPONSE_MESSAGE));
+               } catch (AxisFault e) {
+                       throw new SavanException(e);
+               } catch (OMException e) {
+                       throw new SavanException(e);
+               }
+       }
+
+       public void handleGetStatusRequest(SavanMessageContext 
getStatusMessage, MessageContext outMessage) throws SavanException {
+
+               if (outMessage==null)
+                       throw new SavanException ("Eventing protocol need to 
sent the SubscriptionResponseMessage. But the outMessage is null");
+               
+               MessageContext subscriptionMsgCtx = 
getStatusMessage.getMessageContext();
+               
+               String id = (String) 
getStatusMessage.getProperty(AtomConstants.TransferedProperties.SUBSCRIBER_UUID);
+               if (id==null)
+                       throw new SavanException ("Cannot fulfil request. 
AbstractSubscriber ID not found");
+               
+               //setting the action
+               
outMessage.getOptions().setAction(AtomConstants.Actions.UnsubscribeResponse);
+               
+               SOAPEnvelope outMessageEnvelope = outMessage.getEnvelope();
+               SOAPFactory factory = null;
+               
+               if (outMessageEnvelope!=null) {
+                       factory = (SOAPFactory) 
outMessageEnvelope.getOMFactory();
+               } else {
+                       factory = (SOAPFactory) 
subscriptionMsgCtx.getEnvelope().getOMFactory();
+                       outMessageEnvelope = factory.getDefaultEnvelope();
+                       
+                       try {
+                               outMessage.setEnvelope(outMessageEnvelope);
+                       } catch (AxisFault e) {
+                               throw new SavanException (e);
+                       }
+               }
+               
+               SubscriberStore store = 
CommonUtil.getSubscriberStore(getStatusMessage.getMessageContext().getAxisService());
+               
+               
+               if (store==null) {
+                       throw new SavanException ("AbstractSubscriber Store was 
not found");
+               }
+               
+               AtomSubscriber subscriber = (AtomSubscriber) store.retrieve(id);
+               if (subscriber==null) {
+                       throw new SavanException ("AbstractSubscriber not 
found");
+               }
+               
+               OMNamespace ens = 
factory.createOMNamespace(AtomConstants.ATOM_NAMESPACE,AtomConstants.ATOM_PREFIX);
+               OMElement getStatusResponseElement = 
factory.createOMElement(AtomConstants.ElementNames.GetStatusResponse,ens);
+               
+               Date expires = subscriber.getSubscriptionEndingTime();
+               if (expires!=null) {
+                       OMElement expiresElement = 
factory.createOMElement(AtomConstants.ElementNames.Expires,ens);
+                       Calendar calendar = Calendar.getInstance();
+                       calendar.setTime(expires);
+                       String expirationString = 
ConverterUtil.convertToString(calendar);
+                       expiresElement.setText(expirationString);
+                       getStatusResponseElement.addChild(expiresElement);
+               }
+               
+               outMessageEnvelope.getBody().addChild(getStatusResponseElement);
+               
+               //setting the message type
+               outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new Integer 
(SavanConstants.MessageTypes.GET_STATUS_RESPONSE_MESSAGE));
+       }
+       public static void addNameValuePair(XmlCursor c,QName name,Object 
value){
+        c.beginElement(name);
+        
+        if(value instanceof String){
+            c.insertChars((String)value);
+        }else {
+            //Make sure this works, code is taken from
+            //http://xmlbeans.apache.org/docs/2.0.0/guide/conHandlingAny.html
+            XmlCursor cc = ((XmlObject)value).newCursor();
+            cc.toFirstContentToken();
+            cc.copyXml(c);
+            cc.dispose();
+        }
+        c.toParent();
+    }
+       
+       
+
+
+
+       public void doProtocolSpecificProcessing(SavanMessageContext 
inSavanMessage, MessageContext outMessage) throws SavanException {
+               int msgtype = 
((Integer)inSavanMessage.getProperty(SavanConstants.MESSAGE_TYPE)).intValue();
+               switch(msgtype){
+                       case SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE:
+                               handleSubscriptionRequest(inSavanMessage, 
outMessage);
+                               break;
+                       case SavanConstants.MessageTypes.RENEW_MESSAGE:
+                               handleRenewRequest(inSavanMessage, outMessage);
+                               break;
+                       case SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE:
+                               handleEndSubscriptionRequest(inSavanMessage, 
outMessage);
+                               break;
+                       default:
+                               throw new SavanException("Unknow Message type 
["+msgtype+ "]");
+               }
+       }
+
+
+
+       public void doProtocolSpecificProcessing(SavanMessageContext 
inSavanMessage) throws SavanException {
+               // TODO Auto-generated method stub
+               
+       }
+       
+       
+
+}
diff --git 
a/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriber.java 
b/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriber.java
new file mode 100644
index 0000000..77b6352
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriber.java
@@ -0,0 +1,126 @@
+package org.apache.savan.atom;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Date;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.savan.SavanException;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.subscription.ExpirationBean;
+import org.w3.x2005.x08.addressing.EndpointReferenceType;
+
+public class AtomSubscriber implements Subscriber{
+       private static final Log log = LogFactory.getLog(AtomSubscriber.class);
+       private Date subscriptionEndingTime = null;
+       private Feed feed; 
+       private Filter filter = null;
+       private File atomFile;
+       private String feedUrl;
+       
+       private URI id;
+       private String title;
+       private String author;
+       public URI getId() {
+               return id;
+       }
+       public void renewSubscription(ExpirationBean bean) {
+               throw new UnsupportedOperationException();
+       }
+       public void sendEventData(OMElement eventData) throws SavanException {
+               try {
+                       Date date = new Date ();
+                       
+                       boolean expired = false;
+                       if (subscriptionEndingTime!=null && 
date.after(subscriptionEndingTime))
+                               expired = true;
+                       
+                       if (expired) {
+                               String message = "Cant notify the listner since 
the subscription has been expired";
+                               log.debug(message);
+                       }
+                       if(feed == null){
+                               feed = new Feed(title,id.toString(),author);
+                       }
+                       feed.addEntry(eventData);
+                       
+                       if(!atomFile.getParentFile().exists()){
+                               atomFile.getParentFile().mkdir();
+                       }
+                       FileOutputStream out = new FileOutputStream(atomFile);
+                       feed.write(out);
+                       out.close();
+                       System.out.println("Atom file at "+ atomFile + " is 
updated");
+               } catch (FileNotFoundException e) {
+                       throw new SavanException(e);
+               } catch (XMLStreamException e) {
+                       throw new SavanException(e);
+               } catch (IOException e) {
+                       throw new SavanException(e);
+               }
+       }
+       public void setId(URI id) {
+               this.id = id;
+       }
+       
+       
+       
+       
+
+
+       public void setSubscriptionEndingTime(Date subscriptionEndingTime) {
+               this.subscriptionEndingTime = subscriptionEndingTime;
+       }
+
+       public void setEndToEPr(EndpointReferenceType endToEPR) {
+               throw new UnsupportedOperationException();
+       }
+
+       public String getAuthor() {
+               return author;
+       }
+
+       public void setAuthor(String author) {
+               this.author = author;
+       }
+
+
+       public String getTitle() {
+               return title;
+       }
+
+       public void setTitle(String title) {
+               this.title = title;
+       }
+       
+       
+       public String getFeedUrl(){
+               return feedUrl;
+       }
+
+       public Date getSubscriptionEndingTime() {
+               return subscriptionEndingTime;
+       }
+       public Filter getFilter() {
+               return filter;
+       }
+       public void setFilter(Filter filter) {
+               this.filter = filter;
+       }
+       public void setAtomFile(File atomFile) {
+               this.atomFile = atomFile;
+       }
+       public void setFeedUrl(String feedUrl) {
+               this.feedUrl = feedUrl;
+       }
+       
+       
+}
diff --git 
a/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java
 
b/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java
new file mode 100644
index 0000000..9576016
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java
@@ -0,0 +1,363 @@
+/*
+ * 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.atom;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+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.filters.XPathBasedFilter;
+import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.subscription.ExpirationBean;
+import org.apache.savan.subscription.SubscriptionProcessor;
+import org.apache.xmlbeans.XmlException;
+
+import com.wso2.eventing.atom.CreateFeedDocument;
+import com.wso2.eventing.atom.RenewFeedDocument;
+import com.wso2.eventing.atom.CreateFeedDocument.CreateFeed;
+
+public class AtomSubscriptionProcessor extends SubscriptionProcessor {
+
+       public void init (SavanMessageContext smc) throws SavanException {
+               //setting the subscriber_id as a property if possible.
+               
+               String id = getSubscriberID(smc);
+               if (id!=null) {
+                       
smc.setProperty(AtomConstants.TransferedProperties.SUBSCRIBER_UUID,id);
+               }
+       }
+       
+       /**
+        * Sample subscription
+        * <createFeed xmlns="http://wso2.com/eventing/atom";>
+     * <EndTo>endpoint-reference</EndTo> ?
+     * <Delivery Mode="xs:anyURI"? >xs:any</Delivery>
+     * <Expires>[xs:dateTime | xs:duration]</Expires> ?
+     * <Filter Dialect="xs:anyURI"? > xs:any </Filter> ?
+     * </createFeed>
+     * 
+        */
+       
+       
+       
+       public Subscriber getSubscriberFromMessage(SavanMessageContext smc) 
throws SavanException {
+
+               try {
+                       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");
+                       
+                       SOAPEnvelope envelope = smc.getEnvelope();
+                       if (envelope==null)
+                               return null;
+                       
+//             AbstractSubscriber subscriber = utilFactory.createSubscriber(); 
 //eventing only works on leaf subscriber for now.
+                       
+                       String subscriberName = protocol.getDefaultSubscriber();
+                       Subscriber subscriber = 
configurationManager.getSubscriberInstance(subscriberName);
+                       
+                       if (!(subscriber instanceof AtomSubscriber)) {
+                               String message = "Savan only support 
implementations of Atom subscriber as Subscribers";
+                               throw new SavanException (message);
+                       }
+
+                       //find the real path for atom feeds
+                       File repositoryPath = 
smc.getConfigurationContext().getRealPath("/"); 
+                       File realAtomPath = new 
File(repositoryPath.getAbsoluteFile(),"../atom");
+                       
+                       //Get the service URL from request
+                       String serviceAddress = 
smc.getMessageContext().getTo().getAddress();
+                       int cutIndex = serviceAddress.indexOf("services");
+                       if(cutIndex > 0){
+                               serviceAddress = 
serviceAddress.substring(0,cutIndex-1);
+                       }
+                       
+                       AtomSubscriber atomSubscriber = (AtomSubscriber) 
subscriber;
+                       String id = UUIDGenerator.getUUID();
+                       
smc.setProperty(AtomConstants.TransferedProperties.SUBSCRIBER_UUID,id);
+                       atomSubscriber.setId(new URI(id));
+                       String atomFeedPath = id.replaceAll(":", "_")+ ".atom";
+                       atomSubscriber.setAtomFile(new 
File(realAtomPath,atomFeedPath));
+                       atomSubscriber.setFeedUrl(serviceAddress +"/atom/"+ 
atomFeedPath);
+                       
+                       SOAPBody body = envelope.getBody();
+                       CreateFeedDocument createFeedDocument = 
CreateFeedDocument.Factory.parse(body.getFirstElement().getXMLStreamReader());
+                       CreateFeed createFeed = 
createFeedDocument.getCreateFeed();
+                       //TODO Srinath
+//                     if(createFeed.getEndTo() != null){
+//                             
atomSubscriber.setEndToEPr(createFeed.getEndTo());      
+//                     }
+//                     if(createFeed.getExpires() != null){
+//                             
atomSubscriber.setSubscriptionEndingTime(createFeed.getExpires().getTime());    
+//                     }
+                       
+                       if (createFeed.getFilter() != null) {
+                               Filter filter = null;
+                               String  filterKey = 
createFeed.getFilter().getDialect();
+                               
+                               filter = 
configurationManager.getFilterInstanceFromId(filterKey);
+                               if (filter==null)
+                                       throw new SavanException ("The Filter 
defined by the dialect is not available");
+                               
+                               if(filter instanceof XPathBasedFilter){
+                                       
((XPathBasedFilter)filter).setXPathString(createFeed.getFilter().getStringValue());
+                               }else{
+                                       throw new SavanException("Only Xpath 
fileters are supported");
+                               }
+                               atomSubscriber.setFilter(filter);
+                       }
+                       
+                       
+                       
+                       
+                       
+                       //TODO -Srinath
+                       atomSubscriber.setAuthor(createFeed.getAuthor());
+                       atomSubscriber.setTitle(createFeed.getTitle());
+                       
+                       smc.setProperty(AtomConstants.Properties.feedUrl, 
atomSubscriber.getFeedUrl());
+                       
+                       return atomSubscriber;
+                       
+                       
+//                     SOAPBody body = envelope.getBody();
+//                     
+//                     OMElement createFeed = findElement("createFeed", body, 
true) ;
+//                     OMElement endToElement = 
findElement(AtomConstants.ElementNames.EndTo, body, true);
+//                     
+//                     EndpointReference endToEPR = null;
+//                     if(endToElement != null){
+//                             endToEPR = 
EndpointReferenceHelper.fromOM(endToElement);
+//                     }
+//                     atomSubscriber.setEndToEPr(endToEPR);
+//                     
+//                     
+//                     String expiresText = 
findValue(AtomConstants.EXPIRES_ELEMENT, createFeed, true);
+//                     if (expiresText==null){
+//                             String message = "Expires Text is null";
+//                             throw new SavanException (message);
+//                     }
+//                     expiresText = expiresText.trim();
+//                     Date expiration = 
getExpirationBeanFromString(expiresText);
+//                     if (expiration==null) {
+//                             String message = "Cannot understand the given 
date-time value for the Expiration";
+//                             throw new SavanException (message);
+//                     }
+//                     atomSubscriber.setSubscriptionEndingTime(expiration);
+//                     
+//                     OMElement filterElement = 
findElement(AtomConstants.ElementNames.Filter, createFeed, true);
+//                     if (filterElement!= null) {
+//                             OMNode filterNode = 
filterElement.getFirstOMChild();
+//                             OMAttribute dialectAttr = 
filterElement.getAttribute(new QName (AtomConstants.ElementNames.Dialect));
+//                             Filter filter = null;
+//                             String filterKey = 
AtomConstants.DEFAULT_FILTER_IDENTIFIER;
+//                             if (dialectAttr!=null) {
+//                                     filterKey = 
dialectAttr.getAttributeValue();
+//                             }
+//                             filter = 
configurationManager.getFilterInstanceFromId(filterKey);
+//                             if (filter==null)
+//                                     throw new SavanException ("The Filter 
defined by the dialect is not available");
+//                             
+//                             filter.setUp (filterNode);
+//                             atomSubscriber.setFilter(filter);
+//                     }
+//                     
+//                     
atomSubscriber.setId(findValue(AtomConstants.ID_ELEMENT, createFeed,true));
+//                     
atomSubscriber.setAuthor(findValue(AtomConstants.AUTHOR_ELEMENT, 
createFeed,true));
+//                     
atomSubscriber.setTitle(findValue(AtomConstants.TITLE_ELEMENT, 
createFeed,true));
+//                     
+//                     smc.setProperty(AtomConstants.Properties.feedUrl, 
atomSubscriber.getFeedUrl());
+//                     
+//                     return atomSubscriber;
+               } catch (AxisFault e) {
+                       throw new SavanException(e);
+               } catch (OMException e) {
+                       throw new SavanException(e);
+               } catch (XmlException e) {
+                       throw new SavanException(e);
+               } catch (URISyntaxException e) {
+                       throw new SavanException(e);
+               }
+       }
+       
+       private String findValue(String localName,OMElement parent,boolean 
throwfault) throws SavanException{
+               return findValue(AtomConstants.ATOM_NAMESPACE, localName, 
parent, throwfault);
+       }
+       
+       private String findValue(String nsURI,String localName,OMElement 
parent,boolean throwfault) throws SavanException{
+               QName name = new QName 
(nsURI,AtomConstants.IDEDNTIFIER_ELEMENT);
+               OMElement ele = parent.getFirstChildWithName(name);
+               if(ele != null){
+                       return ele.getText();
+               }else{
+                       if(throwfault){
+                               throw new SavanException (localName + " element 
is not defined");       
+                       }else{
+                               return null;
+                       }
+               }
+       }
+       
+       private OMElement findElement(String localName,OMElement parent,boolean 
throwfault) throws SavanException{
+               QName name = new QName 
(AtomConstants.ATOM_NAMESPACE,AtomConstants.ID_ELEMENT);
+               OMElement ele = parent.getFirstChildWithName(name);
+               if(ele != null){
+                       return ele;
+               }else{
+                       if(throwfault){
+                               throw new SavanException (localName + " element 
is not defined");       
+                       }else{
+                               return null;
+                       }
+               }
+       }
+
+       public void pauseSubscription(SavanMessageContext 
pauseSubscriptionMessage) throws SavanException {
+               throw new UnsupportedOperationException ("Eventing 
specification does not support this type of messages");
+       }
+
+       public void resumeSubscription(SavanMessageContext 
resumeSubscriptionMessage) throws SavanException {
+               throw new UnsupportedOperationException ("Eventing 
specification does not support this type of messages");
+       }
+       
+       /**
+        * <renewFeed><Expires></Expires></renewFeed>
+        */
+
+       public ExpirationBean getExpirationBean(SavanMessageContext 
renewMessage) throws SavanException {
+               try {
+                       SOAPEnvelope envelope = renewMessage.getEnvelope();
+                       
+                       RenewFeedDocument renewFeedDocument = 
RenewFeedDocument.Factory.parse( envelope.getBody().getXMLStreamReader());
+//             SOAPBody body = envelope.getBody();
+//             
+                       ExpirationBean expirationBean =  new ExpirationBean();
+//             OMElement renewFeedEle = findElement(AtomConstants.RENEW_FEED, 
body, true);
+//             Date expieringTime = 
getExpirationBeanFromString(findValue(AtomConstants.EXPIRES_ELEMENT, 
renewFeedEle, true));
+                       expirationBean.setDuration(false);
+                       
expirationBean.setDateValue(renewFeedDocument.getRenewFeed().getExpires().getTime());
+                       
+                       String subscriberID = getSubscriberID(renewMessage);
+                       if (subscriberID==null) {
+                               String message = "Cannot find the subscriber 
ID";
+                               throw new SavanException (message);
+                       }
+                       
+                       
renewMessage.setProperty(AtomConstants.TransferedProperties.SUBSCRIBER_UUID,subscriberID);
+                       
+                       expirationBean.setSubscriberID(subscriberID);
+                       return expirationBean;
+               } catch (OMException e) {
+                       throw new SavanException(e);
+               } catch (XmlException e) {
+                       throw new SavanException(e);
+               }
+       }
+
+       public String getSubscriberID(SavanMessageContext smc) throws 
SavanException {
+               SOAPEnvelope envelope = smc.getEnvelope();
+               SOAPHeader header = envelope.getHeader();
+               if (header==null) {
+                       return null;
+               }
+               
+               return 
findValue(AtomConstants.ATOM_NAMESPACE,AtomConstants.IDEDNTIFIER_ELEMENT, 
envelope.getHeader(), false);
+       }
+       
+//     private Date getExpirationBeanFromString (String expiresStr) throws 
SavanException {
+//
+//             
+//             
+//             //expires can be a duration or a date time.
+//             //Doing the conversion using the ConverUtil helper class.
+//             
+//             boolean isDuration = CommonUtil.isDuration(expiresStr);
+//             if (isDuration) {
+//                     try {
+//                             Date currentTime = new Date();
+//                             Duration duration = 
ConverterUtil.convertToDuration(expiresStr);
+//                             return new Date(currentTime.getTime()+ 
(int)(1000* duration.getSeconds()));
+//                     } catch (IllegalArgumentException e) {
+//                             String message = "Cannot convert the Expiration 
value to a valid duration";
+//                             throw new SavanException (message,e);
+//                     }
+//             } else {
+//                     try {
+//                         Calendar calendar = 
ConverterUtil.convertToDateTime(expiresStr);
+//                         return calendar.getTime();
+//                     } catch (Exception e) {
+//                             String message = "Cannot convert the Expiration 
value to a valid DATE/TIME";
+//                             throw new SavanException (message,e);
+//                     }
+//             }
+//     }
+
+       public void doProtocolSpecificEndSubscription(Subscriber subscriber, 
String reason, ConfigurationContext configurationContext) throws SavanException 
{
+               throw new UnsupportedOperationException();
+//             String SOAPVersion = (String) 
subscriber.getProperty(AtomConstants.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();
+       }
+       
+//     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;
+//     }
+       
+}
diff --git 
a/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java 
b/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java
new file mode 100644
index 0000000..6f1b105
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java
@@ -0,0 +1,70 @@
+/*
+ * 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.atom;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.messagereceiver.MessageReceiverDeligater;
+import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.subscription.SubscriptionProcessor;
+import org.apache.savan.util.UtilFactory;
+
+public class AtomUtilFactory implements UtilFactory {
+
+       /** 
+        * this is a way to map different actions to different types of 
operations 
+        */
+       public SavanMessageContext initializeMessage(SavanMessageContext smc) {
+               MessageContext messageContext = smc.getMessageContext();
+               //setting the message type.
+               String action = messageContext.getOptions().getAction();
+               if (AtomConstants.Actions.Subscribe.equals(action))
+                       
smc.setMessageType(SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE);
+               else if (AtomConstants.Actions.Renew.equals(action))
+                       
smc.setMessageType(SavanConstants.MessageTypes.RENEW_MESSAGE);
+               else if (AtomConstants.Actions.Unsubscribe.equals(action))
+                       
smc.setMessageType(SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE);
+               else if (AtomConstants.Actions.GetStatus.equals(action))
+                       
smc.setMessageType(SavanConstants.MessageTypes.GET_STATUS_MESSAGE);
+               else if (AtomConstants.Actions.SubscribeResponse.equals(action))
+                       
smc.setMessageType(SavanConstants.MessageTypes.SUBSCRIPTION_RESPONSE_MESSAGE);
+               else if (AtomConstants.Actions.RenewResponse.equals(action))
+                       
smc.setMessageType(SavanConstants.MessageTypes.RENEW_RESPONSE_MESSAGE);
+               else if 
(AtomConstants.Actions.UnsubscribeResponse.equals(action))
+                       
smc.setMessageType(SavanConstants.MessageTypes.UNSUBSCRIPTION_RESPONSE_MESSAGE);
+               else if (AtomConstants.Actions.GetStatusResponse.equals(action))
+                       
smc.setMessageType(SavanConstants.MessageTypes.GET_STATUS_RESPONSE_MESSAGE);
+               else 
+                       smc.setMessageType(SavanConstants.MessageTypes.UNKNOWN);
+               return smc;
+       }
+
+       public SubscriptionProcessor createSubscriptionProcessor() {
+               return new AtomSubscriptionProcessor ();
+       }
+       
+       public MessageReceiverDeligater createMessageReceiverDeligater() {
+               return new AtomMessageReceiverDeligater ();
+       }
+
+       public Subscriber createSubscriber() {
+               return new AtomSubscriber ();
+       }
+       
+}
diff --git a/modules/core/src/main/java/org/apache/savan/atom/Feed.java 
b/modules/core/src/main/java/org/apache/savan/atom/Feed.java
new file mode 100644
index 0000000..aa990ba
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/savan/atom/Feed.java
@@ -0,0 +1,110 @@
+package org.apache.savan.atom;
+
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMDocument;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+
+public class Feed {
+       private String title;
+       private String id;
+       private Date lastUpdated;
+       private String author;
+       private ArrayList entries;
+       private OMDocument document;
+       private int entryCount;
+       private OMFactory factory;
+       private OMNamespace atomNs;
+       
+//     <feed xmlns="http://www.w3.org/2005/Atom";>
+//       <id>http://www.example.org/myfeed</id>
+//       <title>My Podcast Feed</title>
+//       <updated>2005-07-15T12:00:00Z</updated>
+//       <author>
+//         <name>James M Snell</name>
+//       </author>
+//       <link href="http://example.org"; />
+//       <link rel="self" href="http://example.org/myfeed"; />
+//       <entry>
+//         <id>http://www.example.org/entries/1</id>
+//         <title>Atom 1.0</title>
+//         <updated>2005-07-15T12:00:00Z</updated>
+//         <link href="http://www.example.org/entries/1"; />
+//         <summary>An overview of Atom 1.0</summary>
+//         <link rel="enclosure" 
+//               type="audio/mpeg"
+//               title="MP3"
+//               href="http://www.example.org/myaudiofile.mp3";
+//               length="1234" />
+//         <link rel="enclosure"
+//               type="application/x-bittorrent"
+//               title="BitTorrent"
+//               href="http://www.example.org/myaudiofile.torrent";
+//               length="1234" />
+//         <content type="xml">
+//           ..
+//         </content>
+//       </entry>
+//     </feed>
+       
+       
+       public Feed(String title, String id, String author) {
+               this.title = title;
+               this.id = id;
+               this.author = author;
+               lastUpdated = new Date();
+               factory = OMAbstractFactory.getOMFactory();
+               document = factory.createOMDocument();
+               atomNs = 
factory.createOMNamespace(AtomConstants.ATOM_NAMESPACE,AtomConstants.ATOM_PREFIX);
+               OMElement feedEle = 
factory.createOMElement("feed",atomNs,document);
+               
+               factory.createOMElement("id",atomNs,feedEle).setText(id);
+               if(title != null){
+                       
factory.createOMElement("title",atomNs,feedEle).setText(id);    
+               }
+               factory.createOMElement("updated",atomNs,feedEle).setText( new 
SimpleDateFormat("dd-mm-yy'T1'HH:MM:ssZ").format(lastUpdated));
+               if(author != null){
+                       OMElement authorEle = 
factory.createOMElement("author",atomNs,feedEle);
+                       
factory.createOMElement("name",atomNs,authorEle).setText(author);
+               }
+       }
+       public void addEntry(OMElement entry){
+               entryCount++;
+               lastUpdated = new Date();
+               OMElement entryEle = 
factory.createOMElement("entry",atomNs,document.getOMDocumentElement());
+               factory.createOMElement("id",atomNs,entryEle).setText(id +"/" + 
entryCount);
+               factory.createOMElement("title",atomNs,entryEle).setText(id 
+"/" + entryCount);
+               
+               factory.createOMElement("updated",atomNs,entryEle).setText( new 
SimpleDateFormat("dd-mm-yy'T1'HH:MM:ssZ").format(lastUpdated));
+               
+               OMElement contentEle =  
factory.createOMElement("content",atomNs,entryEle);
+               contentEle.addAttribute("type","xml",null);
+               contentEle.addChild(entry);
+               
+               
+               
+               document.getOMDocumentElement().addChild(entryEle);
+       }
+       
+       public void write(OutputStream out) throws XMLStreamException{
+               document.serialize(out);
+       }
+       
+//     public static void main(String[] args) throws Exception{
+//             Feed feed = new Feed("testtitle","test_id","john");
+//             StAXOMBuilder builder = new StAXOMBuilder(new 
ByteArrayInputStream("<foo>bar</foo>".getBytes()));
+//             feed.addEntry(builder.getDocumentElement());
+//             feed.write(System.out);
+//             System.out.flush();
+//             
+//     }
+       
+}
diff --git a/modules/core/src/main/java/org/apache/savan/util/CommonUtil.java 
b/modules/core/src/main/java/org/apache/savan/util/CommonUtil.java
index 9c61277..df6c28a 100644
--- a/modules/core/src/main/java/org/apache/savan/util/CommonUtil.java
+++ b/modules/core/src/main/java/org/apache/savan/util/CommonUtil.java
@@ -27,6 +27,7 @@ import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
@@ -36,6 +37,7 @@ import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
 import org.apache.savan.SavanConstants;
 import org.apache.savan.storage.SubscriberStore;
+import org.apache.xmlbeans.XmlObject;
 
 /**
  * A common set of methods that may be used in various places of Savan.
@@ -87,4 +89,10 @@ public class CommonUtil {
                
                return (SubscriberStore) parameter.getValue();
        }
+       
+       public static OMElement toOM(XmlObject element){
+               org.apache.axiom.om.impl.builder.StAXOMBuilder builder = new 
org.apache.axiom.om.impl.builder.StAXOMBuilder
+        (org.apache.axiom.om.OMAbstractFactory.getOMFactory(),new 
org.apache.axis2.util.StreamWrapper(element.newXMLStreamReader())) ;
+               return builder.getDocumentElement();
+       }
 }
diff --git a/modules/mar/module.xml b/modules/mar/module.xml
index 94518ca..6f20028 100644
--- a/modules/mar/module.xml
+++ b/modules/mar/module.xml
@@ -2,11 +2,14 @@
 
     <operation name="SavanInOutOperation" 
mep="http://www.w3.org/2004/08/wsdl/in-out";>
         <messageReceiver 
class="org.apache.savan.messagereceiver.SavanInOutMessageReceiver"/>
-        
         
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe</actionMapping>
         
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew</actionMapping>
         
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus</actionMapping>
         
<actionMapping>http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</actionMapping>
+        <actionMapping>http://wso2.com/eventing/Subscribe</actionMapping>
+               <actionMapping>http://wso2.com/eventing/Renew</actionMapping>
+               
<actionMapping>http://wso2.com/eventing/Unsubscribe</actionMapping>
+               
<actionMapping>http://wso2.com/eventing/GetStatus</actionMapping>
     </operation>
     
 </module>
diff --git a/pom.xml b/pom.xml
index 6faa6e0..d70c13c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,6 +84,12 @@
                        <artifactId>axis2-adb</artifactId>
                        <version>${axis2.version}</version>
                </dependency>
+        <dependency>
+            <groupId>xmlbeans</groupId>
+            <artifactId>xbean</artifactId>
+            <version>2.2.0</version>
+        </dependency>
+               
                
        </dependencies>
        
@@ -103,6 +109,7 @@
                                <artifactId>maven-surefire-plugin</artifactId>
                                <version>2.2</version>
                        </plugin>
+                       
                        <!--
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>

Reply via email to