In preparation for doing some work on Savan, reformat code to match WS standards (remove tabs etc) and fix some spelling errors.
git-svn-id: https://svn.apache.org/repos/asf/webservices/savan/trunk/java@679954 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 2045175..e87d1c0 100644
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -2,109 +2,109 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.ws.savan</groupId>
- <artifactId>savan-parent</artifactId>
- <version>SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
+ <parent>
<groupId>org.apache.ws.savan</groupId>
- <artifactId>savan-core</artifactId>
- <packaging>jar</packaging>
- <name>Savan - Core</name>
+ <artifactId>savan-parent</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
- <dependencies>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>10.1.1.0</version>
- </dependency>
- </dependencies>
- <build>
- <sourceDirectory>src/main/java</sourceDirectory>
- <testSourceDirectory>src/test/java</testSourceDirectory>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <inherited>true</inherited>
- <configuration>
- <skip>false</skip>
- <excludes>
- <exclude>**/*Abstract*.java</exclude>
- <exclude>**/*Util*.java</exclude>
- <exclude>**/AtomTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ws.savan</groupId>
+ <artifactId>savan-core</artifactId>
+ <packaging>jar</packaging>
+ <name>Savan - Core</name>
-<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">
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.1.1.0</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <sourceDirectory>src/main/java</sourceDirectory>
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <skip>false</skip>
+ <excludes>
+ <exclude>**/*Abstract*.java</exclude>
+ <exclude>**/*Util*.java</exclude>
+ <exclude>**/AtomTest.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
- <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>
- <execution>
- <id>copy-config-file</id>
- <phase>package</phase>
- <configuration>
- <tasks>
- <copy file="./src/main/config/savan-config.xml"
- todir="target/classes"/>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
+ <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>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <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>
+ <execution>
+ <id>copy-config-file</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <copy file="./src/main/config/savan-config.xml"
+ todir="target/classes"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/modules/core/src/main/config/savan-config.xml b/modules/core/src/main/config/savan-config.xml
index 5ceb16d..5068cd6 100644
--- a/modules/core/src/main/config/savan-config.xml
+++ b/modules/core/src/main/config/savan-config.xml
@@ -1,69 +1,69 @@
<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>
- <action>http://wso2.com/ws/2007/05/eventing/Publish</action>
- </mapping-rules>
- <defaultSubscriber>eventing</defaultSubscriber>
- <defaultFilter>empty</defaultFilter>
- <!--
- <parameters>
- <parameter>
- <name>eventing-topic-subscriber</name>
- <value>eventing-topic</value>
- </parameter>
- </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>
- <subscriberStore>
- <key>default</key>
- <class>org.apache.savan.storage.DefaultSubscriberStore</class>
- </subscriberStore>
- </subscriberStores>
-
- <filters>
- <filter>
- <name>empty</name>
- <identifier>empty</identifier>
- <class>org.apache.savan.filters.EmptyFilter</class>
- </filter>
- <filter>
- <name>xpath</name>
- <identifier>http://www.w3.org/TR/1999/REC-xpath-19991116</identifier>
- <class>org.apache.savan.filters.XPathBasedFilter</class>
- </filter>
- </filters>
-
- <subscribers>
- <subscriber>
- <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>
-
+ <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>
+ <action>http://wso2.com/ws/2007/05/eventing/Publish</action>
+ </mapping-rules>
+ <defaultSubscriber>eventing</defaultSubscriber>
+ <defaultFilter>empty</defaultFilter>
+ <!--
+ <parameters>
+ <parameter>
+ <name>eventing-topic-subscriber</name>
+ <value>eventing-topic</value>
+ </parameter>
+ </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>
+ <subscriberStore>
+ <key>default</key>
+ <class>org.apache.savan.storage.DefaultSubscriberStore</class>
+ </subscriberStore>
+ </subscriberStores>
+
+ <filters>
+ <filter>
+ <name>empty</name>
+ <identifier>empty</identifier>
+ <class>org.apache.savan.filters.EmptyFilter</class>
+ </filter>
+ <filter>
+ <name>xpath</name>
+ <identifier>http://www.w3.org/TR/1999/REC-xpath-19991116</identifier>
+ <class>org.apache.savan.filters.XPathBasedFilter</class>
+ </filter>
+ </filters>
+
+ <subscribers>
+ <subscriber>
+ <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/MessageInitializer.java b/modules/core/src/main/java/org/apache/savan/MessageInitializer.java
index ab53c1f..26f6fd1 100644
--- a/modules/core/src/main/java/org/apache/savan/MessageInitializer.java
+++ b/modules/core/src/main/java/org/apache/savan/MessageInitializer.java
@@ -19,8 +19,8 @@
public class MessageInitializer {
- public static void initializeMessage (SavanMessageContext smc) {
- //TODO fill the properties in to the SMC,
- //For e.g. UtilFactory and the SubscriberStore
- }
+ public static void initializeMessage(SavanMessageContext smc) {
+ //TODO fill the properties in to the SMC,
+ //For e.g. UtilFactory and the SubscriberStore
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/SavanConstants.java b/modules/core/src/main/java/org/apache/savan/SavanConstants.java
index 10e77ae..f688a18 100644
--- a/modules/core/src/main/java/org/apache/savan/SavanConstants.java
+++ b/modules/core/src/main/java/org/apache/savan/SavanConstants.java
@@ -17,49 +17,43 @@
package org.apache.savan;
-/**
- * Contains the constants used by 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 CONFIGURATION_MANAGER =
+ "SavanConfigurationManager"; //Property name to store the CM in the ConfigCtx.
- String MESSAGE_TYPE = "SavanMessageType";
- String PUBLICATION_MESSAGE = "SavanPublicationMessage";
-
- String SUBSCRIBER_STORE = "SubscriberStore"; //AxisService property
- String SUBSCRIBER_STORE_KEY = "SubscriberStoreKey"; //to mention the key in the services.xml
- String PROTOCOL = "Protocol";
-
- String CONFIG_FILE = "savan-config.xml";
- String UTIL_FACTORY = "UtilFactory";
-
- String DEFAULT_SUBSCRIBER_STORE_KEY = "default";
-
- interface MessageTypes {
- int UNKNOWN = -1;
- int SUBSCRIPTION_MESSAGE = 1;
- int SUBSCRIPTION_RESPONSE_MESSAGE = 2;
- int UNSUBSCRIPTION_MESSAGE = 3;
- int UNSUBSCRIPTION_RESPONSE_MESSAGE = 4;
- int RENEW_MESSAGE = 5;
- int RENEW_RESPONSE_MESSAGE = 6;
- int GET_STATUS_MESSAGE = 7;
- int GET_STATUS_RESPONSE_MESSAGE = 8;
- int PUBLISH = 9;
- }
-
- interface Properties {
- String SUBSCRIBER_STORE = "SubscriberStore";
- }
-
-
-
+ String VALUE_TRUE = "true";
+ String VALUE_FALSE = "false";
-
+ String MESSAGE_TYPE = "SavanMessageType";
+ String PUBLICATION_MESSAGE = "SavanPublicationMessage";
+
+ String SUBSCRIBER_STORE = "SubscriberStore"; //AxisService property
+ String SUBSCRIBER_STORE_KEY = "SubscriberStoreKey"; //to mention the key in the services.xml
+ String PROTOCOL = "Protocol";
+
+ String CONFIG_FILE = "savan-config.xml";
+ String UTIL_FACTORY = "UtilFactory";
+
+ String DEFAULT_SUBSCRIBER_STORE_KEY = "default";
+
+ interface MessageTypes {
+ int UNKNOWN = -1;
+ int SUBSCRIPTION_MESSAGE = 1;
+ int SUBSCRIPTION_RESPONSE_MESSAGE = 2;
+ int UNSUBSCRIPTION_MESSAGE = 3;
+ int UNSUBSCRIPTION_RESPONSE_MESSAGE = 4;
+ int RENEW_MESSAGE = 5;
+ int RENEW_RESPONSE_MESSAGE = 6;
+ int GET_STATUS_MESSAGE = 7;
+ int GET_STATUS_RESPONSE_MESSAGE = 8;
+ int PUBLISH = 9;
+ }
+
+ interface Properties {
+ String SUBSCRIBER_STORE = "SubscriberStore";
+ }
+
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/SavanException.java b/modules/core/src/main/java/org/apache/savan/SavanException.java
index 5f07afa..8bf2678 100644
--- a/modules/core/src/main/java/org/apache/savan/SavanException.java
+++ b/modules/core/src/main/java/org/apache/savan/SavanException.java
@@ -19,21 +19,18 @@
import org.apache.axis2.AxisFault;
-/**
- * To convey a exception that occured in Savan.
- *
- */
+/** To convey a exception that occured in Savan. */
public class SavanException extends AxisFault {
- public SavanException (String cause) {
- super (cause);
- }
-
- public SavanException (String cause, Exception superException) {
- super (cause,superException);
- }
-
- public SavanException (Exception superException) {
- super (superException);
- }
+ public SavanException(String cause) {
+ super(cause);
+ }
+
+ public SavanException(String cause, Exception superException) {
+ super(cause, superException);
+ }
+
+ public SavanException(Exception superException) {
+ super(superException);
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/SavanMessageContext.java b/modules/core/src/main/java/org/apache/savan/SavanMessageContext.java
index 98209ea..fa95583 100644
--- a/modules/core/src/main/java/org/apache/savan/SavanMessageContext.java
+++ b/modules/core/src/main/java/org/apache/savan/SavanMessageContext.java
@@ -26,81 +26,81 @@
import org.apache.savan.storage.SubscriberStore;
/**
- * This encaptulates a Axis2 Message Context.
- * Provide some easy methods to access Savan specific properties easily.
+ * This encaptulates a Axis2 Message Context. Provide some easy methods to access Savan specific
+ * properties easily.
*/
public class SavanMessageContext {
- MessageContext messageContext = null;
-
- public SavanMessageContext (MessageContext messageContext) {
- this.messageContext = messageContext;
- }
-
- 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();
- }
-
- public ConfigurationContext getConfigurationContext () {
- return messageContext.getConfigurationContext();
- }
-
- public Object getProperty (String key) {
- return messageContext.getProperty(key);
- }
-
- public void setProperty (String key, Object val) {
- messageContext.setProperty(key,val);
- }
-
- public SOAPEnvelope getEnvelope () {
- return messageContext.getEnvelope();
- }
-
- 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 AbstractSubscriber 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);
- }
-
+ MessageContext messageContext = null;
+
+ public SavanMessageContext(MessageContext messageContext) {
+ this.messageContext = messageContext;
+ }
+
+ 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();
+ }
+
+ public ConfigurationContext getConfigurationContext() {
+ return messageContext.getConfigurationContext();
+ }
+
+ public Object getProperty(String key) {
+ return messageContext.getProperty(key);
+ }
+
+ public void setProperty(String key, Object val) {
+ messageContext.setProperty(key, val);
+ }
+
+ public SOAPEnvelope getEnvelope() {
+ return messageContext.getEnvelope();
+ }
+
+ 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 AbstractSubscriber 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);
+ }
+
}
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
index fde0b88..d61e62d 100644
--- a/modules/core/src/main/java/org/apache/savan/atom/AtomConstants.java
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomConstants.java
@@ -1,76 +1,72 @@
-
package org.apache.savan.atom;
-/**
- *
- * @author Srinath Perera(hemapani@apache.org)
- */
+/** @author Srinath Perera(hemapani@apache.org) */
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";
- }
-
- public 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 Entry = "entry";
- String Content = "content";
- String deleteFeedResponse = "DeleteFeedResponse";
- }
-
- interface Properties {
- String SOAPVersion = "SOAPVersion";
- String feedUrl = "feedUrl";
- String DataSource = "DataSource";
- }
-
+ 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";
+ }
+
+ public 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 Entry = "entry";
+ String Content = "content";
+ String deleteFeedResponse = "DeleteFeedResponse";
+ }
+
+ interface Properties {
+ String SOAPVersion = "SOAPVersion";
+ String feedUrl = "feedUrl";
+ String DataSource = "DataSource";
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/atom/AtomDataSource.java b/modules/core/src/main/java/org/apache/savan/atom/AtomDataSource.java
index f062cce..45eaba5 100644
--- a/modules/core/src/main/java/org/apache/savan/atom/AtomDataSource.java
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomDataSource.java
@@ -1,21 +1,5 @@
package org.apache.savan.atom;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.builder.StAXBuilder;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
@@ -23,163 +7,175 @@
import org.apache.axis2.context.MessageContext;
import org.apache.savan.SavanException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.sql.*;
+import java.util.Date;
+import java.util.Properties;
+
/**
- * This class interface between Derby and Savan atom implementation
- * @author Srinath Perera(hemapani@apache.org)
+ * This class interface between Derby and Savan atom implementation
*
+ * @author Srinath Perera(hemapani@apache.org)
*/
public class AtomDataSource {
- public static final String SQL_CREATE_FEEDS = "CREATE TABLE FEEDS(id CHAR(250) NOT NULL, " +
- "title CHAR(250), updated TIMESTAMP, author CHAR(250), PRIMARY KEY(id))";
- public static final String SQL_CREATE_ENTRIES = "CREATE TABLE ENTIES(feed CHAR(250), content VARCHAR(2000))";
+ public static final String SQL_CREATE_FEEDS = "CREATE TABLE FEEDS(id CHAR(250) NOT NULL, " +
+ "title CHAR(250), updated TIMESTAMP, author CHAR(250), PRIMARY KEY(id))";
+ public static final String SQL_CREATE_ENTRIES =
+ "CREATE TABLE ENTIES(feed CHAR(250), content VARCHAR(2000))";
- public static final String SQL_ADD_FEED = "INSERT INTO FEEDS(id,title, updated,author) VALUES(?,?,?,?)";
- public static final String SQL_ADD_ENTRY = "INSERT INTO ENTIES(feed, content) VALUES(?,?)";
- public static final String SQL_GET_ENTRIES_4_FEED = "SELECT content from ENTIES WHERE feed=?";
- public static final String SQL_GET_FEED_DATA = "SELECT id,title,updated,author from FEEDS WHERE id=?";
+ public static final String SQL_ADD_FEED =
+ "INSERT INTO FEEDS(id,title, updated,author) VALUES(?,?,?,?)";
+ public static final String SQL_ADD_ENTRY = "INSERT INTO ENTIES(feed, content) VALUES(?,?)";
+ public static final String SQL_GET_ENTRIES_4_FEED = "SELECT content from ENTIES WHERE feed=?";
+ public static final String SQL_GET_FEED_DATA =
+ "SELECT id,title,updated,author from FEEDS WHERE id=?";
-
-
-
- public String framework = "embedded";
+
+ public String framework = "embedded";
public String driver = "org.apache.derby.jdbc.EmbeddedDriver";
public String protocol = "jdbc:derby:";
private Properties props;
-
- public AtomDataSource() throws SavanException{
- try {
- Class.forName(driver).newInstance();
- System.out.println("Loaded the appropriate driver.");
- props = new Properties();
- props.put("user", "user1");
- props.put("password", "user1");
-
- Connection connection = getConnection();
- Statement statement = connection.createStatement();
-
- ResultSet feedtable = connection.getMetaData().getTables(null, null, "FEEDS", null);
- if(!feedtable.next()){
- statement.execute(SQL_CREATE_FEEDS);
- }
- ResultSet entirestable = connection.getMetaData().getTables(null, null, "ENTIES", null);
- if(!entirestable.next()){
- statement.execute(SQL_CREATE_ENTRIES);
- }
- connection.close();
- } catch (InstantiationException e) {
- throw new SavanException(e);
- } catch (IllegalAccessException e) {
- throw new SavanException(e);
- } catch (ClassNotFoundException e) {
- throw new SavanException(e);
- } catch (SQLException e) {
- throw new SavanException(e);
- }
-
- }
-
- public Connection getConnection() throws SavanException{
+ public AtomDataSource() throws SavanException {
try {
- /*
- The connection specifies create=true to cause
- the database to be created. To remove the database,
- remove the directory derbyDB and its contents.
- The directory derbyDB will be created under
- the directory that the system property
- derby.system.home points to, or the current
- directory if derby.system.home is not set.
- */
- return DriverManager.getConnection(protocol +
- "derbyDB;create=true", props);
- } catch (SQLException e) {
- throw new SavanException(e);
- }
-
- }
-
-
- public void addFeed(String id,String title,Date lastEditedtime,String author) throws SavanException{
-
- try {
- Connection connection = getConnection();
- try{
- PreparedStatement statement = connection.prepareStatement(SQL_ADD_FEED);
- statement.setString(1,id );
- statement.setString(2,title );
- Timestamp t = new Timestamp(lastEditedtime.getTime());
- statement.setTimestamp(3, t);
- statement.setString(4, author);
- statement.executeUpdate();
- }finally{
- connection.close();
- }
- } catch (SQLException e) {
- throw new SavanException(e);
- }
-
-
- }
-
- public void addEntry(String id,OMElement entry) throws SavanException{
- try {
- StringWriter w = new StringWriter();
- entry.serialize(w);
- Connection connection = getConnection();
- try{
- PreparedStatement statement = connection.prepareStatement(SQL_ADD_ENTRY);
- statement.setString(1,id );
- statement.setString(2,w.getBuffer().toString() );
- statement.executeUpdate();
- }finally{
- connection.close();
- }
- } catch (SQLException e) {
- throw new SavanException(e);
- } catch (XMLStreamException e) {
- throw new SavanException(e);
- }
- }
-
-
- public OMElement getFeedAsXml(String feedId) throws SavanException{
-
- try {
- Connection connection = getConnection();
- try{
- PreparedStatement statement = connection.prepareStatement(SQL_GET_FEED_DATA);
- statement.setString(1,feedId );
- ResultSet results = statement.executeQuery();
- if(results.next()){
- String title = results.getString("title");
- Timestamp updatedTime = results.getTimestamp("updated");
- String author = results.getString("author");
-
- Feed feed = new Feed(title,feedId,author,updatedTime);
-
- statement.close();
-
- statement = connection.prepareStatement(SQL_GET_ENTRIES_4_FEED);
- statement.setString(1,feedId );
- results = statement.executeQuery();
- while(results.next()){
- String entryAsStr = results.getString("content");
- InputStream atomIn = new ByteArrayInputStream(entryAsStr.getBytes());
- XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(atomIn, MessageContext.DEFAULT_CHAR_SET_ENCODING);
- StAXBuilder builder = new StAXOMBuilder(feed.getFactory(),xmlreader);
- feed.addEntry(builder.getDocumentElement());
- }
- return feed.getFeedAsXml();
- }else{
- throw new SavanException("No such feed "+feedId);
- }
- }finally{
- connection.close();
- }
- } catch (SQLException e) {
- throw new SavanException(e);
- } catch (XMLStreamException e) {
- throw new SavanException(e);
- }
- }
+ Class.forName(driver).newInstance();
+ System.out.println("Loaded the appropriate driver.");
+
+ props = new Properties();
+ props.put("user", "user1");
+ props.put("password", "user1");
+
+ Connection connection = getConnection();
+ Statement statement = connection.createStatement();
+
+ ResultSet feedtable = connection.getMetaData().getTables(null, null, "FEEDS", null);
+ if (!feedtable.next()) {
+ statement.execute(SQL_CREATE_FEEDS);
+ }
+ ResultSet entirestable = connection.getMetaData().getTables(null, null, "ENTIES", null);
+ if (!entirestable.next()) {
+ statement.execute(SQL_CREATE_ENTRIES);
+ }
+ connection.close();
+ } catch (InstantiationException e) {
+ throw new SavanException(e);
+ } catch (IllegalAccessException e) {
+ throw new SavanException(e);
+ } catch (ClassNotFoundException e) {
+ throw new SavanException(e);
+ } catch (SQLException e) {
+ throw new SavanException(e);
+ }
+
+ }
+
+ public Connection getConnection() throws SavanException {
+ try {
+ /*
+ The connection specifies create=true to cause
+ the database to be created. To remove the database,
+ remove the directory derbyDB and its contents.
+ The directory derbyDB will be created under
+ the directory that the system property
+ derby.system.home points to, or the current
+ directory if derby.system.home is not set.
+ */
+ return DriverManager.getConnection(protocol +
+ "derbyDB;create=true", props);
+ } catch (SQLException e) {
+ throw new SavanException(e);
+ }
+
+ }
+
+
+ public void addFeed(String id, String title, Date lastEditedtime, String author)
+ throws SavanException {
+
+ try {
+ Connection connection = getConnection();
+ try {
+ PreparedStatement statement = connection.prepareStatement(SQL_ADD_FEED);
+ statement.setString(1, id);
+ statement.setString(2, title);
+ Timestamp t = new Timestamp(lastEditedtime.getTime());
+ statement.setTimestamp(3, t);
+ statement.setString(4, author);
+ statement.executeUpdate();
+ } finally {
+ connection.close();
+ }
+ } catch (SQLException e) {
+ throw new SavanException(e);
+ }
+
+
+ }
+
+ public void addEntry(String id, OMElement entry) throws SavanException {
+ try {
+ StringWriter w = new StringWriter();
+ entry.serialize(w);
+ Connection connection = getConnection();
+ try {
+ PreparedStatement statement = connection.prepareStatement(SQL_ADD_ENTRY);
+ statement.setString(1, id);
+ statement.setString(2, w.getBuffer().toString());
+ statement.executeUpdate();
+ } finally {
+ connection.close();
+ }
+ } catch (SQLException e) {
+ throw new SavanException(e);
+ } catch (XMLStreamException e) {
+ throw new SavanException(e);
+ }
+ }
+
+
+ public OMElement getFeedAsXml(String feedId) throws SavanException {
+
+ try {
+ Connection connection = getConnection();
+ try {
+ PreparedStatement statement = connection.prepareStatement(SQL_GET_FEED_DATA);
+ statement.setString(1, feedId);
+ ResultSet results = statement.executeQuery();
+ if (results.next()) {
+ String title = results.getString("title");
+ Timestamp updatedTime = results.getTimestamp("updated");
+ String author = results.getString("author");
+
+ Feed feed = new Feed(title, feedId, author, updatedTime);
+
+ statement.close();
+
+ statement = connection.prepareStatement(SQL_GET_ENTRIES_4_FEED);
+ statement.setString(1, feedId);
+ results = statement.executeQuery();
+ while (results.next()) {
+ String entryAsStr = results.getString("content");
+ InputStream atomIn = new ByteArrayInputStream(entryAsStr.getBytes());
+ XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(atomIn,
+ MessageContext.DEFAULT_CHAR_SET_ENCODING);
+ StAXBuilder builder = new StAXOMBuilder(feed.getFactory(), xmlreader);
+ feed.addEntry(builder.getDocumentElement());
+ }
+ return feed.getFeedAsXml();
+ } else {
+ throw new SavanException("No such feed " + feedId);
+ }
+ } finally {
+ connection.close();
+ }
+ } catch (SQLException e) {
+ throw new SavanException(e);
+ } catch (XMLStreamException e) {
+ throw new SavanException(e);
+ }
+ }
}
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
index 1a3a056..44d4b16 100644
--- a/modules/core/src/main/java/org/apache/savan/atom/AtomEventingClient.java
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomEventingClient.java
@@ -1,15 +1,10 @@
package org.apache.savan.atom;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Calendar;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-
+import com.wso2.eventing.atom.CreateFeedDocument;
+import com.wso2.eventing.atom.CreateFeedDocument.CreateFeed;
+import com.wso2.eventing.atom.CreateFeedResponseDocument;
+import com.wso2.eventing.atom.CreateFeedResponseDocument.CreateFeedResponse;
+import com.wso2.eventing.atom.FilterType;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
@@ -31,219 +26,227 @@
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.FilterType;
-import com.wso2.eventing.atom.CreateFeedDocument.CreateFeed;
-import com.wso2.eventing.atom.CreateFeedResponseDocument.CreateFeedResponse;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Calendar;
+import java.util.Iterator;
/**
* This class take provide client interface for Savan atom support
- *
+ *
* @author Srinath Perera(hemapani@apache.org)
- *
*/
public class AtomEventingClient {
- private ServiceClient serviceClient = null;
+ private ServiceClient serviceClient = null;
- private EndpointReference feedEpr;
+ private EndpointReference feedEpr;
- public AtomEventingClient(String serviceUrl,String clientRepository) throws AxisFault{
- ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(clientRepository,clientRepository+"/conf/axis2.xml");
- serviceClient = new ServiceClient (configContext,null); //TODO give a repo
-
- Options options = new Options ();
- serviceClient.setOptions(options);
- serviceClient.engageModule(new QName ("addressing"));
- options.setTo(new EndpointReference (serviceUrl));
- }
-
-
- public AtomEventingClient(ServiceClient serviceClient) {
- this.serviceClient = serviceClient;
- }
+ public AtomEventingClient(String serviceUrl, String clientRepository) throws AxisFault {
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(clientRepository,
+ clientRepository + "/conf/axis2.xml");
+ serviceClient = new ServiceClient(configContext, null); //TODO give a repo
- public CreateFeedResponse createFeed(String title, String author)
- throws AxisFault {
- return createFeed(title, author, null, null);
- }
+ Options options = new Options();
+ serviceClient.setOptions(options);
+ serviceClient.engageModule(new QName("addressing"));
+ options.setTo(new EndpointReference(serviceUrl));
+ }
- public CreateFeedResponse createFeed(String title, String author,
- Calendar expiredTime, String xpathFilter) throws AxisFault {
- try {
- serviceClient.getOptions().setAction(
- AtomConstants.Actions.Subscribe);
- CreateFeedDocument createFeedDocument = CreateFeedDocument.Factory
- .newInstance();
- CreateFeed createFeed = createFeedDocument.addNewCreateFeed();
+ public AtomEventingClient(ServiceClient serviceClient) {
+ this.serviceClient = serviceClient;
+ }
- createFeed.setAuthor(author);
- createFeed.setTitle(title);
+ public CreateFeedResponse createFeed(String title, String author)
+ throws AxisFault {
+ return createFeed(title, author, null, null);
+ }
- if (expiredTime != null) {
- createFeed.setExpires(expiredTime);
- }
- if (xpathFilter != null) {
- FilterType filter = createFeed.addNewFilter();
- filter.setDialect(XPathBasedFilter.XPATH_BASED_FILTER);
- filter.setStringValue(xpathFilter);
- }
+ public CreateFeedResponse createFeed(String title, String author,
+ Calendar expiredTime, String xpathFilter)
+ throws AxisFault {
+ try {
+ serviceClient.getOptions().setAction(
+ AtomConstants.Actions.Subscribe);
- OMElement request = CommonUtil.toOM(createFeedDocument);
- request.build();
- OMElement element = serviceClient.sendReceive(request);
- CreateFeedResponseDocument createFeedResponseDocument = CreateFeedResponseDocument.Factory
- .parse(element.getXMLStreamReader());
- System.out.println(createFeedDocument.xmlText());
+ CreateFeedDocument createFeedDocument = CreateFeedDocument.Factory
+ .newInstance();
+ CreateFeed createFeed = createFeedDocument.addNewCreateFeed();
- // 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"));
+ createFeed.setAuthor(author);
+ createFeed.setTitle(title);
- 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());
- }
+ if (expiredTime != null) {
+ createFeed.setExpires(expiredTime);
+ }
+ if (xpathFilter != null) {
+ FilterType filter = createFeed.addNewFilter();
+ filter.setDialect(XPathBasedFilter.XPATH_BASED_FILTER);
+ filter.setStringValue(xpathFilter);
+ }
- return createFeedResponseDocument.getCreateFeedResponse();
- } catch (XmlException e) {
- throw AxisFault.makeFault(e);
- }
- }
+ OMElement request = CommonUtil.toOM(createFeedDocument);
+ request.build();
+ OMElement element = serviceClient.sendReceive(request);
+ CreateFeedResponseDocument createFeedResponseDocument =
+ CreateFeedResponseDocument.Factory
+ .parse(element.getXMLStreamReader());
+ System.out.println(createFeedDocument.xmlText());
- public void deleteFeed(EndpointReference epr) throws AxisFault {
- serviceClient.getOptions().setAction(AtomConstants.Actions.Unsubscribe);
- serviceClient.getOptions().setTo(epr);
+ // 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"));
- OMElement request = OMAbstractFactory.getOMFactory().createOMElement(
- new QName(AtomConstants.ATOM_MSG_NAMESPACE, "DeleteFeed"));
- serviceClient.sendReceive(request);
- }
+ 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());
+ }
- 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");
- }
- }
+ return createFeedResponseDocument.getCreateFeedResponse();
+ } catch (XmlException e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
- public OMElement fetchFeed(String url) throws SavanException {
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
+ public void deleteFeed(EndpointReference epr) throws AxisFault {
+ serviceClient.getOptions().setAction(AtomConstants.Actions.Unsubscribe);
+ serviceClient.getOptions().setTo(epr);
- // Create a method instance.
- GetMethod method = new GetMethod(url);
+ OMElement request = OMAbstractFactory.getOMFactory().createOMElement(
+ new QName(AtomConstants.ATOM_MSG_NAMESPACE, "DeleteFeed"));
+ serviceClient.sendReceive(request);
+ }
- try {
- // Execute the method.
- int statusCode = client.executeMethod(method);
+ 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");
+ }
+ }
- if (statusCode != HttpStatus.SC_OK) {
- throw new SavanException("Method failed: " + method.getStatusLine());
- }
+ public OMElement fetchFeed(String url) throws SavanException {
+ // Create an instance of HttpClient.
+ HttpClient client = new HttpClient();
- // Read the response body.
- byte[] responseBody = method.getResponseBody();
+ // Create a method instance.
+ GetMethod method = new GetMethod(url);
- StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(
- responseBody));
- return builder.getDocumentElement();
- } catch (IOException e) {
- throw new SavanException(e);
- } catch (XMLStreamException e) {
- throw new SavanException(e);
- } finally {
- // Release the connection.
- method.releaseConnection();
- }
- }
+ try {
+ // Execute the method.
+ int statusCode = client.executeMethod(method);
- public void publishWithREST(String serviceurl, final OMElement content,String topic)
- throws SavanException {
- // Create an instance of HttpClient.
- HttpClient client = new HttpClient();
+ if (statusCode != HttpStatus.SC_OK) {
+ throw new SavanException("Method failed: " + method.getStatusLine());
+ }
- StringBuffer queryUrl = new StringBuffer(serviceurl);
-
- if(!serviceurl.endsWith("/")){
- queryUrl.append("/");
- }
- queryUrl.append("publish");
- if(topic != null ){
- queryUrl.append("?").append(EventingConstants.ElementNames.Topic).append("=").append(topic);
- }
- PostMethod method = new PostMethod(queryUrl.toString());
- // Request content will be retrieved directly
- // from the input stream
- try {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- content.serialize(out);
- out.flush();
- final byte[] data = out.toByteArray();
+ // Read the response body.
+ byte[] responseBody = method.getResponseBody();
- RequestEntity entity = new RequestEntity() {
+ StAXOMBuilder builder = new StAXOMBuilder(new ByteArrayInputStream(
+ responseBody));
+ return builder.getDocumentElement();
+ } catch (IOException e) {
+ throw new SavanException(e);
+ } catch (XMLStreamException e) {
+ throw new SavanException(e);
+ } finally {
+ // Release the connection.
+ method.releaseConnection();
+ }
+ }
- public void writeRequest(OutputStream outstream)
- throws IOException {
- outstream.write(data);
- }
+ public void publishWithREST(String serviceurl, final OMElement content, String topic)
+ throws SavanException {
+ // Create an instance of HttpClient.
+ HttpClient client = new HttpClient();
- public boolean isRepeatable() {
- return false;
- }
+ StringBuffer queryUrl = new StringBuffer(serviceurl);
- public String getContentType() {
- return "text/xml";
- }
+ if (!serviceurl.endsWith("/")) {
+ queryUrl.append("/");
+ }
+ queryUrl.append("publish");
+ if (topic != null) {
+ queryUrl.append("?").append(EventingConstants.ElementNames.Topic).append("=")
+ .append(topic);
+ }
+ PostMethod method = new PostMethod(queryUrl.toString());
+ // Request content will be retrieved directly
+ // from the input stream
+ try {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ content.serialize(out);
+ out.flush();
+ final byte[] data = out.toByteArray();
- public long getContentLength() {
- return data.length;
- }
+ RequestEntity entity = new RequestEntity() {
- };
- method.setRequestEntity(entity);
+ public void writeRequest(OutputStream outstream)
+ throws IOException {
+ outstream.write(data);
+ }
- // Execute the method.
- int statusCode = client.executeMethod(method);
+ public boolean isRepeatable() {
+ return false;
+ }
- if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_ACCEPTED) {
- throw new SavanException("Method failed: " + method.getStatusLine());
- }
+ public String getContentType() {
+ return "text/xml";
+ }
- } catch (IOException e) {
- throw new SavanException(e);
- } catch (XMLStreamException e) {
- throw new SavanException(e);
- } finally {
- // Release the connection.
- method.releaseConnection();
- }
- }
-
- public void publishWithSOAP(String serviceurl, final OMElement content,String topic) throws SavanException{
- try {
- Options options = serviceClient.getOptions();
- EndpointReference to = new EndpointReference(serviceurl);
- if(topic != null){
- to.addReferenceParameter(new QName(EventingConstants.EXTENDED_EVENTING_NAMESPACE,
- EventingConstants.ElementNames.Topic), topic);
- }
- options.setAction(EventingConstants.Actions.Publish);
- serviceClient.fireAndForget(content);
- } catch (AxisFault e) {
- throw new SavanException(e);
- }
- }
-
+ public long getContentLength() {
+ return data.length;
+ }
+
+ };
+ method.setRequestEntity(entity);
+
+ // Execute the method.
+ int statusCode = client.executeMethod(method);
+
+ if (statusCode != HttpStatus.SC_OK && statusCode != HttpStatus.SC_ACCEPTED) {
+ throw new SavanException("Method failed: " + method.getStatusLine());
+ }
+
+ } catch (IOException e) {
+ throw new SavanException(e);
+ } catch (XMLStreamException e) {
+ throw new SavanException(e);
+ } finally {
+ // Release the connection.
+ method.releaseConnection();
+ }
+ }
+
+ public void publishWithSOAP(String serviceurl, final OMElement content, String topic)
+ throws SavanException {
+ try {
+ Options options = serviceClient.getOptions();
+ EndpointReference to = new EndpointReference(serviceurl);
+ if (topic != null) {
+ to.addReferenceParameter(new QName(EventingConstants.EXTENDED_EVENTING_NAMESPACE,
+ EventingConstants.ElementNames.Topic), topic);
+ }
+ options.setAction(EventingConstants.Actions.Publish);
+ serviceClient.fireAndForget(content);
+ } catch (AxisFault e) {
+ throw new SavanException(e);
+ }
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiver.java b/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiver.java
index 4b2498d..ef06cd8 100644
--- a/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiver.java
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiver.java
@@ -1,26 +1,9 @@
package org.apache.savan.atom;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.servlet.http.HttpServletRequest;
-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.OMException;
-import org.apache.axiom.om.impl.builder.StAXBuilder;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.util.StAXUtils;
-import org.apache.axiom.soap.SOAP11Constants;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPProcessingException;
+import org.apache.axiom.soap.*;
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.AxisEngine;
@@ -31,51 +14,50 @@
import org.apache.savan.storage.SubscriberStore;
import org.apache.savan.util.CommonUtil;
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+
/**
* Handle the HTTP GET requests for feeds
+ *
* @author Srinath Perera(hemapani@apache.org)
*/
-public class AtomMessageReceiver implements MessageReceiver{
-
- public static final String ATOM_NAME = "atom";
+public class AtomMessageReceiver implements MessageReceiver {
- public void receive(MessageContext messageCtx) throws AxisFault {
-
- try {
- //String resourcePath = messageCtx.getTo().getAddress();
- //http://127.0.0.1:5555/axis2/services/PublisherService/atom?a=urn_uuid_96C2CB953DABC98DFC1179904343537.atom
+ public static final String ATOM_NAME = "atom";
-
-
- HttpServletRequest request = (HttpServletRequest)messageCtx.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
- if(request == null || HTTPConstants.HEADER_GET.equals(request.getMethod()) || HTTPConstants.HEADER_POST.equals(request.getMethod())){
- SOAPEnvelope envlope = messageCtx.getEnvelope();
- OMElement bodyContent = envlope.getBody().getFirstElement();
-
- OMElement feedID = bodyContent.getFirstElement();
-
-
-
-
- String feedIDAsUrn = feedID.getText().replaceAll("_", ":").replaceAll(".atom", "");
-
- SubscriberStore store = CommonUtil.getSubscriberStore(messageCtx.getAxisService());
- if (store == null)
- throw new AxisFault ("Cant find the Savan subscriber store");
-
-
- AtomSubscriber subscriber = (AtomSubscriber)store.retrieve(feedIDAsUrn);
-
- SOAPFactory fac = getSOAPFactory(messageCtx);
- SOAPEnvelope envelope = fac.getDefaultEnvelope();
+ public void receive(MessageContext messageCtx) throws AxisFault {
- OMElement result = subscriber.getFeedAsXml();
-
-
-
-
-
+ try {
+ //String resourcePath = messageCtx.getTo().getAddress();
+ //http://127.0.0.1:5555/axis2/services/PublisherService/atom?a=urn_uuid_96C2CB953DABC98DFC1179904343537.atom
+
+
+ HttpServletRequest request = (HttpServletRequest)messageCtx
+ .getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST);
+ if (request == null || HTTPConstants.HEADER_GET.equals(request.getMethod()) ||
+ HTTPConstants.HEADER_POST.equals(request.getMethod())) {
+ SOAPEnvelope envlope = messageCtx.getEnvelope();
+ OMElement bodyContent = envlope.getBody().getFirstElement();
+
+ OMElement feedID = bodyContent.getFirstElement();
+
+
+ String feedIDAsUrn = feedID.getText().replaceAll("_", ":").replaceAll(".atom", "");
+
+ SubscriberStore store = CommonUtil.getSubscriberStore(messageCtx.getAxisService());
+ if (store == null)
+ throw new AxisFault("Cant find the Savan subscriber store");
+
+
+ AtomSubscriber subscriber = (AtomSubscriber)store.retrieve(feedIDAsUrn);
+
+ SOAPFactory fac = getSOAPFactory(messageCtx);
+ SOAPEnvelope envelope = fac.getDefaultEnvelope();
+
+ OMElement result = subscriber.getFeedAsXml();
+
// String pathWRTRepository = "atom/"+feedID.getText();
//
// File atomFile = messageCtx.getConfigurationContext().getRealPath(pathWRTRepository);
@@ -106,50 +88,50 @@
// }
// FileInputStream atomIn = new FileInputStream(atomFile);
-
- //add the content of the file to the response
+ //add the content of the file to the response
// XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader
// (atomIn, MessageContext.DEFAULT_CHAR_SET_ENCODING);
// StAXBuilder builder = new StAXOMBuilder(fac,xmlreader);
// OMElement result = (OMElement) builder.getDocumentElement();
- envelope.getBody().addChild(result);
-
- //send beck the response
- MessageContext outMsgContext = MessageContextBuilder.createOutMessageContext(messageCtx);
- outMsgContext.getOperationContext().addMessageContext(outMsgContext);
- outMsgContext.setEnvelope(envelope);
-
- AxisEngine engine =
- new AxisEngine(
- outMsgContext.getConfigurationContext());
- engine.send(outMsgContext);
+ envelope.getBody().addChild(result);
- }else if(HTTPConstants.HEADER_POST.equals(request.getMethod())){
- SOAPEnvelope envlope = messageCtx.getEnvelope();
- OMElement bodyContent = envlope.getBody().getFirstElement();
-
- OMElement feedID = bodyContent.getFirstElement();
- String pathWRTRepository = "atom/"+feedID.getText();
+ //send beck the response
+ MessageContext outMsgContext =
+ MessageContextBuilder.createOutMessageContext(messageCtx);
+ outMsgContext.getOperationContext().addMessageContext(outMsgContext);
+ outMsgContext.setEnvelope(envelope);
- //remove the file
- File atomFile = messageCtx.getConfigurationContext().getRealPath(pathWRTRepository);
- atomFile.delete();
-
- //remove the feed from subscriber store
- String feedIDAsUrn = feedID.getText().replaceAll("_", ":");
- SubscriberStore store = CommonUtil.getSubscriberStore(messageCtx.getAxisService());
- if (store == null)
- throw new AxisFault ("Cant find the Savan subscriber store");
- store.delete(feedIDAsUrn);
- }
-
- } catch (SOAPProcessingException e) {
- e.printStackTrace();
- throw AxisFault.makeFault(e);
-
- } catch (OMException e) {
- e.printStackTrace();
- throw AxisFault.makeFault(e);
+ AxisEngine engine =
+ new AxisEngine(
+ outMsgContext.getConfigurationContext());
+ engine.send(outMsgContext);
+
+ } else if (HTTPConstants.HEADER_POST.equals(request.getMethod())) {
+ SOAPEnvelope envlope = messageCtx.getEnvelope();
+ OMElement bodyContent = envlope.getBody().getFirstElement();
+
+ OMElement feedID = bodyContent.getFirstElement();
+ String pathWRTRepository = "atom/" + feedID.getText();
+
+ //remove the file
+ File atomFile = messageCtx.getConfigurationContext().getRealPath(pathWRTRepository);
+ atomFile.delete();
+
+ //remove the feed from subscriber store
+ String feedIDAsUrn = feedID.getText().replaceAll("_", ":");
+ SubscriberStore store = CommonUtil.getSubscriberStore(messageCtx.getAxisService());
+ if (store == null)
+ throw new AxisFault("Cant find the Savan subscriber store");
+ store.delete(feedIDAsUrn);
+ }
+
+ } catch (SOAPProcessingException e) {
+ e.printStackTrace();
+ throw AxisFault.makeFault(e);
+
+ } catch (OMException e) {
+ e.printStackTrace();
+ throw AxisFault.makeFault(e);
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// throw new AxisFault(e);
@@ -159,18 +141,18 @@
// } catch (URISyntaxException e) {
// e.printStackTrace();
// throw new AxisFault(e);
- }
- }
-
- public SOAPFactory getSOAPFactory(MessageContext msgContext) throws AxisFault {
- String nsURI = msgContext.getEnvelope().getNamespace().getNamespaceURI();
- if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(nsURI)) {
- return OMAbstractFactory.getSOAP12Factory();
- } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(nsURI)) {
- return OMAbstractFactory.getSOAP11Factory();
- } else {
- throw new AxisFault(Messages.getMessage("invalidSOAPversion"));
- }
- }
+ }
+ }
+
+ public SOAPFactory getSOAPFactory(MessageContext msgContext) throws AxisFault {
+ String nsURI = msgContext.getEnvelope().getNamespace().getNamespaceURI();
+ if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(nsURI)) {
+ return OMAbstractFactory.getSOAP12Factory();
+ } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(nsURI)) {
+ return OMAbstractFactory.getSOAP11Factory();
+ } else {
+ throw new AxisFault(Messages.getMessage("invalidSOAPversion"));
+ }
+ }
}
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
index ecf9d96..6f1d0f3 100644
--- a/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiverDeligater.java
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomMessageReceiverDeligater.java
@@ -17,11 +17,9 @@
package org.apache.savan.atom;
-import java.util.Calendar;
-import java.util.Date;
-
-import javax.xml.namespace.QName;
-
+import com.wso2.eventing.atom.CreateFeedResponseDocument;
+import com.wso2.eventing.atom.CreateFeedResponseDocument.CreateFeedResponse;
+import com.wso2.eventing.atom.RenewFeedResponseDocument;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
@@ -43,194 +41,222 @@
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;
+import javax.xml.namespace.QName;
+import java.util.Calendar;
+import java.util.Date;
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;
- }
-
-
+ private SOAPEnvelope findOrCreateSoapEnvelope(SavanMessageContext subscriptionMessage,
+ MessageContext outMessage) throws AxisFault {
+ MessageContext subscriptionMsgCtx = subscriptionMessage.getMessageContext();
- 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);
+ SOAPEnvelope outMessageEnvelope = outMessage.getEnvelope();
+ SOAPFactory factory = null;
- 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");
- }
-
+ 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);
- }
- }
+ 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 handleGetStatusRequest(SavanMessageContext getStatusMessage, MessageContext outMessage) throws SavanException {
+ public void handleRenewRequest(SavanMessageContext renewMessage, 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){
+ 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){
+
+ if (value instanceof String) {
c.insertChars((String)value);
- }else {
+ } 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();
@@ -240,35 +266,32 @@
}
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,
+ 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
- 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
index 35adc57..e5f7903 100644
--- a/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriber.java
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriber.java
@@ -1,14 +1,5 @@
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;
@@ -18,43 +9,49 @@
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 AtomDataSource atomDataSource;
- private URI id;
-
- public void init(AtomDataSource dataSource,URI id,String title,String author) throws SavanException{
- this.atomDataSource = dataSource;
- atomDataSource.addFeed(id.toString(), title, new Date(), author);
- }
-
-
-
- public URI getId() {
- return id;
- }
- public void renewSubscription(ExpirationBean bean) {
- throw new UnsupportedOperationException();
- }
- public void sendEventData(OMElement eventData) throws SavanException {
+import java.io.File;
+import java.net.URI;
+import java.util.Date;
+
+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 AtomDataSource atomDataSource;
+ private URI id;
+
+ public void init(AtomDataSource dataSource, URI id, String title, String author)
+ throws SavanException {
+ this.atomDataSource = dataSource;
+ atomDataSource.addFeed(id.toString(), title, new Date(), 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);
- }
-
- atomDataSource.addEntry(id.toString(), eventData);
+ Date date = new Date();
+
+ boolean expired = false;
+ if (subscriptionEndingTime != null && date.after(subscriptionEndingTime))
+ expired = true;
+
+ if (expired) {
+ String message = "Cant notify the listener since the subscription has been expired";
+ log.debug(message);
+ }
+
+ atomDataSource.addEntry(id.toString(), eventData);
//
// if(feed == null){
// feed = new Feed(title,id.toString(),author);
@@ -75,23 +72,20 @@
// } catch (IOException e) {
// throw new SavanException(e);
// }
- }
- public void setId(URI id) {
- this.id = id;
- }
-
-
-
-
+ }
+
+ public void setId(URI id) {
+ this.id = id;
+ }
- public void setSubscriptionEndingTime(Date subscriptionEndingTime) {
- this.subscriptionEndingTime = subscriptionEndingTime;
- }
+ public void setSubscriptionEndingTime(Date subscriptionEndingTime) {
+ this.subscriptionEndingTime = subscriptionEndingTime;
+ }
- public void setEndToEPr(EndpointReferenceType endToEPR) {
- throw new UnsupportedOperationException();
- }
+ public void setEndToEPr(EndpointReferenceType endToEPR) {
+ throw new UnsupportedOperationException();
+ }
// public String getAuthor() {
// return author;
@@ -109,36 +103,41 @@
// 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;
- }
+
+ 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;
+ }
// public Feed getFeed() {
// return feed;
-// }
- public OMElement getFeedAsXml() throws SavanException {
- return atomDataSource.getFeedAsXml(id.toString());
- }
+
+ // }
+ public OMElement getFeedAsXml() throws SavanException {
+ return atomDataSource.getFeedAsXml(id.toString());
+ }
// public void setAtomDataSource(AtomDataSource atomDataSource) {
// this.atomDataSource = atomDataSource;
// }
-
-
+
+
}
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
index 8105462..47de7d3 100644
--- a/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomSubscriptionProcessor.java
@@ -17,12 +17,9 @@
package org.apache.savan.atom;
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import javax.xml.namespace.QName;
-
+import com.wso2.eventing.atom.CreateFeedDocument;
+import com.wso2.eventing.atom.CreateFeedDocument.CreateFeed;
+import com.wso2.eventing.atom.RenewFeedDocument;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.util.UUIDGenerator;
@@ -43,22 +40,21 @@
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;
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
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);
- }
-
-
-
+ 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);
+ }
+
// AtomSubscriber atomSubscriber = new AtomSubscriber();
// smc.setProperty(AtomConstants.TransferedProperties.SUBSCRIBER_UUID,id);
// atomSubscriber.setId(new URI(id));
@@ -66,133 +62,134 @@
// atomSubscriber.setAtomFile(new File(realAtomPath,atomFeedPath));
// atomSubscriber.setAuthor("DefaultUser");
// atomSubscriber.setTitle("default Feed");
-
- }
-
- /**
- * 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;
-
- ServiceContext serviceContext = smc.getMessageContext().getServiceContext();
- AtomDataSource dataSource = (AtomDataSource)serviceContext.getProperty(AtomConstants.Properties.DataSource);
- if(dataSource == null){
- dataSource = new AtomDataSource();
- serviceContext.setProperty(AtomConstants.Properties.DataSource, dataSource);
- }
-
- 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 = id2Path(id);
- atomSubscriber.setAtomFile(new File(realAtomPath,atomFeedPath));
- atomSubscriber.setFeedUrl(serviceAddress+"/services/"+smc.getMessageContext().getServiceContext().getAxisService().getName() +"/atom?feed="+ atomFeedPath);
-
- SOAPBody body = envelope.getBody();
- CreateFeedDocument createFeedDocument = CreateFeedDocument.Factory.parse(body.getFirstElement().getXMLStreamReader());
- CreateFeed createFeed = createFeedDocument.getCreateFeed();
+ /**
+ * 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>
+ */
- 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);
- }
-
- atomSubscriber.init(dataSource, new URI(id), createFeed.getTitle(), createFeed.getAuthor());
- 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);
- }
- }
-
+
+ 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;
+
+ ServiceContext serviceContext = smc.getMessageContext().getServiceContext();
+ AtomDataSource dataSource =
+ (AtomDataSource)serviceContext.getProperty(AtomConstants.Properties.DataSource);
+ if (dataSource == null) {
+ dataSource = new AtomDataSource();
+ serviceContext.setProperty(AtomConstants.Properties.DataSource, dataSource);
+ }
+
+ 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 = id2Path(id);
+ atomSubscriber.setAtomFile(new File(realAtomPath, atomFeedPath));
+ atomSubscriber.setFeedUrl(serviceAddress + "/services/" + smc.getMessageContext()
+ .getServiceContext().getAxisService().getName() + "/atom?feed=" + atomFeedPath);
+
+ SOAPBody body = envelope.getBody();
+ CreateFeedDocument createFeedDocument =
+ CreateFeedDocument.Factory.parse(body.getFirstElement().getXMLStreamReader());
+ CreateFeed createFeed = createFeedDocument.getCreateFeed();
+
+ 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);
+ }
+
+ atomSubscriber
+ .init(dataSource, new URI(id), createFeed.getTitle(), createFeed.getAuthor());
+ 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 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);
@@ -207,69 +204,76 @@
// }
// }
- public void pauseSubscription(SavanMessageContext pauseSubscriptionMessage) throws SavanException {
- throw new UnsupportedOperationException ("Eventing specification does not support this type of messages");
- }
+ 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 void resumeSubscription(SavanMessageContext resumeSubscriptionMessage)
+ throws SavanException {
+ throw new UnsupportedOperationException(
+ "Eventing specification does not support this type of messages");
+ }
- public ExpirationBean getExpirationBean(SavanMessageContext renewMessage) throws SavanException {
- try {
- SOAPEnvelope envelope = renewMessage.getEnvelope();
-
- RenewFeedDocument renewFeedDocument = RenewFeedDocument.Factory.parse( envelope.getBody().getXMLStreamReader());
+ /** <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();
+ 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);
- }
- }
+ expirationBean.setDuration(false);
+ expirationBean.setDateValue(renewFeedDocument.getRenewFeed().getExpires().getTime());
- 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);
- }
+ String subscriberID = getSubscriberID(renewMessage);
+ if (subscriberID == null) {
+ String message = "Cannot find the subscriber ID";
+ throw new SavanException(message);
+ }
- public void unsubscribe(SavanMessageContext endSubscriptionMessage) throws SavanException {
- String subscriberID = getSubscriberID (endSubscriptionMessage);
- File feedPath = endSubscriptionMessage.getConfigurationContext().getRealPath("atom/"+id2Path(subscriberID));
- if(feedPath.exists()){
- feedPath.delete();
- }
- super.unsubscribe(endSubscriptionMessage);
- }
-
- private String id2Path(String id){
- return id.replaceAll(":", "_")+ ".atom";
+ 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);
+ }
+
+ public void unsubscribe(SavanMessageContext endSubscriptionMessage) throws SavanException {
+ String subscriberID = getSubscriberID(endSubscriptionMessage);
+ File feedPath = endSubscriptionMessage.getConfigurationContext()
+ .getRealPath("atom/" + id2Path(subscriberID));
+ if (feedPath.exists()) {
+ feedPath.delete();
+ }
+ super.unsubscribe(endSubscriptionMessage);
+ }
+
+ private String id2Path(String id) {
+ return id.replaceAll(":", "_") + ".atom";
}
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
index 0801849..8562300 100644
--- a/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java
+++ b/modules/core/src/main/java/org/apache/savan/atom/AtomUtilFactory.java
@@ -26,51 +26,48 @@
import org.apache.savan.util.UtilFactory;
public class AtomUtilFactory implements UtilFactory {
-
- public AtomUtilFactory(){
-
- }
-
-
- /**
- * 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 AtomUtilFactory() {
- public SubscriptionProcessor createSubscriptionProcessor() {
- return new AtomSubscriptionProcessor ();
- }
-
- public MessageReceiverDeligater createMessageReceiverDeligater() {
- return new AtomMessageReceiverDeligater ();
- }
+ }
- public Subscriber createSubscriber() {
- return new AtomSubscriber ();
- }
-
+
+ /** 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
index aea30a4..2bdee5d 100644
--- a/modules/core/src/main/java/org/apache/savan/atom/Feed.java
+++ b/modules/core/src/main/java/org/apache/savan/atom/Feed.java
@@ -1,29 +1,24 @@
package org.apache.savan.atom;
+import org.apache.axiom.om.*;
+
+import javax.xml.stream.XMLStreamException;
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;
-
+ 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>
@@ -54,59 +49,62 @@
// </content>
// </entry>
// </feed>
-
-
- public Feed(String title, String id, String author,Date lastUpdated) {
- this.title = title;
- if(title != null){
- title = title.trim();
- }
- if(author != null){
- author = author.trim();
- }
-
- this.id = id;
- this.author = author;
- if(lastUpdated == null){
- 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(title);
- }
- 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("entry" + 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","text/xml",null);
- contentEle.addChild(entry);
-
-
-
- document.getOMDocumentElement().addChild(entryEle);
- }
-
- public void write(OutputStream out) throws XMLStreamException{
- document.serialize(out);
- }
-
+
+
+ public Feed(String title, String id, String author, Date lastUpdated) {
+ this.title = title;
+ if (title != null) {
+ title = title.trim();
+ }
+ if (author != null) {
+ author = author.trim();
+ }
+
+ this.id = id;
+ this.author = author;
+ if (lastUpdated == null) {
+ 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(title);
+ }
+ 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("entry" + 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", "text/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()));
@@ -115,12 +113,13 @@
// System.out.flush();
//
// }
-
- public OMElement getFeedAsXml(){
- return document.getOMDocumentElement();
- }
- public OMFactory getFactory() {
- return factory;
- }
-
+
+ public OMElement getFeedAsXml() {
+ return document.getOMDocumentElement();
+ }
+
+ public OMFactory getFactory() {
+ return factory;
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/configuration/ConfigurationManager.java b/modules/core/src/main/java/org/apache/savan/configuration/ConfigurationManager.java
index 2df0066..0c0f439 100644
--- a/modules/core/src/main/java/org/apache/savan/configuration/ConfigurationManager.java
+++ b/modules/core/src/main/java/org/apache/savan/configuration/ConfigurationManager.java
@@ -17,18 +17,6 @@
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 java.util.Map;
-
-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;
@@ -39,378 +27,399 @@
import org.apache.savan.filters.Filter;
import org.apache.savan.storage.SubscriberStore;
import org.apache.savan.subscribers.Subscriber;
-import org.apache.savan.subscribers.Subscriber;
import org.apache.savan.util.UtilFactory;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+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 java.util.Map;
+
/**
- * This is responsible for loading Savan configuration data from a resource
- * for e.g. from a savan-config.xml fie
+ * 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 HashMap filterMap = null;
- private HashMap subscribersMap = null;
-
- private final String SAVAN_CONFIG = "savan-config";
- private final String PROTOCOLS = "protocols";
- private final String PROTOCOL = "protocol";
- private final String NAME = "name";
- private final String UTIL_FACTORY = "utilFactory";
- private final String MAPPING_RULES = "mapping-rules";
- private final String ACTION = "action";
- private final String SUBSCRIBER_STORES = "subscriberStores";
- private final String SUBSCRIBER_STORE = "subscriberStore";
- private final String FILTERS = "filters";
- private final String FILTER = "filter";
- private final String KEY = "key";
- private final String CLASS = "class";
- private final String IDENTIFIER = "identifier";
- private final String SUBSCRIBERS = "subscribers";
- private final String SUBSCRIBER = "subscriber";
- private final String URL_APPENDER = "urlAppender";
- private final String DEFAULT_SUBSCRIBER = "defaultSubscriber";
- private final String DEFAULT_FILTER = "defaultFilter";
-
-
- public ConfigurationManager () {
- protocolMap = new HashMap ();
- subscriberStoreNamesMap = new HashMap ();
- filterMap = new HashMap ();
- subscribersMap = new HashMap ();
- }
-
- /**
- * To load configurations from a savan-config.xml file in the classpath.
- *
- * @throws SavanException
- */
- public void configure () throws SavanException {
- ClassLoader classLoader = getClass().getClassLoader();
- configure(classLoader);
- }
-
- public void configure (ClassLoader classLoader) throws SavanException {
- InputStream in = classLoader.getResourceAsStream(SavanConstants.CONFIG_FILE);
+ private HashMap protocolMap = null;
+ private HashMap subscriberStoreNamesMap = null;
+ private HashMap filterMap = null;
+ private HashMap subscribersMap = null;
- if (in==null)
- throw new SavanException ("Cannot find the savan configuration file. Initialation cannot continue.");
-
- 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 {
+ private final String SAVAN_CONFIG = "savan-config";
+ private final String PROTOCOLS = "protocols";
+ private final String PROTOCOL = "protocol";
+ private final String NAME = "name";
+ private final String UTIL_FACTORY = "utilFactory";
+ private final String MAPPING_RULES = "mapping-rules";
+ private final String ACTION = "action";
+ private final String SUBSCRIBER_STORES = "subscriberStores";
+ private final String SUBSCRIBER_STORE = "subscriberStore";
+ private final String FILTERS = "filters";
+ private final String FILTER = "filter";
+ private final String KEY = "key";
+ private final String CLASS = "class";
+ private final String IDENTIFIER = "identifier";
+ private final String SUBSCRIBERS = "subscribers";
+ private final String SUBSCRIBER = "subscriber";
+ private final String URL_APPENDER = "urlAppender";
+ private final String DEFAULT_SUBSCRIBER = "defaultSubscriber";
+ private final String DEFAULT_FILTER = "defaultFilter";
- if (in==null) {
- String message = "Invalid InputStream.";
- 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 (!SAVAN_CONFIG.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 (SUBSCRIBER_STORES));
- if (subscriberStoresElement==null) {
- throw new SavanException ("'subscriberStores' element should be present, as a sub-element of the 'savan-config' element");
- }
- processSubscriberStores(subscriberStoresElement);
-
- OMElement filtersElement = element.getFirstChildWithName(new QName (FILTERS));
- if (subscriberStoresElement==null) {
- throw new SavanException ("'Filters' element should be present, as a sub-element of the 'savan-config' element");
- }
- processFilters (filtersElement);
-
- OMElement subscribersElement = element.getFirstChildWithName(new QName (SUBSCRIBERS));
- if (subscriberStoresElement==null) {
- throw new SavanException ("'Subscribers' element should be present as a sub-element of the 'savan-config' element");
- }
- processSubscribers (subscribersElement);
-
- }
-
- 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 (UTIL_FACTORY));
- 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 (MAPPING_RULES));
- if (mappingRulesElement==null)
- throw new SavanException ("Protocol must have a 'mappingRules' sub-element");
- processMappingRules (mappingRulesElement,protocol);
-
- OMElement defaultSubscriberElement = element.getFirstChildWithName(new QName (DEFAULT_SUBSCRIBER));
- if (defaultSubscriberElement==null)
- throw new SavanException ("Protocols must have a 'defaultSubscriber' sub-element");
- String defaultSubscriber = defaultSubscriberElement.getText();
- protocol.setDefaultSubscriber(defaultSubscriber);
-
- OMElement defaultFilterElement = element.getFirstChildWithName(new QName (DEFAULT_FILTER));
- if (defaultFilterElement==null)
- throw new SavanException ("Protocols must have a 'defaultFilter' sub-element");
- String defaultFilter = defaultFilterElement.getText();
- protocol.setDefaultFilter(defaultFilter);
-
- protocolMap.put(protocol.getName(),protocol);
- }
-
- private void processMappingRules (OMElement element, Protocol protocol) {
-
- MappingRules mappingRules = protocol.getMappingRules();
-
- Iterator actionsIterator = element.getChildrenWithName(new QName (ACTION));
- while (actionsIterator.hasNext()) {
- OMElement actionElement = (OMElement) actionsIterator.next();
- String action = actionElement.getText();
- mappingRules.addRule(MappingRules.MAPPING_TYPE_ACTION, action);
- }
-
- }
-
- private void processSubscriberStores (OMElement element) throws SavanException {
- Iterator subscriberStoreElementsIterator = element.getChildrenWithName(new QName (SUBSCRIBER_STORE));
- 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 (CLASS));
- if (classElement==null)
- throw new SavanException ("SubscriberStore must have a 'Clazz' subelement'");
-
- String clazz = classElement.getText();
-
- //initialize the class to check weather it is value
- Object obj = getObject(clazz);
-
- if (!(obj instanceof SubscriberStore)) {
- String message = "Class " + clazz + " does not implement the SubscriberStore interface.";
- throw new SavanException (message);
- }
-
- subscriberStoreNamesMap.put(key,clazz);
- }
- public HashMap getProtocolMap () {
- return protocolMap;
- }
-
- public Protocol getProtocol (String name) {
- return (Protocol) protocolMap.get(name);
- }
-
- public SubscriberStore getSubscriberStoreInstance (String key) throws SavanException {
- String name = (String) subscriberStoreNamesMap.get(key);
- return (SubscriberStore) getObject(name);
- }
-
- public Filter getFilterInstanceFromName (String name) throws SavanException {
- for (Iterator it=filterMap.keySet().iterator();it.hasNext();) {
- String key = (String) it.next();
- FilterBean filterBean = (FilterBean) filterMap.get(key);
- if (name.equals(filterBean.getName()))
- return (Filter) getObject(filterBean.getClazz());
- }
-
- return null;
- }
-
- public Filter getFilterInstanceFromId (String id) throws SavanException {
- FilterBean filterBean = (FilterBean) filterMap.get(id);
- String filterClass = filterBean.getClazz();
- if (filterClass==null)
- return null;
-
- return (Filter) getObject(filterClass);
- }
-
- 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;
- }
-
- private void processFilters (OMElement element) throws SavanException {
- Iterator filterElementsIterator = element.getChildrenWithName(new QName (FILTER));
- while (filterElementsIterator.hasNext()) {
- OMElement filterElement = (OMElement) filterElementsIterator.next();
- processFilter (filterElement);
- }
- }
-
- private void processFilter (OMElement element) throws SavanException {
- OMElement nameElement = element.getFirstChildWithName(new QName (NAME));
- OMElement identifierElement = element.getFirstChildWithName(new QName (IDENTIFIER));
- OMElement classElement = element.getFirstChildWithName(new QName (CLASS));
-
- if (nameElement==null)
- throw new SavanException ("Name element is not present within the Filter");
- if (identifierElement==null)
- throw new SavanException ("Identifier element is not present within the Filter");
- if (classElement==null)
- throw new SavanException ("Class element is not present within the Filter");
-
- String name = nameElement.getText();
- String identifier = identifierElement.getText();
- String clazz = classElement.getText();
-
- //initialize the class to check weather it is value
- Object obj = getObject(clazz);
-
- if (!(obj instanceof Filter)) {
- String message = "Class " + clazz + " does not implement the Filter interface.";
- throw new SavanException (message);
- }
-
- FilterBean bean = new FilterBean ();
- bean.setName(name);
- bean.setIdentifier(identifier);
- bean.setClazz(clazz);
-
- filterMap.put(identifier,bean);
- }
-
- private void processSubscribers (OMElement element) throws SavanException {
- Iterator subscriberElementsIterator = element.getChildrenWithName(new QName (SUBSCRIBER));
- while (subscriberElementsIterator.hasNext()) {
- OMElement subscriberElement = (OMElement) subscriberElementsIterator.next();
- processSubscriber (subscriberElement);
- }
- }
-
- private void processSubscriber (OMElement element) throws SavanException {
- OMElement nameElement = element.getFirstChildWithName(new QName (NAME));
- OMElement urlAppenderElement = element.getFirstChildWithName(new QName (URL_APPENDER));
- OMElement classElement = element.getFirstChildWithName(new QName (CLASS));
-
- if (nameElement==null)
- throw new SavanException ("Name element is not present within the AbstractSubscriber");
- if (classElement==null)
- throw new SavanException ("Class element is not present within the Filter");
-
- String name = nameElement.getText();
- String clazz = classElement.getText();
-
- //initialize the class to check weather it is valid
- Object obj = getObject(clazz);
-
- if (!(obj instanceof Subscriber)) {
- String message = "Class " + clazz + " does not implement the Subscriber interface.";
- throw new SavanException (message);
- }
-
- SubscriberBean bean = new SubscriberBean ();
- bean.setName(name);
- bean.setClazz(clazz);
-
- subscribersMap.put(name,bean);
- }
-
- public Map getSubscriberBeans () {
- return subscribersMap;
- }
-
- public Map getFilterBeans () {
- return filterMap;
- }
-
- public SubscriberBean getSubscriberBean (String subscriberName) {
- return (SubscriberBean) subscribersMap.get(subscriberName);
- }
-
- public Subscriber getSubscriberInstance (String subscriberName) throws SavanException {
- SubscriberBean subscriberBean = (SubscriberBean) subscribersMap.get(subscriberName);
- if (subscriberBean==null) {
- String message = "A subscriber with the name '" + subscriberName + "' was not found.";
- throw new SavanException (message);
- }
-
- return (Subscriber) getObject(subscriberBean.getClazz());
+ public ConfigurationManager() {
+ protocolMap = new HashMap();
+ subscriberStoreNamesMap = new HashMap();
+ filterMap = new HashMap();
+ subscribersMap = new HashMap();
+ }
+
+ /**
+ * To load configurations from a savan-config.xml file in the classpath.
+ *
+ * @throws SavanException
+ */
+ public void configure() throws SavanException {
+ ClassLoader classLoader = getClass().getClassLoader();
+
+ configure(classLoader);
+ }
+
+ public void configure(ClassLoader classLoader) throws SavanException {
+ InputStream in = classLoader.getResourceAsStream(SavanConstants.CONFIG_FILE);
+
+ if (in == null)
+ throw new SavanException(
+ "Cannot find the savan configuration file. Initialation cannot continue.");
+
+ 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 = "Invalid InputStream.";
+ 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 (!SAVAN_CONFIG.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(SUBSCRIBER_STORES));
+ if (subscriberStoresElement == null) {
+ throw new SavanException(
+ "'subscriberStores' element should be present, as a sub-element of the 'savan-config' element");
+ }
+ processSubscriberStores(subscriberStoresElement);
+
+ OMElement filtersElement = element.getFirstChildWithName(new QName(FILTERS));
+ if (subscriberStoresElement == null) {
+ throw new SavanException(
+ "'Filters' element should be present, as a sub-element of the 'savan-config' element");
+ }
+ processFilters(filtersElement);
+
+ OMElement subscribersElement = element.getFirstChildWithName(new QName(SUBSCRIBERS));
+ if (subscriberStoresElement == null) {
+ throw new SavanException(
+ "'Subscribers' element should be present as a sub-element of the 'savan-config' element");
+ }
+ processSubscribers(subscribersElement);
+
+ }
+
+ 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(UTIL_FACTORY));
+ 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(MAPPING_RULES));
+ if (mappingRulesElement == null)
+ throw new SavanException("Protocol must have a 'mappingRules' sub-element");
+ processMappingRules(mappingRulesElement, protocol);
+
+ OMElement defaultSubscriberElement =
+ element.getFirstChildWithName(new QName(DEFAULT_SUBSCRIBER));
+ if (defaultSubscriberElement == null)
+ throw new SavanException("Protocols must have a 'defaultSubscriber' sub-element");
+ String defaultSubscriber = defaultSubscriberElement.getText();
+ protocol.setDefaultSubscriber(defaultSubscriber);
+
+ OMElement defaultFilterElement = element.getFirstChildWithName(new QName(DEFAULT_FILTER));
+ if (defaultFilterElement == null)
+ throw new SavanException("Protocols must have a 'defaultFilter' sub-element");
+ String defaultFilter = defaultFilterElement.getText();
+ protocol.setDefaultFilter(defaultFilter);
+
+ protocolMap.put(protocol.getName(), protocol);
+ }
+
+ private void processMappingRules(OMElement element, Protocol protocol) {
+
+ MappingRules mappingRules = protocol.getMappingRules();
+
+ Iterator actionsIterator = element.getChildrenWithName(new QName(ACTION));
+ while (actionsIterator.hasNext()) {
+ OMElement actionElement = (OMElement)actionsIterator.next();
+ String action = actionElement.getText();
+ mappingRules.addRule(MappingRules.MAPPING_TYPE_ACTION, action);
+ }
+
+ }
+
+ private void processSubscriberStores(OMElement element) throws SavanException {
+ Iterator subscriberStoreElementsIterator =
+ element.getChildrenWithName(new QName(SUBSCRIBER_STORE));
+ 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(CLASS));
+ if (classElement == null)
+ throw new SavanException("SubscriberStore must have a 'Clazz' subelement'");
+
+ String clazz = classElement.getText();
+
+ //initialize the class to check weather it is value
+ Object obj = getObject(clazz);
+
+ if (!(obj instanceof SubscriberStore)) {
+ String message =
+ "Class " + clazz + " does not implement the SubscriberStore interface.";
+ throw new SavanException(message);
+ }
+
+ subscriberStoreNamesMap.put(key, clazz);
+ }
+
+ public HashMap getProtocolMap() {
+ return protocolMap;
+ }
+
+ public Protocol getProtocol(String name) {
+ return (Protocol)protocolMap.get(name);
+ }
+
+ public SubscriberStore getSubscriberStoreInstance(String key) throws SavanException {
+ String name = (String)subscriberStoreNamesMap.get(key);
+ return (SubscriberStore)getObject(name);
+ }
+
+ public Filter getFilterInstanceFromName(String name) throws SavanException {
+ for (Iterator it = filterMap.keySet().iterator(); it.hasNext();) {
+ String key = (String)it.next();
+ FilterBean filterBean = (FilterBean)filterMap.get(key);
+ if (name.equals(filterBean.getName()))
+ return (Filter)getObject(filterBean.getClazz());
+ }
+
+ return null;
+ }
+
+ public Filter getFilterInstanceFromId(String id) throws SavanException {
+ FilterBean filterBean = (FilterBean)filterMap.get(id);
+ String filterClass = filterBean.getClazz();
+ if (filterClass == null)
+ return null;
+
+ return (Filter)getObject(filterClass);
+ }
+
+ 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;
+ }
+
+ private void processFilters(OMElement element) throws SavanException {
+ Iterator filterElementsIterator = element.getChildrenWithName(new QName(FILTER));
+ while (filterElementsIterator.hasNext()) {
+ OMElement filterElement = (OMElement)filterElementsIterator.next();
+ processFilter(filterElement);
+ }
+ }
+
+ private void processFilter(OMElement element) throws SavanException {
+ OMElement nameElement = element.getFirstChildWithName(new QName(NAME));
+ OMElement identifierElement = element.getFirstChildWithName(new QName(IDENTIFIER));
+ OMElement classElement = element.getFirstChildWithName(new QName(CLASS));
+
+ if (nameElement == null)
+ throw new SavanException("Name element is not present within the Filter");
+ if (identifierElement == null)
+ throw new SavanException("Identifier element is not present within the Filter");
+ if (classElement == null)
+ throw new SavanException("Class element is not present within the Filter");
+
+ String name = nameElement.getText();
+ String identifier = identifierElement.getText();
+ String clazz = classElement.getText();
+
+ //initialize the class to check weather it is value
+ Object obj = getObject(clazz);
+
+ if (!(obj instanceof Filter)) {
+ String message = "Class " + clazz + " does not implement the Filter interface.";
+ throw new SavanException(message);
+ }
+
+ FilterBean bean = new FilterBean();
+ bean.setName(name);
+ bean.setIdentifier(identifier);
+ bean.setClazz(clazz);
+
+ filterMap.put(identifier, bean);
+ }
+
+ private void processSubscribers(OMElement element) throws SavanException {
+ Iterator subscriberElementsIterator = element.getChildrenWithName(new QName(SUBSCRIBER));
+ while (subscriberElementsIterator.hasNext()) {
+ OMElement subscriberElement = (OMElement)subscriberElementsIterator.next();
+ processSubscriber(subscriberElement);
+ }
+ }
+
+ private void processSubscriber(OMElement element) throws SavanException {
+ OMElement nameElement = element.getFirstChildWithName(new QName(NAME));
+ OMElement urlAppenderElement = element.getFirstChildWithName(new QName(URL_APPENDER));
+ OMElement classElement = element.getFirstChildWithName(new QName(CLASS));
+
+ if (nameElement == null)
+ throw new SavanException("Name element is not present within the AbstractSubscriber");
+ if (classElement == null)
+ throw new SavanException("Class element is not present within the Filter");
+
+ String name = nameElement.getText();
+ String clazz = classElement.getText();
+
+ //initialize the class to check weather it is valid
+ Object obj = getObject(clazz);
+
+ if (!(obj instanceof Subscriber)) {
+ String message = "Class " + clazz + " does not implement the Subscriber interface.";
+ throw new SavanException(message);
+ }
+
+ SubscriberBean bean = new SubscriberBean();
+ bean.setName(name);
+ bean.setClazz(clazz);
+
+ subscribersMap.put(name, bean);
+ }
+
+ public Map getSubscriberBeans() {
+ return subscribersMap;
+ }
+
+ public Map getFilterBeans() {
+ return filterMap;
+ }
+
+ public SubscriberBean getSubscriberBean(String subscriberName) {
+ return (SubscriberBean)subscribersMap.get(subscriberName);
+ }
+
+ public Subscriber getSubscriberInstance(String subscriberName) throws SavanException {
+ SubscriberBean subscriberBean = (SubscriberBean)subscribersMap.get(subscriberName);
+ if (subscriberBean == null) {
+ String message = "A subscriber with the name '" + subscriberName + "' was not found.";
+ throw new SavanException(message);
+ }
+
+ return (Subscriber)getObject(subscriberBean.getClazz());
}
}
diff --git a/modules/core/src/main/java/org/apache/savan/configuration/FilterBean.java b/modules/core/src/main/java/org/apache/savan/configuration/FilterBean.java
index 2791196..ed3e306 100644
--- a/modules/core/src/main/java/org/apache/savan/configuration/FilterBean.java
+++ b/modules/core/src/main/java/org/apache/savan/configuration/FilterBean.java
@@ -18,32 +18,32 @@
public class FilterBean {
- String name;
- String identifier;
- String clazz;
-
- public String getClazz() {
- return clazz;
- }
-
- public String getIdentifier() {
- return identifier;
- }
-
- public String getName() {
- return name;
- }
-
- public void setClazz(String clazz) {
- this.clazz = clazz;
- }
-
- public void setIdentifier(String identifier) {
- this.identifier = identifier;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
+ String name;
+ String identifier;
+ String clazz;
+
+ public String getClazz() {
+ return clazz;
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setClazz(String clazz) {
+ this.clazz = clazz;
+ }
+
+ public void setIdentifier(String identifier) {
+ this.identifier = identifier;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/configuration/MappingRules.java b/modules/core/src/main/java/org/apache/savan/configuration/MappingRules.java
index 9c10a23..7642428 100644
--- a/modules/core/src/main/java/org/apache/savan/configuration/MappingRules.java
+++ b/modules/core/src/main/java/org/apache/savan/configuration/MappingRules.java
@@ -20,29 +20,29 @@
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).
+ * Encapsulates a date of a set of Mapping-Rules as defined by Savan configurations. (probably from
+ * a savan-config.xml file).
*/
public class MappingRules {
- public static final int MAPPING_TYPE_ACTION = 1;
-
- private ArrayList actionList = null;
-
- public MappingRules () {
- actionList = new ArrayList ();
- }
-
- public void addRule (int type,String value) {
- if (type==MAPPING_TYPE_ACTION)
- actionList.add(value);
- }
-
- public boolean ruleMatched (int type, String value) {
- if (type==MAPPING_TYPE_ACTION)
- return actionList.contains(value);
-
- return false;
- }
-
+ public static final int MAPPING_TYPE_ACTION = 1;
+
+ private ArrayList actionList = null;
+
+ public MappingRules() {
+ actionList = new ArrayList();
+ }
+
+ public void addRule(int type, String value) {
+ if (type == MAPPING_TYPE_ACTION)
+ actionList.add(value);
+ }
+
+ public boolean ruleMatched(int type, String value) {
+ if (type == MAPPING_TYPE_ACTION)
+ return actionList.contains(value);
+
+ return false;
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/configuration/Protocol.java b/modules/core/src/main/java/org/apache/savan/configuration/Protocol.java
index af7ee1d..b73dfd4 100644
--- a/modules/core/src/main/java/org/apache/savan/configuration/Protocol.java
+++ b/modules/core/src/main/java/org/apache/savan/configuration/Protocol.java
@@ -20,55 +20,55 @@
import org.apache.savan.util.UtilFactory;
/**
- *Encapsulates a date of a Protocol as defined by Savan configurations.
- *(probably from a savan-config.xml file).
+ * 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;
- private String defaultSubscriber;
- private String defaultFilter;
-
- public Protocol () {
- this.mappingRules = new MappingRules ();
- }
+ private String name;
+ private UtilFactory utilFactory;
+ private MappingRules mappingRules;
+ private String defaultSubscriber;
+ private String defaultFilter;
- public String getDefaultFilter() {
- return defaultFilter;
- }
+ public Protocol() {
+ this.mappingRules = new MappingRules();
+ }
- public String getDefaultSubscriber() {
- return defaultSubscriber;
- }
+ public String getDefaultFilter() {
+ return defaultFilter;
+ }
- public void setDefaultFilter(String defaultFilter) {
- this.defaultFilter = defaultFilter;
- }
+ public String getDefaultSubscriber() {
+ return defaultSubscriber;
+ }
- public void setDefaultSubscriber(String defaultSubscriber) {
- this.defaultSubscriber = defaultSubscriber;
- }
+ public void setDefaultFilter(String defaultFilter) {
+ this.defaultFilter = defaultFilter;
+ }
- 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 void setDefaultSubscriber(String defaultSubscriber) {
+ this.defaultSubscriber = defaultSubscriber;
+ }
- public MappingRules getMappingRules() {
- return 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;
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/configuration/SubscriberBean.java b/modules/core/src/main/java/org/apache/savan/configuration/SubscriberBean.java
index cad25d0..346dc1b 100644
--- a/modules/core/src/main/java/org/apache/savan/configuration/SubscriberBean.java
+++ b/modules/core/src/main/java/org/apache/savan/configuration/SubscriberBean.java
@@ -17,23 +17,25 @@
package org.apache.savan.configuration;
public class SubscriberBean {
-
- String name;
- String clazz;
-
- public String getClazz() {
- return clazz;
- }
- public String getName() {
- return name;
- }
- public void setClazz(String clazz) {
- this.clazz = clazz;
- }
- public void setName(String name) {
- this.name = name;
- }
-
-
+ String name;
+ String clazz;
+
+ public String getClazz() {
+ return clazz;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setClazz(String clazz) {
+ this.clazz = clazz;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/eventing/Delivery.java b/modules/core/src/main/java/org/apache/savan/eventing/Delivery.java
index 1beb747..54c8eef 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/Delivery.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/Delivery.java
@@ -21,25 +21,24 @@
public class Delivery {
- EndpointReference deliveryEPR;
- String deliveryMode;
+ EndpointReference deliveryEPR;
+ String deliveryMode;
- public EndpointReference getDeliveryEPR() {
- return deliveryEPR;
- }
+ public EndpointReference getDeliveryEPR() {
+ return deliveryEPR;
+ }
- public String getDeliveryMode() {
- return deliveryMode;
- }
+ public String getDeliveryMode() {
+ return deliveryMode;
+ }
- public void setDeliveryEPR(EndpointReference deliveryEPR) {
- this.deliveryEPR = deliveryEPR;
- }
+ public void setDeliveryEPR(EndpointReference deliveryEPR) {
+ this.deliveryEPR = deliveryEPR;
+ }
- public void setDeliveryMode(String deliveryMode) {
- this.deliveryMode = deliveryMode;
- }
-
-
-
+ public void setDeliveryMode(String deliveryMode) {
+ this.deliveryMode = deliveryMode;
+ }
+
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/eventing/EventingConstants.java b/modules/core/src/main/java/org/apache/savan/eventing/EventingConstants.java
index 49e3027..5070296 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/EventingConstants.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/EventingConstants.java
@@ -19,54 +19,58 @@
public interface EventingConstants {
- String EVENTING_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/08/eventing";
- String EXTENDED_EVENTING_NAMESPACE = "http://ws.apache.org/ws/2007/05/eventing-extended";
- String EVENTING_PREFIX = "wse";
- String DEFAULT_DELIVERY_MODE = "http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push";
- String DEFAULT_FILTER_IDENTIFIER = FilterDialects.XPath;
-
-
- 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 Topic = "topic";
- }
-
- interface Actions {
- String Subscribe = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe";
- String SubscribeResponse = "http://schemas.xmlsoap.org/ws/2004/08/eventing/SubscribeResponse";
- String Renew = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew";
- String RenewResponse = "http://schemas.xmlsoap.org/ws/2004/08/eventing/RenewResponse";
- String Unsubscribe = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe";
- 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";
- String Publish = "http://ws.apache.org/ws/2007/05/eventing-extended/Publish";
- }
-
- interface Properties {
- String SOAPVersion = "SOAPVersion";
- }
-
- interface FilterDialects {
- String XPath = "http://www.w3.org/TR/1999/REC-xpath-19991116";
- }
+ String EVENTING_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/08/eventing";
+ String EXTENDED_EVENTING_NAMESPACE = "http://ws.apache.org/ws/2007/05/eventing-extended";
+ String EVENTING_PREFIX = "wse";
+ String DEFAULT_DELIVERY_MODE =
+ "http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push";
+ String DEFAULT_FILTER_IDENTIFIER = FilterDialects.XPath;
+
+
+ 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 Topic = "topic";
+ }
+
+ interface Actions {
+ String Subscribe = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe";
+ String SubscribeResponse =
+ "http://schemas.xmlsoap.org/ws/2004/08/eventing/SubscribeResponse";
+ String Renew = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew";
+ String RenewResponse = "http://schemas.xmlsoap.org/ws/2004/08/eventing/RenewResponse";
+ String Unsubscribe = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe";
+ 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";
+ String Publish = "http://ws.apache.org/ws/2007/05/eventing-extended/Publish";
+ }
+
+ interface Properties {
+ String SOAPVersion = "SOAPVersion";
+ }
+
+ interface FilterDialects {
+ String XPath = "http://www.w3.org/TR/1999/REC-xpath-19991116";
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/eventing/EventingMessageReceiverDeligater.java b/modules/core/src/main/java/org/apache/savan/eventing/EventingMessageReceiverDeligater.java
index cfe66c8..851ad79 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/EventingMessageReceiverDeligater.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/EventingMessageReceiverDeligater.java
@@ -17,17 +17,14 @@
package org.apache.savan.eventing;
-import java.util.Calendar;
-import java.util.Date;
-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.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReferenceHelper;
import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.databinding.utils.ConverterUtil;
import org.apache.savan.SavanConstants;
@@ -37,234 +34,272 @@
import org.apache.savan.messagereceiver.MessageReceiverDeligater;
import org.apache.savan.storage.SubscriberStore;
import org.apache.savan.subscribers.Subscriber;
-import org.apache.savan.subscribers.Subscriber;
import org.apache.savan.util.CommonUtil;
+import javax.xml.namespace.QName;
+import java.util.Calendar;
+import java.util.Date;
+
public class EventingMessageReceiverDeligater extends MessageReceiverDeligater {
-
- public void doProtocolSpecificProcessing (SavanMessageContext inSavanMessage, MessageContext outMessage) throws SavanException {
- int messageType = inSavanMessage.getMessageType();
- if (messageType==SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE) {
- handleSubscriptionRequest(inSavanMessage,outMessage);
- } else if (messageType==SavanConstants.MessageTypes.RENEW_MESSAGE) {
- handleRenewRequest (inSavanMessage,outMessage);
- } else if (messageType==SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE) {
- handleEndSubscriptionRequest (inSavanMessage,outMessage);
- } else if (messageType==SavanConstants.MessageTypes.GET_STATUS_MESSAGE) {
- handleGetStatusRequest (inSavanMessage,outMessage);
- }
- }
- private void handleSubscriptionRequest(SavanMessageContext subscriptionMessage, MessageContext outMessage) throws SavanException {
-
- if (outMessage==null)
- throw new SavanException ("Eventing protocol need to sent the SubscriptionResponseMessage. But the outMessage is null");
-
- 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();
-
- try {
- outMessage.setEnvelope(outMessageEnvelope);
- } catch (AxisFault e) {
- throw new SavanException (e);
- }
- }
-
- //setting the action
- outMessage.getOptions().setAction(EventingConstants.Actions.SubscribeResponse);
-
- //sending the subscription response message.
- String address = subscriptionMsgCtx.getOptions().getTo().getAddress();
- EndpointReference subscriptionManagerEPR = new EndpointReference (address);
+ public void doProtocolSpecificProcessing(SavanMessageContext inSavanMessage,
+ MessageContext outMessage) throws SavanException {
+ int messageType = inSavanMessage.getMessageType();
+ if (messageType == SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE) {
+ handleSubscriptionRequest(inSavanMessage, outMessage);
+ } else if (messageType == SavanConstants.MessageTypes.RENEW_MESSAGE) {
+ handleRenewRequest(inSavanMessage, outMessage);
+ } else if (messageType == SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE) {
+ handleEndSubscriptionRequest(inSavanMessage, outMessage);
+ } else if (messageType == SavanConstants.MessageTypes.GET_STATUS_MESSAGE) {
+ handleGetStatusRequest(inSavanMessage, outMessage);
+ }
+ }
- String id = (String) subscriptionMessage.getProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID);
- if (id==null)
- throw new SavanException ("Subscription UUID is not set");
-
- subscriptionManagerEPR.addReferenceParameter(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Identifier,EventingConstants.EVENTING_PREFIX),id);
-
- OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,EventingConstants.EVENTING_PREFIX);
- OMElement subscribeResponseElement = factory.createOMElement(EventingConstants.ElementNames.SubscribeResponse,ens);
- OMElement subscriptionManagerElement = null;
- try {
- subscriptionManagerElement = EndpointReferenceHelper.toOM(subscribeResponseElement.getOMFactory(), subscriptionManagerEPR, new QName(EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.SubscriptionManager,EventingConstants.EVENTING_PREFIX), AddressingConstants.Submission.WSA_NAMESPACE);
- } catch (AxisFault e) {
- throw new SavanException (e);
- }
-
- //TODO set expires
-
- subscribeResponseElement.addChild(subscriptionManagerElement);
- outMessageEnvelope.getBody().addChild(subscribeResponseElement);
-
- //setting the message type
- outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new Integer (SavanConstants.MessageTypes.SUBSCRIPTION_RESPONSE_MESSAGE));
-
- }
-
- private void handleRenewRequest(SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException {
-
- if (outMessage==null)
- throw new SavanException ("Eventing protocol need to sent the SubscriptionResponseMessage. But the outMessage is null");
-
- MessageContext subscriptionMsgCtx = renewMessage.getMessageContext();
-
- 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);
- }
- }
-
- //setting the action
- outMessage.getOptions().setAction(EventingConstants.Actions.RenewResponse);
-
- OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,EventingConstants.EVENTING_PREFIX);
-
- //sending the Renew Response message.
- OMElement renewResponseElement = factory.createOMElement(EventingConstants.ElementNames.RenewResponse,ens);
- String subscriberID = (String) renewMessage.getProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID);
- if (subscriberID==null) {
- String message = "SubscriberID TransferedProperty is not set";
- throw new SavanException (message);
- }
+ private void handleSubscriptionRequest(SavanMessageContext subscriptionMessage,
+ MessageContext outMessage) throws SavanException {
- SubscriberStore store = CommonUtil.getSubscriberStore(renewMessage.getMessageContext().getAxisService());
- Subscriber subscriber = store.retrieve(subscriberID);
- EventingSubscriber eventingSubscriber = (EventingSubscriber) subscriber;
- if (eventingSubscriber==null) {
- String message = "Cannot find the AbstractSubscriber with the given ID";
- throw new SavanException (message);
- }
-
- Date expiration = eventingSubscriber.getSubscriptionEndingTime();
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(expiration);
-
- String expiresValue = ConverterUtil.convertToString(calendar);
-
- if (expiresValue!=null) {
- OMElement expiresElement = factory.createOMElement(EventingConstants.ElementNames.Expires,ens);
- renewResponseElement.addChild(expiresElement);
- }
-
- outMessageEnvelope.getBody().addChild(renewResponseElement);
-
- //setting the message type
- outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new Integer (SavanConstants.MessageTypes.RENEW_RESPONSE_MESSAGE));
- }
+ if (outMessage == null)
+ throw new SavanException(
+ "Eventing protocol need to sent the SubscriptionResponseMessage. But the outMessage is null");
- private void handleEndSubscriptionRequest(SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException {
-
- if (outMessage==null)
- throw new SavanException ("Eventing protocol need to sent the SubscriptionResponseMessage. But the outMessage is null");
-
- MessageContext subscriptionMsgCtx = renewMessage.getMessageContext();
-
- //setting the action
- outMessage.getOptions().setAction(EventingConstants.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);
- }
- }
-
- //setting the message type
- outMessage.setProperty(SavanConstants.MESSAGE_TYPE,new Integer (SavanConstants.MessageTypes.UNSUBSCRIPTION_RESPONSE_MESSAGE));
- }
+ MessageContext subscriptionMsgCtx = subscriptionMessage.getMessageContext();
- public void handleGetStatusRequest(SavanMessageContext getStatusMessage, MessageContext outMessage) throws SavanException {
+ SOAPEnvelope outMessageEnvelope = outMessage.getEnvelope();
+ SOAPFactory factory = null;
- 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(EventingConstants.TransferedProperties.SUBSCRIBER_UUID);
- if (id==null)
- throw new SavanException ("Cannot fulfil request. AbstractSubscriber ID not found");
-
- //setting the action
- outMessage.getOptions().setAction(EventingConstants.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");
- }
-
- EventingSubscriber subscriber = (EventingSubscriber) store.retrieve(id);
- if (subscriber==null) {
- throw new SavanException ("AbstractSubscriber 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);
- 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 void doProtocolSpecificProcessing(SavanMessageContext inSavanMessage) throws SavanException {
-
- }
+ 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);
+ }
+ }
+
+ //setting the action
+ outMessage.getOptions().setAction(EventingConstants.Actions.SubscribeResponse);
+
+ //sending the subscription response message.
+ String address = subscriptionMsgCtx.getOptions().getTo().getAddress();
+ EndpointReference subscriptionManagerEPR = new EndpointReference(address);
+
+ String id = (String)subscriptionMessage
+ .getProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID);
+ if (id == null)
+ throw new SavanException("Subscription UUID is not set");
+
+ subscriptionManagerEPR.addReferenceParameter(new QName(EventingConstants.EVENTING_NAMESPACE,
+ EventingConstants.ElementNames.Identifier,
+ EventingConstants.EVENTING_PREFIX),
+ id);
+
+ OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,
+ EventingConstants.EVENTING_PREFIX);
+ OMElement subscribeResponseElement =
+ factory.createOMElement(EventingConstants.ElementNames.SubscribeResponse, ens);
+ OMElement subscriptionManagerElement = null;
+ try {
+ subscriptionManagerElement = EndpointReferenceHelper.toOM(
+ subscribeResponseElement.getOMFactory(), subscriptionManagerEPR, new QName(
+ EventingConstants.EVENTING_NAMESPACE,
+ EventingConstants.ElementNames.SubscriptionManager,
+ EventingConstants.EVENTING_PREFIX),
+ AddressingConstants.Submission.WSA_NAMESPACE);
+ } catch (AxisFault e) {
+ throw new SavanException(e);
+ }
+
+ //TODO set expires
+
+ subscribeResponseElement.addChild(subscriptionManagerElement);
+ outMessageEnvelope.getBody().addChild(subscribeResponseElement);
+
+ //setting the message type
+ outMessage.setProperty(SavanConstants.MESSAGE_TYPE, new Integer(
+ SavanConstants.MessageTypes.SUBSCRIPTION_RESPONSE_MESSAGE));
+
+ }
+
+ private void handleRenewRequest(SavanMessageContext renewMessage, MessageContext outMessage)
+ throws SavanException {
+
+ if (outMessage == null)
+ throw new SavanException(
+ "Eventing protocol need to sent the SubscriptionResponseMessage. But the outMessage is null");
+
+ MessageContext subscriptionMsgCtx = renewMessage.getMessageContext();
+
+ 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);
+ }
+ }
+
+ //setting the action
+ outMessage.getOptions().setAction(EventingConstants.Actions.RenewResponse);
+
+ OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,
+ EventingConstants.EVENTING_PREFIX);
+
+ //sending the Renew Response message.
+ OMElement renewResponseElement =
+ factory.createOMElement(EventingConstants.ElementNames.RenewResponse, ens);
+ String subscriberID = (String)renewMessage
+ .getProperty(EventingConstants.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);
+ EventingSubscriber eventingSubscriber = (EventingSubscriber)subscriber;
+ if (eventingSubscriber == null) {
+ String message = "Cannot find the AbstractSubscriber with the given ID";
+ throw new SavanException(message);
+ }
+
+ Date expiration = eventingSubscriber.getSubscriptionEndingTime();
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(expiration);
+
+ String expiresValue = ConverterUtil.convertToString(calendar);
+
+ if (expiresValue != null) {
+ OMElement expiresElement =
+ factory.createOMElement(EventingConstants.ElementNames.Expires, ens);
+ renewResponseElement.addChild(expiresElement);
+ }
+
+ outMessageEnvelope.getBody().addChild(renewResponseElement);
+
+ //setting the message type
+ outMessage.setProperty(SavanConstants.MESSAGE_TYPE,
+ new Integer(SavanConstants.MessageTypes.RENEW_RESPONSE_MESSAGE));
+ }
+
+ private void handleEndSubscriptionRequest(SavanMessageContext renewMessage,
+ MessageContext outMessage) throws SavanException {
+
+ if (outMessage == null)
+ throw new SavanException(
+ "Eventing protocol need to sent the SubscriptionResponseMessage. But the outMessage is null");
+
+ MessageContext subscriptionMsgCtx = renewMessage.getMessageContext();
+
+ //setting the action
+ outMessage.getOptions().setAction(EventingConstants.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);
+ }
+ }
+
+ //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 {
+
+ 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(EventingConstants.TransferedProperties.SUBSCRIBER_UUID);
+ if (id == null)
+ throw new SavanException("Cannot fulfil request. AbstractSubscriber ID not found");
+
+ //setting the action
+ outMessage.getOptions().setAction(EventingConstants.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");
+ }
+
+ EventingSubscriber subscriber = (EventingSubscriber)store.retrieve(id);
+ if (subscriber == null) {
+ throw new SavanException("AbstractSubscriber 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);
+ 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 void doProtocolSpecificProcessing(SavanMessageContext inSavanMessage)
+ throws SavanException {
+
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/eventing/EventingSubscriptionProcessor.java b/modules/core/src/main/java/org/apache/savan/eventing/EventingSubscriptionProcessor.java
index 4edd9a3..86fcc64 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/EventingSubscriptionProcessor.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/EventingSubscriptionProcessor.java
@@ -17,30 +17,18 @@
package org.apache.savan.eventing;
-import java.net.URI;
-import java.net.URISyntaxException;
-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.om.util.UUIDGenerator;
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.AxisFault;
-import org.apache.axis2.addressing.EndpointReferenceHelper;
import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
import org.apache.axis2.databinding.types.Duration;
import org.apache.axis2.databinding.utils.ConverterUtil;
-import org.apache.axiom.om.util.UUIDGenerator;
import org.apache.savan.SavanConstants;
import org.apache.savan.SavanException;
import org.apache.savan.SavanMessageContext;
@@ -50,280 +38,304 @@
import org.apache.savan.eventing.subscribers.EventingSubscriber;
import org.apache.savan.filters.Filter;
import org.apache.savan.subscribers.Subscriber;
-import org.apache.savan.subscribers.Subscriber;
import org.apache.savan.subscription.ExpirationBean;
import org.apache.savan.subscription.SubscriptionProcessor;
import org.apache.savan.util.CommonUtil;
import org.apache.savan.util.UtilFactory;
+import javax.xml.namespace.QName;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Calendar;
+import java.util.Date;
+
public class EventingSubscriptionProcessor 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(EventingConstants.TransferedProperties.SUBSCRIBER_UUID,id);
- }
- }
-
- public Subscriber getSubscriberFromMessage(SavanMessageContext smc) throws SavanException {
+ public void init(SavanMessageContext smc) throws SavanException {
+ //setting the subscriber_id as a property if possible.
- 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");
-
- UtilFactory utilFactory = protocol.getUtilFactory();
-
- SOAPEnvelope envelope = smc.getEnvelope();
- if (envelope==null)
- return null;
-
+ String id = getSubscriberID(smc);
+ if (id != null) {
+ smc.setProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID, id);
+ }
+ }
+
+ public Subscriber getSubscriberFromMessage(SavanMessageContext smc) throws SavanException {
+
+ ConfigurationManager configurationManager = (ConfigurationManager)smc
+ .getConfigurationContext().getProperty(SavanConstants.CONFIGURATION_MANAGER);
+ if (configurationManager == null)
+ throw new SavanException("Configuration Manager not set");
+
+ Protocol protocol = smc.getProtocol();
+ if (protocol == null)
+ throw new SavanException("Protocol not found");
+
+ UtilFactory utilFactory = protocol.getUtilFactory();
+
+ 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();
- SubscriberBean subscriberBean = configurationManager.getSubscriberBean(subscriberName);
-
- Subscriber subscriber = configurationManager.getSubscriberInstance(subscriberName);
-
- if (!(subscriber instanceof EventingSubscriber)) {
- String message = "Eventing protocol only support implementations of eventing subscriber as Subscribers";
- throw new SavanException (message);
- }
-
- EventingSubscriber eventingSubscriber = (EventingSubscriber) subscriber;
- String id = UUIDGenerator.getUUID();
- smc.setProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID,id);
- try {
- URI uri = new URI (id);
- eventingSubscriber.setId(uri);
- } catch (URISyntaxException e) {
- throw new SavanException (e);
- }
-
- SOAPBody body = envelope.getBody();
- OMElement subscribeElement = body.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Subscribe));
- if (subscribeElement==null)
- throw new SavanException ("'Subscribe' element is not present");
-
- OMElement endToElement = subscribeElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.EndTo));
- if (endToElement!=null) {
- EndpointReference endToEPR = null;
-
+
+ String subscriberName = protocol.getDefaultSubscriber();
+ SubscriberBean subscriberBean = configurationManager.getSubscriberBean(subscriberName);
+
+ Subscriber subscriber = configurationManager.getSubscriberInstance(subscriberName);
+
+ if (!(subscriber instanceof EventingSubscriber)) {
+ String message =
+ "Eventing protocol only support implementations of eventing subscriber as Subscribers";
+ throw new SavanException(message);
+ }
+
+ EventingSubscriber eventingSubscriber = (EventingSubscriber)subscriber;
+ String id = UUIDGenerator.getUUID();
+ smc.setProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID, id);
+ try {
+ URI uri = new URI(id);
+ eventingSubscriber.setId(uri);
+ } catch (URISyntaxException e) {
+ throw new SavanException(e);
+ }
+
+ SOAPBody body = envelope.getBody();
+ OMElement subscribeElement = body.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.Subscribe));
+ if (subscribeElement == null)
+ throw new SavanException("'Subscribe' element is not present");
+
+ OMElement endToElement = subscribeElement.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.EndTo));
+ if (endToElement != null) {
+ EndpointReference endToEPR = null;
+
try {
endToEPR = EndpointReferenceHelper.fromOM(endToElement);
}
catch (AxisFault af) {
throw new SavanException(af);
}
-
- eventingSubscriber.setEndToEPr(endToEPR);
- }
-
- OMElement deliveryElement = subscribeElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Delivery));
- if (deliveryElement==null)
- throw new SavanException ("Delivery element is not present");
-
- OMElement notifyToElement = deliveryElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.NotifyTo));
- if (notifyToElement==null)
- throw new SavanException ("NotifyTo element is null");
-
- EndpointReference notifyToEPr = null;
-
+
+ eventingSubscriber.setEndToEPr(endToEPR);
+ }
+
+ OMElement deliveryElement = subscribeElement.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.Delivery));
+ if (deliveryElement == null)
+ throw new SavanException("Delivery element is not present");
+
+ OMElement notifyToElement = deliveryElement.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.NotifyTo));
+ if (notifyToElement == null)
+ throw new SavanException("NotifyTo element is null");
+
+ EndpointReference notifyToEPr = null;
+
try {
notifyToEPr = EndpointReferenceHelper.fromOM(notifyToElement);
}
- catch (AxisFault af) {
+ catch (AxisFault af) {
throw new SavanException(af);
}
-
- OMAttribute deliveryModeAttr = deliveryElement.getAttribute(new QName (EventingConstants.ElementNames.Mode));
- String deliveryMode = null;
- if (deliveryModeAttr!=null) {
- deliveryMode = deliveryModeAttr.getAttributeValue().trim();
- } else {
- deliveryMode = EventingConstants.DEFAULT_DELIVERY_MODE;
- }
-
- if (!deliveryModesupported()) {
- //TODO throw unsupported delivery mode fault.
- }
-
- Delivery delivery = new Delivery ();
- delivery.setDeliveryEPR(notifyToEPr);
- delivery.setDeliveryMode(deliveryMode);
-
- eventingSubscriber.setDelivery(delivery);
-
- OMElement expiresElement = subscribeElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Expires));
- if (expiresElement!=null) {
- String expiresText = expiresElement.getText();
- if (expiresText==null){
- String message = "Expires Text is null";
- throw new SavanException (message);
- }
-
- expiresText = expiresText.trim();
-
- ExpirationBean expirationBean = getExpirationBeanFromString(expiresText);
- Date expiration = null;
- if (expirationBean.isDuration()) {
- Calendar calendar = Calendar.getInstance();
- CommonUtil.addDurationToCalendar(calendar,expirationBean.getDurationValue());
- expiration = calendar.getTime();
- } else
- expiration = expirationBean.getDateValue();
-
-
- if (expiration==null) {
- String message = "Cannot understand the given date-time value for the Expiration";
- throw new SavanException (message);
- }
-
- eventingSubscriber.setSubscriptionEndingTime(expiration);
- }
-
- OMElement filterElement = subscribeElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Filter));
- if (filterElement!=null) {
- OMNode filterNode = filterElement.getFirstOMChild();
- OMAttribute dialectAttr = filterElement.getAttribute(new QName (EventingConstants.ElementNames.Dialect));
- Filter filter = null;
-
- String filterKey = EventingConstants.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);
-
- eventingSubscriber.setFilter(filter);
- }
-
- return eventingSubscriber;
- }
+ OMAttribute deliveryModeAttr =
+ deliveryElement.getAttribute(new QName(EventingConstants.ElementNames.Mode));
+ String deliveryMode = null;
+ if (deliveryModeAttr != null) {
+ deliveryMode = deliveryModeAttr.getAttributeValue().trim();
+ } else {
+ deliveryMode = EventingConstants.DEFAULT_DELIVERY_MODE;
+ }
- public void pauseSubscription(SavanMessageContext pauseSubscriptionMessage) throws SavanException {
- throw new UnsupportedOperationException ("Eventing specification does not support this type of messages");
- }
+ if (!deliveryModesupported()) {
+ //TODO throw unsupported delivery mode fault.
+ }
- public void resumeSubscription(SavanMessageContext resumeSubscriptionMessage) throws SavanException {
- throw new UnsupportedOperationException ("Eventing specification does not support this type of messages");
- }
+ Delivery delivery = new Delivery();
+ delivery.setDeliveryEPR(notifyToEPr);
+ delivery.setDeliveryMode(deliveryMode);
- public ExpirationBean getExpirationBean(SavanMessageContext renewMessage) throws SavanException {
+ eventingSubscriber.setDelivery(delivery);
- SOAPEnvelope envelope = renewMessage.getEnvelope();
- SOAPBody body = envelope.getBody();
-
- ExpirationBean expirationBean = null;
-
- OMElement renewElement = body.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Renew));
- if (renewElement==null) {
- String message = "Renew element not present in the assumed Renew Message";
- throw new SavanException (message);
- }
-
- OMElement expiresElement = renewElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Expires));
- if (expiresElement!=null) {
- String expiresText = expiresElement.getText().trim();
- expirationBean = getExpirationBeanFromString(expiresText);
- }
-
- String subscriberID = getSubscriberID(renewMessage);
- if (subscriberID==null) {
- String message = "Cannot find the subscriber ID";
- throw new SavanException (message);
- }
-
- renewMessage.setProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID,subscriberID);
-
- expirationBean.setSubscriberID(subscriberID);
- return expirationBean;
- }
+ OMElement expiresElement = subscribeElement.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.Expires));
+ if (expiresElement != null) {
+ String expiresText = expiresElement.getText();
- public String getSubscriberID(SavanMessageContext smc) throws SavanException {
- SOAPEnvelope envelope = smc.getEnvelope();
- SOAPHeader header = envelope.getHeader();
- if (header==null) {
- return null;
- }
-
- OMElement ideltifierElement = envelope.getHeader().getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Identifier));
- if (ideltifierElement==null) {
- return null;
- }
-
- return ideltifierElement.getText().trim();
- }
-
- private ExpirationBean getExpirationBeanFromString (String expiresStr) throws SavanException {
+ if (expiresText == null) {
+ String message = "Expires Text is null";
+ throw new SavanException(message);
+ }
- ExpirationBean bean = new ExpirationBean ();
-
- //expires can be a duration or a date time.
- //Doing the conversion using the ConverUtil helper class.
-
- Date date = null;
- boolean isDuration = CommonUtil.isDuration(expiresStr);
-
- if (isDuration) {
- try {
- bean.setDuration(true);
- Duration duration = ConverterUtil.convertToDuration(expiresStr);
- bean.setDurationValue(duration);
- } 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);
- date = calendar.getTime();
- bean.setDateValue(date);
- } catch (Exception e) {
- String message = "Cannot convert the Expiration value to a valid DATE/TIME";
- throw new SavanException (message,e);
- }
- }
-
- boolean invalidExpirationTime = false;
- if (bean.isDuration()) {
- if (isInvalidDiration (bean.getDurationValue()))
- invalidExpirationTime = true;
- } else {
- if (isDateInThePast (bean.getDateValue()))
- invalidExpirationTime = true;
- }
-
- if (invalidExpirationTime) {
- //TODO throw Invalid Expiration Time fault
- }
-
- return bean;
- }
+ expiresText = expiresText.trim();
- 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;
- }
-
+ ExpirationBean expirationBean = getExpirationBeanFromString(expiresText);
+ Date expiration = null;
+ if (expirationBean.isDuration()) {
+ Calendar calendar = Calendar.getInstance();
+ CommonUtil.addDurationToCalendar(calendar, expirationBean.getDurationValue());
+ expiration = calendar.getTime();
+ } else
+ expiration = expirationBean.getDateValue();
+
+
+ if (expiration == null) {
+ String message = "Cannot understand the given date-time value for the Expiration";
+ throw new SavanException(message);
+ }
+
+ eventingSubscriber.setSubscriptionEndingTime(expiration);
+ }
+
+ OMElement filterElement = subscribeElement.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.Filter));
+ if (filterElement != null) {
+ OMNode filterNode = filterElement.getFirstOMChild();
+ OMAttribute dialectAttr =
+ filterElement.getAttribute(new QName(EventingConstants.ElementNames.Dialect));
+ Filter filter = null;
+
+ String filterKey = EventingConstants.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);
+
+ eventingSubscriber.setFilter(filter);
+ }
+
+ return eventingSubscriber;
+ }
+
+ 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");
+ }
+
+ public ExpirationBean getExpirationBean(SavanMessageContext renewMessage)
+ throws SavanException {
+
+ SOAPEnvelope envelope = renewMessage.getEnvelope();
+ SOAPBody body = envelope.getBody();
+
+ ExpirationBean expirationBean = null;
+
+ OMElement renewElement = body.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.Renew));
+ if (renewElement == null) {
+ String message = "Renew element not present in the assumed Renew Message";
+ throw new SavanException(message);
+ }
+
+ OMElement expiresElement = renewElement.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.Expires));
+ if (expiresElement != null) {
+ String expiresText = expiresElement.getText().trim();
+ expirationBean = getExpirationBeanFromString(expiresText);
+ }
+
+ String subscriberID = getSubscriberID(renewMessage);
+ if (subscriberID == null) {
+ String message = "Cannot find the subscriber ID";
+ throw new SavanException(message);
+ }
+
+ renewMessage
+ .setProperty(EventingConstants.TransferedProperties.SUBSCRIBER_UUID, subscriberID);
+
+ expirationBean.setSubscriberID(subscriberID);
+ return expirationBean;
+ }
+
+ public String getSubscriberID(SavanMessageContext smc) throws SavanException {
+ SOAPEnvelope envelope = smc.getEnvelope();
+ SOAPHeader header = envelope.getHeader();
+ if (header == null) {
+ return null;
+ }
+
+ OMElement ideltifierElement = envelope.getHeader().getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.Identifier));
+ if (ideltifierElement == null) {
+ return null;
+ }
+
+ return ideltifierElement.getText().trim();
+ }
+
+ private ExpirationBean getExpirationBeanFromString(String expiresStr) throws SavanException {
+
+ ExpirationBean bean = new ExpirationBean();
+
+ //expires can be a duration or a date time.
+ //Doing the conversion using the ConverUtil helper class.
+
+ Date date = null;
+ boolean isDuration = CommonUtil.isDuration(expiresStr);
+
+ if (isDuration) {
+ try {
+ bean.setDuration(true);
+ Duration duration = ConverterUtil.convertToDuration(expiresStr);
+ bean.setDurationValue(duration);
+ } 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);
+ date = calendar.getTime();
+ bean.setDateValue(date);
+ } catch (Exception e) {
+ String message = "Cannot convert the Expiration value to a valid DATE/TIME";
+ throw new SavanException(message, e);
+ }
+ }
+
+ boolean invalidExpirationTime = false;
+ if (bean.isDuration()) {
+ if (isInvalidDiration(bean.getDurationValue()))
+ invalidExpirationTime = true;
+ } else {
+ if (isDateInThePast(bean.getDateValue()))
+ invalidExpirationTime = true;
+ }
+
+ if (invalidExpirationTime) {
+ //TODO throw Invalid Expiration Time fault
+ }
+
+ return bean;
+ }
+
+ 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/eventing/EventingUtilFactory.java b/modules/core/src/main/java/org/apache/savan/eventing/EventingUtilFactory.java
index 7420458..32076c5 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/EventingUtilFactory.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/EventingUtilFactory.java
@@ -19,7 +19,6 @@
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.eventing.subscribers.EventingSubscriber;
import org.apache.savan.messagereceiver.MessageReceiverDeligater;
@@ -29,46 +28,46 @@
public class EventingUtilFactory implements UtilFactory {
- public SavanMessageContext initializeMessage(SavanMessageContext smc) {
-
- MessageContext messageContext = smc.getMessageContext();
-
- //setting the message type.
- String action = messageContext.getOptions().getAction();
- if (EventingConstants.Actions.Subscribe.equals(action))
- smc.setMessageType(SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE);
- else if (EventingConstants.Actions.Renew.equals(action))
- smc.setMessageType(SavanConstants.MessageTypes.RENEW_MESSAGE);
- else if (EventingConstants.Actions.Unsubscribe.equals(action))
- smc.setMessageType(SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE);
- else if (EventingConstants.Actions.GetStatus.equals(action))
- smc.setMessageType(SavanConstants.MessageTypes.GET_STATUS_MESSAGE);
- else if (EventingConstants.Actions.SubscribeResponse.equals(action))
- smc.setMessageType(SavanConstants.MessageTypes.SUBSCRIPTION_RESPONSE_MESSAGE);
- else if (EventingConstants.Actions.RenewResponse.equals(action))
- smc.setMessageType(SavanConstants.MessageTypes.RENEW_RESPONSE_MESSAGE);
- else if (EventingConstants.Actions.UnsubscribeResponse.equals(action))
- smc.setMessageType(SavanConstants.MessageTypes.UNSUBSCRIPTION_RESPONSE_MESSAGE);
- else if (EventingConstants.Actions.GetStatusResponse.equals(action))
- smc.setMessageType(SavanConstants.MessageTypes.GET_STATUS_RESPONSE_MESSAGE);
- else if (EventingConstants.Actions.Publish.equals(action))
- smc.setMessageType(SavanConstants.MessageTypes.PUBLISH);
- else
- smc.setMessageType(SavanConstants.MessageTypes.UNKNOWN);
-
- return smc;
- }
+ public SavanMessageContext initializeMessage(SavanMessageContext smc) {
- public SubscriptionProcessor createSubscriptionProcessor() {
- return new EventingSubscriptionProcessor ();
- }
-
- public MessageReceiverDeligater createMessageReceiverDeligater() {
- return new EventingMessageReceiverDeligater ();
- }
+ MessageContext messageContext = smc.getMessageContext();
- public Subscriber createSubscriber() {
- return new EventingSubscriber ();
- }
-
+ //setting the message type.
+ String action = messageContext.getOptions().getAction();
+ if (EventingConstants.Actions.Subscribe.equals(action))
+ smc.setMessageType(SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE);
+ else if (EventingConstants.Actions.Renew.equals(action))
+ smc.setMessageType(SavanConstants.MessageTypes.RENEW_MESSAGE);
+ else if (EventingConstants.Actions.Unsubscribe.equals(action))
+ smc.setMessageType(SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE);
+ else if (EventingConstants.Actions.GetStatus.equals(action))
+ smc.setMessageType(SavanConstants.MessageTypes.GET_STATUS_MESSAGE);
+ else if (EventingConstants.Actions.SubscribeResponse.equals(action))
+ smc.setMessageType(SavanConstants.MessageTypes.SUBSCRIPTION_RESPONSE_MESSAGE);
+ else if (EventingConstants.Actions.RenewResponse.equals(action))
+ smc.setMessageType(SavanConstants.MessageTypes.RENEW_RESPONSE_MESSAGE);
+ else if (EventingConstants.Actions.UnsubscribeResponse.equals(action))
+ smc.setMessageType(SavanConstants.MessageTypes.UNSUBSCRIPTION_RESPONSE_MESSAGE);
+ else if (EventingConstants.Actions.GetStatusResponse.equals(action))
+ smc.setMessageType(SavanConstants.MessageTypes.GET_STATUS_RESPONSE_MESSAGE);
+ else if (EventingConstants.Actions.Publish.equals(action))
+ smc.setMessageType(SavanConstants.MessageTypes.PUBLISH);
+ else
+ smc.setMessageType(SavanConstants.MessageTypes.UNKNOWN);
+
+ return smc;
+ }
+
+ public SubscriptionProcessor createSubscriptionProcessor() {
+ return new EventingSubscriptionProcessor();
+ }
+
+ public MessageReceiverDeligater createMessageReceiverDeligater() {
+ return new EventingMessageReceiverDeligater();
+ }
+
+ public Subscriber createSubscriber() {
+ return new EventingSubscriber();
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/eventing/client/EventingClient.java b/modules/core/src/main/java/org/apache/savan/eventing/client/EventingClient.java
index 53db7c6..9ae4737 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/client/EventingClient.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/client/EventingClient.java
@@ -17,24 +17,14 @@
package org.apache.savan.eventing.client;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-
-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.OMNamespace;
-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.*;
import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReferenceHelper;
import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.databinding.types.Duration;
@@ -43,316 +33,356 @@
import org.apache.savan.subscription.ExpirationBean;
import org.apache.savan.util.CommonUtil;
+import javax.xml.namespace.QName;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+
public class EventingClient {
- ServiceClient serviceClient = null;
- HashMap subscriptionDataMap = null;
-
- public EventingClient (ServiceClient serviceClient) {
- this.serviceClient = serviceClient;
- subscriptionDataMap = new HashMap ();
- }
-
- public void subscribe (EventingClientBean bean, String subscriptionID) throws Exception {
-
- Options options = serviceClient.getOptions();
- if (options==null) {
- options = new Options ();
- serviceClient.setOptions(options);
- }
-
- String SOAPVersion = options.getSoapVersionURI();
- if (SOAPVersion==null)
- SOAPVersion = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-
- SOAPEnvelope envelope = createSubscriptionEnvelope(bean,SOAPVersion);
-
- String oldAction = options.getAction();
- String action = EventingConstants.Actions.Subscribe;
- options.setAction(action);
- OMElement subscriptionResponse = serviceClient.sendReceive (envelope.getBody().getFirstElement());
- SubscriptionResponseData subscriptionResponseData = getSubscriptionResponseData (subscriptionResponse);
-
- subscriptionDataMap.put(subscriptionID,subscriptionResponseData);
-
- options.setAction(oldAction);
- }
-
- public void renewSubscription (Date newExpirationTime, String subscriptionID) throws Exception {
- String expirationString = ConverterUtil.convertToString(newExpirationTime);
- renewSubscription(expirationString,subscriptionID);
- }
-
- public void renewSubscription (Duration duration, String subscriptionID) throws Exception {
- String expirationString = ConverterUtil.convertToString(duration);
- renewSubscription(expirationString,subscriptionID);
- }
-
- private void renewSubscription (String expirationString, String subscriptionID) throws Exception {
- SubscriptionResponseData data = (SubscriptionResponseData) subscriptionDataMap.get(subscriptionID);
- EndpointReference managerEPR = data.getSubscriptionManager();
- if (managerEPR==null)
- throw new Exception ("Manager EPR is not set");
-
- Options options = serviceClient.getOptions();
- if (options==null) {
- options = new Options ();
- serviceClient.setOptions(options);
- }
-
- String SOAPVersion = options.getSoapVersionURI();
- if (SOAPVersion==null)
- SOAPVersion = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-
- SOAPEnvelope envelope = createRenewSubscriptionEnvelope(expirationString,SOAPVersion);
-
- String oldAction = options.getAction();
- String action = EventingConstants.Actions.Renew;
- options.setAction(action);
-
- EndpointReference oldTo = serviceClient.getOptions().getTo();
- options.setTo(managerEPR);
-
- OMElement renewResponse = serviceClient.sendReceive (envelope.getBody().getFirstElement());
+ ServiceClient serviceClient = null;
+ HashMap subscriptionDataMap = null;
- options.setAction(oldAction);
- options.setTo(oldTo);
- }
-
- public void unsubscribe (String subscriptionID) throws Exception {
- SubscriptionResponseData data = (SubscriptionResponseData) subscriptionDataMap.get(subscriptionID);
- EndpointReference managerEPR = data.getSubscriptionManager();
- if (managerEPR==null)
- throw new Exception ("Manager EPR is not set");
-
- Options options = serviceClient.getOptions();
- if (options==null) {
- options = new Options ();
- serviceClient.setOptions(options);
- }
-
- String SOAPVersion = options.getSoapVersionURI();
- if (SOAPVersion==null)
- SOAPVersion = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-
- SOAPEnvelope envelope = createUnsubscriptionEnvelope(SOAPVersion);
-
- String oldAction = options.getAction();
- String action = EventingConstants.Actions.Unsubscribe;
- options.setAction(action);
-
- EndpointReference oldTo = serviceClient.getOptions().getTo();
- options.setTo(managerEPR);
-
- OMElement unsubscribeResponse = serviceClient.sendReceive (envelope.getBody().getFirstElement());
- //TODO process unsubscriber response
-
- options.setAction(oldAction);
- options.setTo(oldTo);
- }
-
- public SubscriptionStatus getSubscriptionStatus (String subscriptionID) throws Exception {
- SubscriptionResponseData data = (SubscriptionResponseData) subscriptionDataMap.get(subscriptionID);
- EndpointReference managerEPR = data.getSubscriptionManager();
- if (managerEPR==null)
- throw new Exception ("Manager EPR is not set");
-
- Options options = serviceClient.getOptions();
- if (options==null) {
- options = new Options ();
- serviceClient.setOptions(options);
- }
-
- String SOAPVersion = options.getSoapVersionURI();
- if (SOAPVersion==null)
- SOAPVersion = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-
- SOAPEnvelope envelope = createGetStatusEnvelope(SOAPVersion);
-
- String oldAction = options.getAction();
- String action = EventingConstants.Actions.GetStatus;
- options.setAction(action);
-
- EndpointReference oldTo = serviceClient.getOptions().getTo();
- options.setTo(managerEPR);
-
- OMElement getStatusResponse = serviceClient.sendReceive (envelope.getBody().getFirstElement());
- SubscriptionStatus subscriptionStatus = getSubscriptionStatus (getStatusResponse);
-
- options.setAction(oldAction);
- options.setTo(oldTo);
-
- return subscriptionStatus;
- }
-
- private SubscriptionResponseData getSubscriptionResponseData (OMElement responseMessagePayload) throws Exception {
- SubscriptionResponseData data = new SubscriptionResponseData ();
-
- OMElement subscriberManagerElement = responseMessagePayload.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.SubscriptionManager));
- EndpointReference managerEPR = EndpointReferenceHelper.fromOM(subscriberManagerElement);
- data.setSubscriptionManager(managerEPR);
-
- OMElement expiresElement = responseMessagePayload.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Expires));
- if (expiresElement!=null) {
- String text = expiresElement.getText().trim();
+ public EventingClient(ServiceClient serviceClient) {
+ this.serviceClient = serviceClient;
+ subscriptionDataMap = new HashMap();
+ }
- ExpirationBean expirationBean = new ExpirationBean ();
- if (CommonUtil.isDuration(text)) {
- expirationBean.setDuration(true);
- Duration duration = ConverterUtil.convertToDuration(text);
- expirationBean.setDurationValue(duration);
- } else {
- expirationBean.setDuration(false);
- Date date = ConverterUtil.convertToDateTime(text).getTime();
- expirationBean.setDateValue(date);
- }
-
- data.setExpiration(expirationBean);
- }
-
- return data;
- }
-
- private SubscriptionStatus getSubscriptionStatus (OMElement getStatusResponseElement) throws Exception {
- SubscriptionStatus subscriptionStatus = new SubscriptionStatus ();
-
- OMElement expiresElementElement = getStatusResponseElement.getFirstChildWithName(new QName (EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.Expires));
- if (expiresElementElement!=null) {
- String valueStr = expiresElementElement.getText();
+ public void subscribe(EventingClientBean bean, String subscriptionID) throws Exception {
+
+ Options options = serviceClient.getOptions();
+ if (options == null) {
+ options = new Options();
+ serviceClient.setOptions(options);
+ }
+
+ String SOAPVersion = options.getSoapVersionURI();
+ if (SOAPVersion == null)
+ SOAPVersion = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+
+ SOAPEnvelope envelope = createSubscriptionEnvelope(bean, SOAPVersion);
+
+ String oldAction = options.getAction();
+ String action = EventingConstants.Actions.Subscribe;
+ options.setAction(action);
+ OMElement subscriptionResponse =
+ serviceClient.sendReceive(envelope.getBody().getFirstElement());
+ SubscriptionResponseData subscriptionResponseData =
+ getSubscriptionResponseData(subscriptionResponse);
+
+ subscriptionDataMap.put(subscriptionID, subscriptionResponseData);
+
+ options.setAction(oldAction);
+ }
+
+ public void renewSubscription(Date newExpirationTime, String subscriptionID) throws Exception {
+ String expirationString = ConverterUtil.convertToString(newExpirationTime);
+ renewSubscription(expirationString, subscriptionID);
+ }
+
+ public void renewSubscription(Duration duration, String subscriptionID) throws Exception {
+ String expirationString = ConverterUtil.convertToString(duration);
+ renewSubscription(expirationString, subscriptionID);
+ }
+
+ private void renewSubscription(String expirationString, String subscriptionID)
+ throws Exception {
+ SubscriptionResponseData data =
+ (SubscriptionResponseData)subscriptionDataMap.get(subscriptionID);
+ EndpointReference managerEPR = data.getSubscriptionManager();
+ if (managerEPR == null)
+ throw new Exception("Manager EPR is not set");
+
+ Options options = serviceClient.getOptions();
+ if (options == null) {
+ options = new Options();
+ serviceClient.setOptions(options);
+ }
+
+ String SOAPVersion = options.getSoapVersionURI();
+ if (SOAPVersion == null)
+ SOAPVersion = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+
+ SOAPEnvelope envelope = createRenewSubscriptionEnvelope(expirationString, SOAPVersion);
+
+ String oldAction = options.getAction();
+ String action = EventingConstants.Actions.Renew;
+ options.setAction(action);
+
+ EndpointReference oldTo = serviceClient.getOptions().getTo();
+ options.setTo(managerEPR);
+
+ OMElement renewResponse = serviceClient.sendReceive(envelope.getBody().getFirstElement());
+
+ options.setAction(oldAction);
+ options.setTo(oldTo);
+ }
+
+ public void unsubscribe(String subscriptionID) throws Exception {
+ SubscriptionResponseData data =
+ (SubscriptionResponseData)subscriptionDataMap.get(subscriptionID);
+ EndpointReference managerEPR = data.getSubscriptionManager();
+ if (managerEPR == null)
+ throw new Exception("Manager EPR is not set");
+
+ Options options = serviceClient.getOptions();
+ if (options == null) {
+ options = new Options();
+ serviceClient.setOptions(options);
+ }
+
+ String SOAPVersion = options.getSoapVersionURI();
+ if (SOAPVersion == null)
+ SOAPVersion = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+
+ SOAPEnvelope envelope = createUnsubscriptionEnvelope(SOAPVersion);
+
+ String oldAction = options.getAction();
+ String action = EventingConstants.Actions.Unsubscribe;
+ options.setAction(action);
+
+ EndpointReference oldTo = serviceClient.getOptions().getTo();
+ options.setTo(managerEPR);
+
+ OMElement unsubscribeResponse =
+ serviceClient.sendReceive(envelope.getBody().getFirstElement());
+ //TODO process unsubscriber response
+
+ options.setAction(oldAction);
+ options.setTo(oldTo);
+ }
+
+ public SubscriptionStatus getSubscriptionStatus(String subscriptionID) throws Exception {
+ SubscriptionResponseData data =
+ (SubscriptionResponseData)subscriptionDataMap.get(subscriptionID);
+ EndpointReference managerEPR = data.getSubscriptionManager();
+ if (managerEPR == null)
+ throw new Exception("Manager EPR is not set");
+
+ Options options = serviceClient.getOptions();
+ if (options == null) {
+ options = new Options();
+ serviceClient.setOptions(options);
+ }
+
+ String SOAPVersion = options.getSoapVersionURI();
+ if (SOAPVersion == null)
+ SOAPVersion = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
+
+ SOAPEnvelope envelope = createGetStatusEnvelope(SOAPVersion);
+
+ String oldAction = options.getAction();
+ String action = EventingConstants.Actions.GetStatus;
+ options.setAction(action);
+
+ EndpointReference oldTo = serviceClient.getOptions().getTo();
+ options.setTo(managerEPR);
+
+ OMElement getStatusResponse =
+ serviceClient.sendReceive(envelope.getBody().getFirstElement());
+ SubscriptionStatus subscriptionStatus = getSubscriptionStatus(getStatusResponse);
+
+ options.setAction(oldAction);
+ options.setTo(oldTo);
+
+ return subscriptionStatus;
+ }
+
+ private SubscriptionResponseData getSubscriptionResponseData(OMElement responseMessagePayload)
+ throws Exception {
+ SubscriptionResponseData data = new SubscriptionResponseData();
+
+ OMElement subscriberManagerElement = responseMessagePayload.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE,
+ EventingConstants.ElementNames.SubscriptionManager));
+ EndpointReference managerEPR = EndpointReferenceHelper.fromOM(subscriberManagerElement);
+ data.setSubscriptionManager(managerEPR);
+
+ OMElement expiresElement = responseMessagePayload.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.Expires));
+ if (expiresElement != null) {
+ String text = expiresElement.getText().trim();
+
+ ExpirationBean expirationBean = new ExpirationBean();
+ if (CommonUtil.isDuration(text)) {
+ expirationBean.setDuration(true);
+ Duration duration = ConverterUtil.convertToDuration(text);
+ expirationBean.setDurationValue(duration);
+ } else {
+ expirationBean.setDuration(false);
+ Date date = ConverterUtil.convertToDateTime(text).getTime();
+ expirationBean.setDateValue(date);
+ }
+
+ data.setExpiration(expirationBean);
+ }
+
+ return data;
+ }
+
+ private SubscriptionStatus getSubscriptionStatus(OMElement getStatusResponseElement)
+ throws Exception {
+ SubscriptionStatus subscriptionStatus = new SubscriptionStatus();
+
+ OMElement expiresElementElement = getStatusResponseElement.getFirstChildWithName(new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.Expires));
+ if (expiresElementElement != null) {
+ String valueStr = expiresElementElement.getText();
// long expires = Long.parseLong(valueStr);
- subscriptionStatus.setExpirationValue(valueStr);
- }
-
- return subscriptionStatus;
- }
-
- private SOAPEnvelope createSubscriptionEnvelope (EventingClientBean bean, String SOAPVersion) throws Exception{
- 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 Exception ("Unknown SOAP version");
-
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- SOAPBody body = envelope.getBody();
-
- OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,EventingConstants.EVENTING_PREFIX);
-
- OMElement subscriptionElement = factory.createOMElement(EventingConstants.ElementNames.Subscribe,ens);
-
- EndpointReference endToEPR = bean.getEndToEPR();
- if (bean.getEndToEPR()!=null) {
- OMElement endToElement = EndpointReferenceHelper.toOM(subscriptionElement.getOMFactory(), endToEPR, new QName(EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.EndTo,EventingConstants.EVENTING_PREFIX), AddressingConstants.Submission.WSA_NAMESPACE);
- subscriptionElement.addChild(endToElement);
- }
-
- EndpointReference deliveryEPR = bean.getDeliveryEPR();
- if (deliveryEPR==null)
- throw new Exception ("Delivery EPR is not set");
-
- OMElement deliveryElement = factory.createOMElement(EventingConstants.ElementNames.Delivery,ens);
- OMElement notifyToElement = EndpointReferenceHelper.toOM(subscriptionElement.getOMFactory(), deliveryEPR, new QName(EventingConstants.EVENTING_NAMESPACE,EventingConstants.ElementNames.NotifyTo,EventingConstants.EVENTING_PREFIX), AddressingConstants.Submission.WSA_NAMESPACE);
+ subscriptionStatus.setExpirationValue(valueStr);
+ }
- deliveryElement.addChild(notifyToElement);
- subscriptionElement.addChild(deliveryElement);
-
- if (bean.getExpirationTime()!=null || bean.getExpirationDuration()!=null) {
- String timeString = null;
-
- //if time is set it will be taken. Otherwise duration will be taken.
- if (bean.getExpirationTime()!=null) {
- Date date = bean.getExpirationTime();
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(date);
- timeString = ConverterUtil.convertToString(calendar);
- } else if (bean.getExpirationDuration()!=null) {
- Duration duration = bean.getExpirationDuration();
- timeString = ConverterUtil.convertToString(duration);
- }
-
- OMElement expiresElement = factory.createOMElement(EventingConstants.ElementNames.Expires,ens);
- expiresElement.setText(timeString);
- subscriptionElement.addChild(expiresElement);
- }
-
- if (bean.getFilter()!=null) {
- String filter = bean.getFilter();
- String dialect = bean.getFilterDialect();
-
- OMElement filterElement = factory.createOMElement(EventingConstants.ElementNames.Filter,ens);
- OMAttribute dialectAttr = factory.createOMAttribute(EventingConstants.ElementNames.Dialect,null,dialect);
- filterElement.addAttribute(dialectAttr);
- filterElement.setText(filter);
-
- subscriptionElement.addChild(filterElement);
- }
-
- body.addChild(subscriptionElement);
-
- return envelope;
- }
-
- private SOAPEnvelope createRenewSubscriptionEnvelope (String expiresString, String SOAPVersion) throws Exception{
- 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 Exception ("Unknown SOAP version");
-
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- SOAPBody body = envelope.getBody();
-
- OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,EventingConstants.EVENTING_PREFIX);
- OMElement renewElement = factory.createOMElement(EventingConstants.ElementNames.Renew,ens);
- OMElement expiresElement = factory.createOMElement(EventingConstants.ElementNames.Expires,ens);
- expiresElement.setText(expiresString);
- renewElement.addChild(expiresElement);
-
- body.addChild(renewElement);
-
- return envelope;
- }
-
- private SOAPEnvelope createUnsubscriptionEnvelope (String SOAPVersion) throws Exception {
- 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 Exception ("Unknown SOAP version");
-
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- SOAPBody body = envelope.getBody();
-
- OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,EventingConstants.EVENTING_PREFIX);
- OMElement unsubscribeElement = factory.createOMElement(EventingConstants.ElementNames.Unsubscribe,ens);
- body.addChild(unsubscribeElement);
-
- return envelope;
- }
+ return subscriptionStatus;
+ }
- private SOAPEnvelope createGetStatusEnvelope (String SOAPVersion) throws Exception {
- 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 Exception ("Unknown SOAP version");
-
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- SOAPBody body = envelope.getBody();
-
- OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,EventingConstants.EVENTING_PREFIX);
- OMElement getStatusElement = factory.createOMElement(EventingConstants.ElementNames.GetStatus,ens);
- body.addChild(getStatusElement);
-
- return envelope;
- }
-
+ private SOAPEnvelope createSubscriptionEnvelope(EventingClientBean bean, String SOAPVersion)
+ throws Exception {
+ 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 Exception("Unknown SOAP version");
+
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ SOAPBody body = envelope.getBody();
+
+ OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,
+ EventingConstants.EVENTING_PREFIX);
+
+ OMElement subscriptionElement =
+ factory.createOMElement(EventingConstants.ElementNames.Subscribe, ens);
+
+ EndpointReference endToEPR = bean.getEndToEPR();
+ if (bean.getEndToEPR() != null) {
+ OMElement endToElement = EndpointReferenceHelper.toOM(
+ subscriptionElement.getOMFactory(), endToEPR, new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.EndTo,
+ EventingConstants.EVENTING_PREFIX),
+ AddressingConstants.Submission.WSA_NAMESPACE);
+ subscriptionElement.addChild(endToElement);
+ }
+
+ EndpointReference deliveryEPR = bean.getDeliveryEPR();
+ if (deliveryEPR == null)
+ throw new Exception("Delivery EPR is not set");
+
+ OMElement deliveryElement =
+ factory.createOMElement(EventingConstants.ElementNames.Delivery, ens);
+ OMElement notifyToElement = EndpointReferenceHelper.toOM(subscriptionElement.getOMFactory(),
+ deliveryEPR, new QName(
+ EventingConstants.EVENTING_NAMESPACE, EventingConstants.ElementNames.NotifyTo,
+ EventingConstants.EVENTING_PREFIX), AddressingConstants.Submission.WSA_NAMESPACE);
+
+ deliveryElement.addChild(notifyToElement);
+ subscriptionElement.addChild(deliveryElement);
+
+ if (bean.getExpirationTime() != null || bean.getExpirationDuration() != null) {
+ String timeString = null;
+
+ //if time is set it will be taken. Otherwise duration will be taken.
+ if (bean.getExpirationTime() != null) {
+ Date date = bean.getExpirationTime();
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ timeString = ConverterUtil.convertToString(calendar);
+ } else if (bean.getExpirationDuration() != null) {
+ Duration duration = bean.getExpirationDuration();
+ timeString = ConverterUtil.convertToString(duration);
+ }
+
+ OMElement expiresElement =
+ factory.createOMElement(EventingConstants.ElementNames.Expires, ens);
+ expiresElement.setText(timeString);
+ subscriptionElement.addChild(expiresElement);
+ }
+
+ if (bean.getFilter() != null) {
+ String filter = bean.getFilter();
+ String dialect = bean.getFilterDialect();
+
+ OMElement filterElement =
+ factory.createOMElement(EventingConstants.ElementNames.Filter, ens);
+ OMAttribute dialectAttr = factory.createOMAttribute(
+ EventingConstants.ElementNames.Dialect, null, dialect);
+ filterElement.addAttribute(dialectAttr);
+ filterElement.setText(filter);
+
+ subscriptionElement.addChild(filterElement);
+ }
+
+ body.addChild(subscriptionElement);
+
+ return envelope;
+ }
+
+ private SOAPEnvelope createRenewSubscriptionEnvelope(String expiresString, String SOAPVersion)
+ throws Exception {
+ 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 Exception("Unknown SOAP version");
+
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ SOAPBody body = envelope.getBody();
+
+ OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,
+ EventingConstants.EVENTING_PREFIX);
+ OMElement renewElement = factory.createOMElement(EventingConstants.ElementNames.Renew, ens);
+ OMElement expiresElement =
+ factory.createOMElement(EventingConstants.ElementNames.Expires, ens);
+ expiresElement.setText(expiresString);
+ renewElement.addChild(expiresElement);
+
+ body.addChild(renewElement);
+
+ return envelope;
+ }
+
+ private SOAPEnvelope createUnsubscriptionEnvelope(String SOAPVersion) throws Exception {
+ 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 Exception("Unknown SOAP version");
+
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ SOAPBody body = envelope.getBody();
+
+ OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,
+ EventingConstants.EVENTING_PREFIX);
+ OMElement unsubscribeElement =
+ factory.createOMElement(EventingConstants.ElementNames.Unsubscribe, ens);
+ body.addChild(unsubscribeElement);
+
+ return envelope;
+ }
+
+ private SOAPEnvelope createGetStatusEnvelope(String SOAPVersion) throws Exception {
+ 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 Exception("Unknown SOAP version");
+
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ SOAPBody body = envelope.getBody();
+
+ OMNamespace ens = factory.createOMNamespace(EventingConstants.EVENTING_NAMESPACE,
+ EventingConstants.EVENTING_PREFIX);
+ OMElement getStatusElement =
+ factory.createOMElement(EventingConstants.ElementNames.GetStatus, ens);
+ body.addChild(getStatusElement);
+
+ return envelope;
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/eventing/client/EventingClientBean.java b/modules/core/src/main/java/org/apache/savan/eventing/client/EventingClientBean.java
index 6205655..e061416 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/client/EventingClientBean.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/client/EventingClientBean.java
@@ -17,64 +17,65 @@
package org.apache.savan.eventing.client;
-import java.util.Date;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.databinding.types.Duration;
+import java.util.Date;
+
public class EventingClientBean {
- EndpointReference deliveryEPR;
- EndpointReference endToEPR;
- String filterDialect;
- String filter;
- Date expirationTime;
- Duration expirationDuration;
-
- public Duration getExpirationDuration() {
- return expirationDuration;
- }
+ EndpointReference deliveryEPR;
+ EndpointReference endToEPR;
+ String filterDialect;
+ String filter;
+ Date expirationTime;
+ Duration expirationDuration;
- public void setExpirationDuration(Duration expirationDuration) {
- this.expirationDuration = expirationDuration;
- }
+ public Duration getExpirationDuration() {
+ return expirationDuration;
+ }
- public EndpointReference getDeliveryEPR() {
- return deliveryEPR;
- }
-
- public EndpointReference getEndToEPR() {
- return endToEPR;
- }
-
- public Date getExpirationTime() {
- return expirationTime;
- }
-
- public String getFilter() {
- return filter;
- }
-
- public String getFilterDialect() {
- return filterDialect;
- }
-
- public void setDeliveryEPR(EndpointReference deliveryEPR) {
- this.deliveryEPR = deliveryEPR;
- }
-
- public void setEndToEPR(EndpointReference endToEPR) {
- this.endToEPR = endToEPR;
- }
-
- public void setExpirationTime(Date expirationTime) {
- this.expirationTime = expirationTime;
- }
-
- public void setFilter(String filter) {
- this.filter = filter;
- }
-
- public void setFilterDialect(String filterDialect) {
- this.filterDialect = filterDialect;
- }
+ public void setExpirationDuration(Duration expirationDuration) {
+ this.expirationDuration = expirationDuration;
+ }
+
+ public EndpointReference getDeliveryEPR() {
+ return deliveryEPR;
+ }
+
+ public EndpointReference getEndToEPR() {
+ return endToEPR;
+ }
+
+ public Date getExpirationTime() {
+ return expirationTime;
+ }
+
+ public String getFilter() {
+ return filter;
+ }
+
+ public String getFilterDialect() {
+ return filterDialect;
+ }
+
+ public void setDeliveryEPR(EndpointReference deliveryEPR) {
+ this.deliveryEPR = deliveryEPR;
+ }
+
+ public void setEndToEPR(EndpointReference endToEPR) {
+ this.endToEPR = endToEPR;
+ }
+
+ public void setExpirationTime(Date expirationTime) {
+ this.expirationTime = expirationTime;
+ }
+
+ public void setFilter(String filter) {
+ this.filter = filter;
+ }
+
+ public void setFilterDialect(String filterDialect) {
+ this.filterDialect = filterDialect;
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/eventing/client/SubscriptionResponseData.java b/modules/core/src/main/java/org/apache/savan/eventing/client/SubscriptionResponseData.java
index 95f5414..d8ce4bb 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/client/SubscriptionResponseData.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/client/SubscriptionResponseData.java
@@ -22,26 +22,26 @@
public class SubscriptionResponseData {
- EndpointReference subscriptionManager = null;
- ExpirationBean expiration = null;
-
- public SubscriptionResponseData () {
- expiration = new ExpirationBean ();
- }
+ EndpointReference subscriptionManager = null;
+ ExpirationBean expiration = null;
- public EndpointReference getSubscriptionManager() {
- return subscriptionManager;
- }
+ public SubscriptionResponseData() {
+ expiration = new ExpirationBean();
+ }
- public ExpirationBean getExpiration() {
- return expiration;
- }
+ public EndpointReference getSubscriptionManager() {
+ return subscriptionManager;
+ }
- public void setExpiration(ExpirationBean expiration) {
- this.expiration = expiration;
- }
+ public ExpirationBean getExpiration() {
+ return expiration;
+ }
- public void setSubscriptionManager(EndpointReference subscriptionManager) {
- this.subscriptionManager = subscriptionManager;
- }
+ public void setExpiration(ExpirationBean expiration) {
+ this.expiration = expiration;
+ }
+
+ public void setSubscriptionManager(EndpointReference subscriptionManager) {
+ this.subscriptionManager = subscriptionManager;
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/eventing/client/SubscriptionStatus.java b/modules/core/src/main/java/org/apache/savan/eventing/client/SubscriptionStatus.java
index 33075d5..4db81c8 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/client/SubscriptionStatus.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/client/SubscriptionStatus.java
@@ -18,17 +18,15 @@
public class SubscriptionStatus {
- String expirationValue;
+ String expirationValue;
- public String getExpirationValue() {
- return expirationValue;
- }
+ public String getExpirationValue() {
+ return expirationValue;
+ }
- public void setExpirationValue(String expirationValue) {
- this.expirationValue = expirationValue;
- }
+ public void setExpirationValue(String expirationValue) {
+ this.expirationValue = expirationValue;
+ }
-
-
-
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/eventing/subscribers/EventingSubscriber.java b/modules/core/src/main/java/org/apache/savan/eventing/subscribers/EventingSubscriber.java
index d24e970..c19a1ea 100644
--- a/modules/core/src/main/java/org/apache/savan/eventing/subscribers/EventingSubscriber.java
+++ b/modules/core/src/main/java/org/apache/savan/eventing/subscribers/EventingSubscriber.java
@@ -16,10 +16,6 @@
package org.apache.savan.eventing.subscribers;
-import java.net.URI;
-import java.util.Calendar;
-import java.util.Date;
-
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
@@ -34,138 +30,137 @@
import org.apache.savan.subscription.ExpirationBean;
import org.apache.savan.util.CommonUtil;
-/**
- * Defines methods common to all eventing subscribers.
- */
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
+
+/** Defines methods common to all eventing subscribers. */
public class EventingSubscriber implements Subscriber {
-
-
- private URI id;
- private Filter filter = null;
- private EndpointReference endToEPr;
- private Delivery delivery;
- private ConfigurationContext configurationContext;
-
- /**
- * The time at which further notification of messages should be avaoded
- * to this subscriber.
- */
- private Date subscriptionEndingTime = null;
- public Filter getFilter() {
- return filter;
- }
+ private URI id;
+ private Filter filter = null;
+ private EndpointReference endToEPr;
+ private Delivery delivery;
+ private ConfigurationContext configurationContext;
- public void setFilter(Filter filter) {
- this.filter = filter;
- }
+ /** The time at which further notification of messages should be avaoded to this subscriber. */
+ private Date subscriptionEndingTime = null;
- public URI getId() {
- return id;
- }
-
- public void setId(URI id) {
- this.id = id;
- }
-
- public Delivery getDelivery() {
- return delivery;
- }
- public EndpointReference getEndToEPr() {
- return endToEPr;
- }
+ public Filter getFilter() {
+ return filter;
+ }
- public void setDelivery(Delivery delivery) {
- this.delivery = delivery;
- }
+ public void setFilter(Filter filter) {
+ this.filter = filter;
+ }
- public void setEndToEPr(EndpointReference errorReportingEPR) {
- this.endToEPr = errorReportingEPR;
- }
+ public URI getId() {
+ return id;
+ }
- public Date getSubscriptionEndingTime () {
- return subscriptionEndingTime;
- }
-
- public void setSubscriptionEndingTime () {
- }
-
- public ConfigurationContext getConfigurationContext() {
- return configurationContext;
- }
+ public void setId(URI id) {
+ this.id = id;
+ }
- public void setConfigurationContext(ConfigurationContext configurationContext) {
- this.configurationContext = configurationContext;
- }
+ public Delivery getDelivery() {
+ return delivery;
+ }
- public void setSubscriptionEndingTime(Date subscriptionEndingTime) {
- this.subscriptionEndingTime = subscriptionEndingTime;
- }
-
- /**
- * This method first checks weather the passed message complies with the current filter.
- * If so message is sent, and the subscriberID is added to the PublicationReport.
- * Else message is ignored.
- *
- * @param smc
- * @param report
- * @throws SavanException
- */
- public void sendEventData (OMElement eventData) throws SavanException {
+ public EndpointReference getEndToEPr() {
+ return endToEPr;
+ }
- 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";
- throw new SavanException (message);
- }
-
- if (doesEventDataBelongToTheFilter(eventData)) {
- sendThePublication (eventData);
- }
- }
+ public void setDelivery(Delivery delivery) {
+ this.delivery = delivery;
+ }
- private boolean doesEventDataBelongToTheFilter(OMElement eventData) throws SavanException {
- if (filter!=null) {
- return filter.checkCompliance (eventData);
- } else
- return true;
- }
-
- private void sendThePublication(OMElement eventData) throws SavanException {
-
- EndpointReference deliveryEPR = delivery.getDeliveryEPR();
- try {
- ServiceClient sc = new ServiceClient (configurationContext,null);
- Options options = new Options ();
- sc.setOptions(options);
- options.setTo(deliveryEPR);
- options.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, Boolean.FALSE);
- sc.fireAndForget(eventData);
- } catch (AxisFault e) {
- throw new SavanException (e);
- }
- }
-
- public void renewSubscription (ExpirationBean bean) {
- if (bean.isDuration()) {
- if (subscriptionEndingTime==null) {
- Calendar calendar = Calendar.getInstance();
- CommonUtil.addDurationToCalendar(calendar,bean.getDurationValue());
- subscriptionEndingTime = calendar.getTime();
- } else {
- Calendar expiration = Calendar.getInstance();
- expiration.setTime(subscriptionEndingTime);
- CommonUtil.addDurationToCalendar(expiration,bean.getDurationValue());
- subscriptionEndingTime = expiration.getTime();
- }
- } else
- subscriptionEndingTime = bean.getDateValue();
+ public void setEndToEPr(EndpointReference errorReportingEPR) {
+ this.endToEPr = errorReportingEPR;
+ }
+
+ public Date getSubscriptionEndingTime() {
+ return subscriptionEndingTime;
+ }
+
+ public void setSubscriptionEndingTime() {
+ }
+
+ public ConfigurationContext getConfigurationContext() {
+ return configurationContext;
+ }
+
+ public void setConfigurationContext(ConfigurationContext configurationContext) {
+ this.configurationContext = configurationContext;
+ }
+
+ public void setSubscriptionEndingTime(Date subscriptionEndingTime) {
+ this.subscriptionEndingTime = subscriptionEndingTime;
+ }
+
+ /**
+ * This method first checks weather the passed message complies with the current filter. If so
+ * message is sent, and the subscriberID is added to the PublicationReport. Else message is
+ * ignored.
+ *
+ * @param smc
+ * @param report
+ * @throws SavanException
+ */
+ public void sendEventData(OMElement eventData) throws SavanException {
+
+ Date date = new Date();
+ boolean expired = false;
+ if (subscriptionEndingTime != null && date.after(subscriptionEndingTime))
+ expired = true;
+
+ if (expired) {
+ String message = "Cant notify the listener since the subscription has been expired";
+ throw new SavanException(message);
+ }
+
+ if (doesEventDataBelongToTheFilter(eventData)) {
+ sendThePublication(eventData);
+ }
+ }
+
+ private boolean doesEventDataBelongToTheFilter(OMElement eventData) throws SavanException {
+ if (filter != null) {
+ return filter.checkCompliance(eventData);
+ } else
+ return true;
+ }
+
+ private void sendThePublication(OMElement eventData) throws SavanException {
+
+ EndpointReference deliveryEPR = delivery.getDeliveryEPR();
+ try {
+ ServiceClient sc = new ServiceClient(configurationContext, null);
+ Options options = new Options();
+ sc.setOptions(options);
+ options.setTo(deliveryEPR);
+ options.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, Boolean.FALSE);
+ sc.fireAndForget(eventData);
+ } catch (AxisFault e) {
+ throw new SavanException(e);
+ }
+ }
+
+ public void renewSubscription(ExpirationBean bean) {
+ if (bean.isDuration()) {
+ if (subscriptionEndingTime == null) {
+ Calendar calendar = Calendar.getInstance();
+ CommonUtil.addDurationToCalendar(calendar, bean.getDurationValue());
+ subscriptionEndingTime = calendar.getTime();
+ } else {
+ Calendar expiration = Calendar.getInstance();
+ expiration.setTime(subscriptionEndingTime);
+ CommonUtil.addDurationToCalendar(expiration, bean.getDurationValue());
+ subscriptionEndingTime = expiration.getTime();
+ }
+ } else
+ subscriptionEndingTime = bean.getDateValue();
}
}
diff --git a/modules/core/src/main/java/org/apache/savan/filters/EmptyFilter.java b/modules/core/src/main/java/org/apache/savan/filters/EmptyFilter.java
index 013ca64..ed05ca1 100644
--- a/modules/core/src/main/java/org/apache/savan/filters/EmptyFilter.java
+++ b/modules/core/src/main/java/org/apache/savan/filters/EmptyFilter.java
@@ -20,21 +20,18 @@
import org.apache.axiom.om.OMNode;
import org.apache.savan.SavanException;
-/**
- * This filter does not do any affective filtering.
- * May be the default for some protocols.
- */
+/** This filter does not do any affective filtering. May be the default for some protocols. */
public class EmptyFilter implements Filter {
- public boolean checkCompliance(OMElement envelope) throws SavanException {
- return true;
- }
+ public boolean checkCompliance(OMElement envelope) throws SavanException {
+ return true;
+ }
- public Object getFilterValue() {
- return null;
- }
+ public Object getFilterValue() {
+ return null;
+ }
- public void setUp(OMNode element) {
- }
-
+ public void setUp(OMNode element) {
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/filters/Filter.java b/modules/core/src/main/java/org/apache/savan/filters/Filter.java
index 0a60e6c..de6b125 100644
--- a/modules/core/src/main/java/org/apache/savan/filters/Filter.java
+++ b/modules/core/src/main/java/org/apache/savan/filters/Filter.java
@@ -21,33 +21,31 @@
import org.apache.axiom.om.OMNode;
import org.apache.savan.SavanException;
-/**
- * Defines a filter used by Savan.
- *
- */
+/** Defines a filter used by Savan. */
public interface Filter {
-
- /**
- * To check weather the passed envelope is compliant with the current filter.
- * @param envelope
- * @return
- * @throws SavanException
- */
- public boolean checkCompliance (OMElement element) 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 void setUp (OMNode element);
-
- /**
- * Returns a previously set filter value.
- *
- * @return
- */
+
+ /**
+ * To check weather the passed envelope is compliant with the current filter.
+ *
+ * @param envelope
+ * @return
+ * @throws SavanException
+ */
+ public boolean checkCompliance(OMElement element) 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 void setUp(OMNode element);
+
+ /**
+ * Returns a previously set filter value.
+ *
+ * @return
+ */
public Object getFilterValue ();
}
diff --git a/modules/core/src/main/java/org/apache/savan/filters/XPathBasedFilter.java b/modules/core/src/main/java/org/apache/savan/filters/XPathBasedFilter.java
index 4ccb4d5..eae1098 100644
--- a/modules/core/src/main/java/org/apache/savan/filters/XPathBasedFilter.java
+++ b/modules/core/src/main/java/org/apache/savan/filters/XPathBasedFilter.java
@@ -17,80 +17,57 @@
package org.apache.savan.filters;
-import java.util.List;
-
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMText;
import org.apache.axiom.om.xpath.AXIOMXPath;
-import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.savan.SavanException;
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
import org.jaxen.JaxenException;
-/**
- * A filter that does filtering of messages based on a XPath string.
- *
- */
+import java.util.List;
+
+/** A filter that does filtering of messages based on a XPath string. */
public class XPathBasedFilter implements Filter {
-
- public static String XPATH_BASED_FILTER = "http://www.w3.org/TR/1999/REC-xpath-19991116";
- private String XPathString = null;
-
- public String getXPathString() {
- return XPathString;
- }
+ public static String XPATH_BASED_FILTER = "http://www.w3.org/TR/1999/REC-xpath-19991116";
- public void setXPathString(String XPathString) {
- this.XPathString = XPathString;
- }
+ private String XPathString = null;
- /**
- * This method may fail due to the JIRA issues WS-Commons(40) amd WS-Commons (41)
- */
- public boolean checkCompliance (OMElement element) throws SavanException {
-
- if (XPathString==null)
- return true;
-
- try {
- AXIOMXPath xpath = new AXIOMXPath (XPathString);
- List resultList = xpath.selectNodes(element);
+ public String getXPathString() {
+ return XPathString;
+ }
+
+ public void setXPathString(String XPathString) {
+ this.XPathString = XPathString;
+ }
+
+ /** This method may fail due to the JIRA issues WS-Commons(40) amd WS-Commons (41) */
+ public boolean checkCompliance(OMElement element) throws SavanException {
+
+ if (XPathString == null)
+ return true;
+
+ try {
+ AXIOMXPath xpath = new AXIOMXPath(XPathString);
+ List resultList = xpath.selectNodes(element);
return resultList.size() > 0;
- } catch (JaxenException e) {
- throw new SavanException (e);
- }
- }
+ } catch (JaxenException e) {
+ throw new SavanException(e);
+ }
+ }
- public void setUp(OMNode element) {
- if (!(element instanceof OMText))
- throw new IllegalArgumentException ("Cannot determine a valid XPath string");
-
- OMText text = (OMText) element;
- XPathString = text.getText();
- }
+ public void setUp(OMNode element) {
+ if (!(element instanceof OMText))
+ throw new IllegalArgumentException("Cannot determine a valid XPath string");
- public Object getFilterValue() {
- return XPathString;
- }
+ OMText text = (OMText)element;
+ XPathString = text.getText();
+ }
-
+ public Object getFilterValue() {
+ return XPathString;
+ }
+
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/messagereceiver/MessageReceiverDeligater.java b/modules/core/src/main/java/org/apache/savan/messagereceiver/MessageReceiverDeligater.java
index 13191bd..2fa6fb6 100644
--- a/modules/core/src/main/java/org/apache/savan/messagereceiver/MessageReceiverDeligater.java
+++ b/modules/core/src/main/java/org/apache/savan/messagereceiver/MessageReceiverDeligater.java
@@ -21,7 +21,6 @@
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
-import org.apache.axis2.engine.Handler.InvocationResponse;
import org.apache.savan.SavanConstants;
import org.apache.savan.SavanException;
import org.apache.savan.SavanMessageContext;
@@ -29,84 +28,84 @@
import org.apache.savan.configuration.Protocol;
import org.apache.savan.storage.SubscriberStore;
import org.apache.savan.subscription.SubscriptionProcessor;
-import org.apache.savan.util.ProtocolManager;
import org.apache.savan.util.UtilFactory;
-/**
- * Provide abstract functions that may be done by protocols at the MessageReceiver level.
- *
- */
+/** Provide abstract functions that may be done by protocols at the MessageReceiver level. */
public abstract class MessageReceiverDeligater {
-
-
- public void processMessage (SavanMessageContext smc) throws SavanException {
- MessageContext msgContext = smc.getMessageContext();
-
- //setting the Protocol
- Protocol protocol = smc.getProtocol();
-
- if (protocol==null) {
- //this message does not have a matching protocol
- //so let it go
- throw new SavanException ("Cannot find a matching protocol");
- }
-
- smc.setProtocol(protocol);
-
- AxisService axisService = msgContext.getAxisService();
- if (axisService==null)
- throw new SavanException ("Service context is null");
-
- //setting the AbstractSubscriber Store
- Parameter parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
- if (parameter==null){
- setSubscriberStore (smc);
- parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
- }
-
- UtilFactory utilFactory = smc.getProtocol().getUtilFactory();
- utilFactory.initializeMessage (smc);
-
- int messageType = smc.getMessageType ();
- SubscriptionProcessor processor = utilFactory.createSubscriptionProcessor ();
- processor.init (smc);
- if (messageType==SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE) {
- processor.subscribe(smc);
- } else if (messageType==SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE) {
- processor.unsubscribe(smc);
- } else if (messageType==SavanConstants.MessageTypes.RENEW_MESSAGE) {
- processor.renewSubscription(smc);
- }else if (messageType==SavanConstants.MessageTypes.PUBLISH) {
- processor.publish(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);
- }
-
- }
-
- public abstract void doProtocolSpecificProcessing (SavanMessageContext inSavanMessage, MessageContext outMessage) throws SavanException;
-
- public abstract void doProtocolSpecificProcessing (SavanMessageContext inSavanMessage) throws SavanException;
+ public void processMessage(SavanMessageContext smc) throws SavanException {
+ MessageContext msgContext = smc.getMessageContext();
+
+ //setting the Protocol
+ Protocol protocol = smc.getProtocol();
+
+ if (protocol == null) {
+ //this message does not have a matching protocol
+ //so let it go
+ throw new SavanException("Cannot find a matching protocol");
+ }
+
+ smc.setProtocol(protocol);
+
+ AxisService axisService = msgContext.getAxisService();
+ if (axisService == null)
+ throw new SavanException("Service context is null");
+
+ //setting the AbstractSubscriber Store
+ Parameter parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
+ if (parameter == null) {
+ setSubscriberStore(smc);
+ parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
+ }
+
+ UtilFactory utilFactory = smc.getProtocol().getUtilFactory();
+ utilFactory.initializeMessage(smc);
+
+ int messageType = smc.getMessageType();
+
+ SubscriptionProcessor processor = utilFactory.createSubscriptionProcessor();
+ processor.init(smc);
+ if (messageType == SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE) {
+ processor.subscribe(smc);
+ } else if (messageType == SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE) {
+ processor.unsubscribe(smc);
+ } else if (messageType == SavanConstants.MessageTypes.RENEW_MESSAGE) {
+ processor.renewSubscription(smc);
+ } else if (messageType == SavanConstants.MessageTypes.PUBLISH) {
+ processor.publish(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);
+ }
+
+ }
+
+ public abstract void doProtocolSpecificProcessing(SavanMessageContext inSavanMessage,
+ MessageContext outMessage)
+ throws SavanException;
+
+ public abstract void doProtocolSpecificProcessing(SavanMessageContext inSavanMessage)
+ throws SavanException;
}
diff --git a/modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java b/modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java
index c8a82a9..c5db337 100644
--- a/modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java
+++ b/modules/core/src/main/java/org/apache/savan/messagereceiver/PublishingMessageReceiver.java
@@ -1,12 +1,5 @@
package org.apache.savan.messagereceiver;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.HashMap;
-import java.util.StringTokenizer;
-
-import javax.xml.namespace.QName;
-
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.soap.SOAPEnvelope;
@@ -18,59 +11,69 @@
import org.apache.savan.eventing.EventingConstants;
import org.apache.savan.publication.client.PublicationClient;
+import javax.xml.namespace.QName;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.StringTokenizer;
+
/**
- * This Message reciver handles the publish requests. It will received all messages sent to SOAP/WS action
- * http://ws.apache.org/ws/2007/05/eventing-extended/Publish, or request URL http://<host>:port//services/<service-name>/publish.
- * It will search for topic in URL query parameter "topic" or
- * Soap Header <eevt::topic xmlns="http://ws.apache.org/ws/2007/05/eventing-extended">...</topic>
+ * This Message reciver handles the publish requests. It will received all messages sent to SOAP/WS
+ * action http://ws.apache.org/ws/2007/05/eventing-extended/Publish, or request URL
+ * http://<host>:port//services/<service-name>/publish. It will search for topic in URL query
+ * parameter "topic" or Soap Header <eevt::topic xmlns="http://ws.apache.org/ws/2007/05/eventing-extended">...</topic>
+ *
* @author Srinath Perera (hemapani@apache.org)
*/
-public class PublishingMessageReceiver implements MessageReceiver{
-
- public void receive(MessageContext messageCtx) throws AxisFault {
- try {
- String toAddress = messageCtx.getTo().getAddress();
- //Here we try to locate the topic. It can be either a query parameter of the input address or a header
- //in the SOAP evvelope
- URI topic = null;
-
- SOAPEnvelope requestEnvelope = messageCtx.getEnvelope();
- int querySeperatorIndex = toAddress.indexOf('?');
- if(querySeperatorIndex > 0){
- String queryString = toAddress.substring(querySeperatorIndex+1);
- HashMap map = new HashMap();
- StringTokenizer t = new StringTokenizer(queryString,"=&");
- while(t.hasMoreTokens()){
- map.put(t.nextToken(), t.nextToken());
- }
- if(map.containsKey(EventingConstants.ElementNames.Topic)){
- topic = new URI((String)map.get(EventingConstants.ElementNames.Topic));
- }
- }else{
- OMElement topicHeader = requestEnvelope.getHeader().getFirstChildWithName(new QName(EventingConstants.EXTENDED_EVENTING_NAMESPACE,
- EventingConstants.ElementNames.Topic));
- if(topicHeader != null){
- topic = new URI(topicHeader.getText());
- }
- }
-
- //Here we locate the content of the Event. If this is APP we unwrap APP wrapping elements.
- OMElement eventData = requestEnvelope.getBody().getFirstElement();
- if(AtomConstants.ATOM_NAMESPACE.equals(eventData.getNamespace().getNamespaceURI()) &&
- AtomConstants.ElementNames.Entry.equals(eventData.getLocalName())){
- OMElement content = eventData.getFirstChildWithName(new QName(AtomConstants.ATOM_NAMESPACE,AtomConstants.ElementNames.Content));
- if(content != null && content.getFirstElement() != null){
- eventData.getFirstElement();
- }
- }
- //Use in memory API to publish the event
- ServiceContext serviceContext = messageCtx.getServiceContext();
- PublicationClient client = new PublicationClient(serviceContext.getConfigurationContext());
- client.sendPublication(eventData,serviceContext.getAxisService(),topic);
- } catch (OMException e) {
- throw AxisFault.makeFault(e);
- } catch (URISyntaxException e) {
- throw AxisFault.makeFault(e);
- }
- }
+public class PublishingMessageReceiver implements MessageReceiver {
+
+ public void receive(MessageContext messageCtx) throws AxisFault {
+ try {
+ String toAddress = messageCtx.getTo().getAddress();
+ //Here we try to locate the topic. It can be either a query parameter of the input address or a header
+ //in the SOAP evvelope
+ URI topic = null;
+
+ SOAPEnvelope requestEnvelope = messageCtx.getEnvelope();
+ int querySeperatorIndex = toAddress.indexOf('?');
+ if (querySeperatorIndex > 0) {
+ String queryString = toAddress.substring(querySeperatorIndex + 1);
+ HashMap map = new HashMap();
+ StringTokenizer t = new StringTokenizer(queryString, "=&");
+ while (t.hasMoreTokens()) {
+ map.put(t.nextToken(), t.nextToken());
+ }
+ if (map.containsKey(EventingConstants.ElementNames.Topic)) {
+ topic = new URI((String)map.get(EventingConstants.ElementNames.Topic));
+ }
+ } else {
+ OMElement topicHeader = requestEnvelope.getHeader().getFirstChildWithName(
+ new QName(EventingConstants.EXTENDED_EVENTING_NAMESPACE,
+ EventingConstants.ElementNames.Topic));
+ if (topicHeader != null) {
+ topic = new URI(topicHeader.getText());
+ }
+ }
+
+ //Here we locate the content of the Event. If this is APP we unwrap APP wrapping elements.
+ OMElement eventData = requestEnvelope.getBody().getFirstElement();
+ if (AtomConstants.ATOM_NAMESPACE.equals(eventData.getNamespace().getNamespaceURI()) &&
+ AtomConstants.ElementNames.Entry.equals(eventData.getLocalName())) {
+ OMElement content = eventData.getFirstChildWithName(new QName(
+ AtomConstants.ATOM_NAMESPACE, AtomConstants.ElementNames.Content));
+ if (content != null && content.getFirstElement() != null) {
+ eventData.getFirstElement();
+ }
+ }
+ //Use in memory API to publish the event
+ ServiceContext serviceContext = messageCtx.getServiceContext();
+ PublicationClient client =
+ new PublicationClient(serviceContext.getConfigurationContext());
+ client.sendPublication(eventData, serviceContext.getAxisService(), topic);
+ } catch (OMException e) {
+ throw AxisFault.makeFault(e);
+ } catch (URISyntaxException e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java b/modules/core/src/main/java/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java
index c8970a0..8f07de7 100644
--- a/modules/core/src/main/java/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java
+++ b/modules/core/src/main/java/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java
@@ -22,14 +22,13 @@
import org.apache.axis2.receivers.AbstractInMessageReceiver;
/**
- * InOnly message deceiver for Savan.
- * May get called for control messages depending on the protocol.
- *
+ * 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 {
- }
+ public void invokeBusinessLogic(MessageContext inMessage) throws AxisFault {
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java b/modules/core/src/main/java/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java
index 3233dc3..311106f 100644
--- a/modules/core/src/main/java/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java
+++ b/modules/core/src/main/java/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java
@@ -26,32 +26,30 @@
import org.apache.savan.util.ProtocolManager;
import org.apache.savan.util.UtilFactory;
-/**
- * InOut message deceiver for Savan.
- * May get called for control messages depending on the protocol.
- */
+/** 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 {
+ public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage)
+ throws AxisFault {
- SavanMessageContext savanInMessage = new SavanMessageContext (inMessage);
-
- //setting the Protocol
- Protocol protocol = ProtocolManager.getMessageProtocol(savanInMessage);
- if (protocol==null) {
- //this message does not have a matching protocol
- //so let it go
- throw new SavanException ("Cannot find a matching protocol");
- }
-
- savanInMessage.setProtocol(protocol);
-
- UtilFactory utilFactory = protocol.getUtilFactory();
- MessageReceiverDeligater deligator = utilFactory.createMessageReceiverDeligater();
-
- deligator.processMessage(savanInMessage);
- deligator.doProtocolSpecificProcessing (savanInMessage, outMessage);
-
- }
+ SavanMessageContext savanInMessage = new SavanMessageContext(inMessage);
+
+ //setting the Protocol
+ Protocol protocol = ProtocolManager.getMessageProtocol(savanInMessage);
+ if (protocol == null) {
+ //this message does not have a matching protocol
+ //so let it go
+ throw new SavanException("Cannot find a matching protocol");
+ }
+
+ savanInMessage.setProtocol(protocol);
+
+ UtilFactory utilFactory = protocol.getUtilFactory();
+ MessageReceiverDeligater deligator = utilFactory.createMessageReceiverDeligater();
+
+ deligator.processMessage(savanInMessage);
+ deligator.doProtocolSpecificProcessing(savanInMessage, outMessage);
+
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/module/SavanModule.java b/modules/core/src/main/java/org/apache/savan/module/SavanModule.java
index 3193ad4..07167dd 100644
--- a/modules/core/src/main/java/org/apache/savan/module/SavanModule.java
+++ b/modules/core/src/main/java/org/apache/savan/module/SavanModule.java
@@ -22,7 +22,6 @@
import org.apache.axis2.description.AxisDescription;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
import org.apache.axis2.modules.Module;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -31,41 +30,37 @@
import org.apache.savan.SavanConstants;
import org.apache.savan.SavanException;
import org.apache.savan.configuration.ConfigurationManager;
-import org.apache.savan.storage.SubscriberStore;
-/**
- * Savan Module class.
- *
- */
-public class SavanModule implements Module {
+/** Savan Module class. */
+public class SavanModule implements Module {
- private static final Log log = LogFactory.getLog(SavanModule.class);
-
- public void engageNotify(AxisDescription axisDescription) throws AxisFault {
- //adding a subscriber store to the description
-
- if (axisDescription instanceof AxisService) { //TODO remove this restriction
+ private static final Log log = LogFactory.getLog(SavanModule.class);
- //TODO set a suitable SubscriberStore for the service.
-
- }
-
- }
+ public void engageNotify(AxisDescription axisDescription) throws AxisFault {
+ //adding a subscriber store to the description
- public void init(ConfigurationContext configContext, AxisModule module) throws AxisFault {
- ConfigurationManager configurationManager = new ConfigurationManager ();
- try {
- ClassLoader moduleClassLoader = module.getModuleClassLoader();
- configurationManager.configure(getClass().getClassLoader());
- } catch (SavanException e) {
- log.error ("Exception thrown while trying to configure the Savan module",e);
- }
-
- configContext.setProperty(SavanConstants.CONFIGURATION_MANAGER,configurationManager);
- }
+ if (axisDescription instanceof AxisService) { //TODO remove this restriction
- public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
- }
+ //TODO set a suitable SubscriberStore for the service.
+
+ }
+
+ }
+
+ public void init(ConfigurationContext configContext, AxisModule module) throws AxisFault {
+ ConfigurationManager configurationManager = new ConfigurationManager();
+ try {
+ ClassLoader moduleClassLoader = module.getModuleClassLoader();
+ configurationManager.configure(getClass().getClassLoader());
+ } catch (SavanException e) {
+ log.error("Exception thrown while trying to configure the Savan module", e);
+ }
+
+ configContext.setProperty(SavanConstants.CONFIGURATION_MANAGER, configurationManager);
+ }
+
+ public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
+ }
public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
// TODO
@@ -75,7 +70,6 @@
// TODO
return true;
}
-
-
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/publication/PublicationReport.java b/modules/core/src/main/java/org/apache/savan/publication/PublicationReport.java
index 2c03308..f5422f3 100644
--- a/modules/core/src/main/java/org/apache/savan/publication/PublicationReport.java
+++ b/modules/core/src/main/java/org/apache/savan/publication/PublicationReport.java
@@ -17,49 +17,46 @@
package org.apache.savan.publication;
+import org.apache.savan.SavanException;
+
import java.util.ArrayList;
import java.util.Hashtable;
-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.
+ * 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 () {
- errors = new Hashtable ();
- notifiedSubscribers = new ArrayList ();
- }
-
- public void addErrorReportEntry (String id, SavanException reason) {
- errors.put(id,reason);
- }
-
- public void addNotifiedSubscriber (String subscriberID) {
- notifiedSubscribers.add(subscriberID);
- }
+ /**
+ * The susbscribers to which this msg could not be sent. Probably their ID and the Exception that
+ * occured.
+ */
+ private Hashtable errors = null;
- public Hashtable getErrors() {
- return errors;
- }
+ /** Ids of the subscribers to which this msg could be sent successfully. */
+ private ArrayList notifiedSubscribers;
- public ArrayList getNotifiedSubscribers() {
- return notifiedSubscribers;
- }
+ public PublicationReport() {
+ errors = new Hashtable();
+ notifiedSubscribers = new ArrayList();
+ }
+
+ public void addErrorReportEntry(String id, SavanException reason) {
+ errors.put(id, reason);
+ }
+
+ public void addNotifiedSubscriber(String subscriberID) {
+ notifiedSubscribers.add(subscriberID);
+ }
+
+ public Hashtable getErrors() {
+ return errors;
+ }
+
+ public ArrayList getNotifiedSubscribers() {
+ return notifiedSubscribers;
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/publication/client/PublicationClient.java b/modules/core/src/main/java/org/apache/savan/publication/client/PublicationClient.java
index f712b8e..165c725 100644
--- a/modules/core/src/main/java/org/apache/savan/publication/client/PublicationClient.java
+++ b/modules/core/src/main/java/org/apache/savan/publication/client/PublicationClient.java
@@ -17,27 +17,11 @@
package org.apache.savan.publication.client;
-import java.net.URI;
-import java.net.URL;
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.OperationClient;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.AxisService;
-import org.apache.axis2.description.Parameter;
-import org.apache.savan.SavanConstants;
import org.apache.savan.SavanException;
import org.apache.savan.publication.PublicationReport;
import org.apache.savan.storage.SubscriberStore;
@@ -45,79 +29,87 @@
import org.apache.savan.subscribers.SubscriberGroup;
import org.apache.savan.util.CommonUtil;
+import java.net.URI;
+import java.util.Iterator;
+
/**
- * This can be used to make the Publication Process easy.
- * Handle things like engaging the savan module correctly and setting the
- * correct subscriber store.
+ * 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 final String TEMP_PUBLICATION_ACTION = "UUID:TempPublicationAction";
- private ConfigurationContext configurationContext = null;
-
- public PublicationClient (ConfigurationContext configurationContext) {
- this.configurationContext = configurationContext;
- }
- /**
- * This can be used by the Publishers in the same JVM (e.g. a service deployed in the same Axis2 instance).
- *
- * @param eventData - The XML message to be published
- * @param service - The service to which this publication is bound to (i.e. this will be only sent to the subscribers of this service)
- * @param eventName - The name of the event, this can be a action which represents an out only operation or a Topic ID.
- *
- * @throws SavanException
- */
- public void sendPublication (OMElement eventData, AxisService service, URI eventName) throws SavanException {
-
- try {
-
- SubscriberStore subscriberStore = CommonUtil.getSubscriberStore(service);
- if (subscriberStore==null)
- throw new SavanException ("Cannot find the Subscriber Store");
-
- PublicationReport report = new PublicationReport();
- if (eventName!=null) {
- //there should be a valid operation or a SubscriberGroup to match this event.
- AxisOperation operation = getAxisOperationFromEventName (eventName);
- if (operation!=null) {
- //send to all subscribers with this operation.
- throw new UnsupportedOperationException ("Not implemented");
- } else {
- //there should be a valid SubscriberGroup to match this eventName
-
- String groupId = eventName.toString();
- SubscriberGroup group = (SubscriberGroup) subscriberStore.getSubscriberGroup(groupId);
- if (group!=null)
- group.sendEventDataToGroup(eventData);
- else
- throw new SavanException ("Could not find a subscriberGroup or an operation to match the eventName");
+ public static final String TEMP_PUBLICATION_ACTION = "UUID:TempPublicationAction";
+ private ConfigurationContext configurationContext = null;
- }
- } else {
- //no event name, so send it to everybody.
-
- //sending to all individual subscribers
- for (Iterator iter = subscriberStore.retrieveAllSubscribers();iter.hasNext();){
- Subscriber subscriber = (Subscriber) iter.next();
- subscriber.sendEventData(eventData);
- }
-
- //sending to all Subscriber Groups
- for (Iterator iter = subscriberStore.retrieveAllSubscriberGroups();iter.hasNext();){
- SubscriberGroup subscriberGroup = (SubscriberGroup) iter.next();
- subscriberGroup.sendEventDataToGroup(eventData);
- }
- }
-
- } catch (AxisFault e) {
- String message = "Could not send the publication";
- throw new SavanException (message,e);
- }
- }
-
- private AxisOperation getAxisOperationFromEventName (URI eventName) {
- //TODO do operation lookup
+ public PublicationClient(ConfigurationContext configurationContext) {
+ this.configurationContext = configurationContext;
+ }
+
+ /**
+ * This can be used by the Publishers in the same JVM (e.g. a service deployed in the same Axis2
+ * instance).
+ *
+ * @param eventData - The XML message to be published
+ * @param service - The service to which this publication is bound to (i.e. this will be only
+ * sent to the subscribers of this service)
+ * @param eventName - The name of the event, this can be a action which represents an out only
+ * operation or a Topic ID.
+ * @throws SavanException
+ */
+ public void sendPublication(OMElement eventData, AxisService service, URI eventName)
+ throws SavanException {
+
+ try {
+
+ SubscriberStore subscriberStore = CommonUtil.getSubscriberStore(service);
+ if (subscriberStore == null)
+ throw new SavanException("Cannot find the Subscriber Store");
+
+ PublicationReport report = new PublicationReport();
+ if (eventName != null) {
+ //there should be a valid operation or a SubscriberGroup to match this event.
+ AxisOperation operation = getAxisOperationFromEventName(eventName);
+ if (operation != null) {
+ //send to all subscribers with this operation.
+ throw new UnsupportedOperationException("Not implemented");
+ } else {
+ //there should be a valid SubscriberGroup to match this eventName
+
+ String groupId = eventName.toString();
+ SubscriberGroup group =
+ (SubscriberGroup)subscriberStore.getSubscriberGroup(groupId);
+ if (group != null)
+ group.sendEventDataToGroup(eventData);
+ else
+ throw new SavanException(
+ "Could not find a subscriberGroup or an operation to match the eventName");
+
+ }
+ } else {
+ //no event name, so send it to everybody.
+
+ //sending to all individual subscribers
+ for (Iterator iter = subscriberStore.retrieveAllSubscribers(); iter.hasNext();) {
+ Subscriber subscriber = (Subscriber)iter.next();
+ subscriber.sendEventData(eventData);
+ }
+
+ //sending to all Subscriber Groups
+ for (Iterator iter = subscriberStore.retrieveAllSubscriberGroups();
+ iter.hasNext();) {
+ SubscriberGroup subscriberGroup = (SubscriberGroup)iter.next();
+ subscriberGroup.sendEventDataToGroup(eventData);
+ }
+ }
+
+ } catch (AxisFault e) {
+ String message = "Could not send the publication";
+ throw new SavanException(message, e);
+ }
+ }
+
+ private AxisOperation getAxisOperationFromEventName(URI eventName) {
+ //TODO do operation lookup
return null;
}
diff --git a/modules/core/src/main/java/org/apache/savan/storage/DefaultSubscriberStore.java b/modules/core/src/main/java/org/apache/savan/storage/DefaultSubscriberStore.java
index 64d610a..b007ac1 100644
--- a/modules/core/src/main/java/org/apache/savan/storage/DefaultSubscriberStore.java
+++ b/modules/core/src/main/java/org/apache/savan/storage/DefaultSubscriberStore.java
@@ -17,76 +17,76 @@
package org.apache.savan.storage;
-import java.net.URI;
-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;
import org.apache.savan.subscribers.SubscriberGroup;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
public class DefaultSubscriberStore implements SubscriberStore {
- private HashMap subscriberMap = null;
- private HashMap subscriberGroups = null;
-
- public DefaultSubscriberStore () {
- subscriberMap = new HashMap ();
- subscriberGroups = new HashMap ();
- }
-
- public void init(ConfigurationContext configurationContext) throws SavanException {
- // TODO Auto-generated method stub
- }
+ private HashMap subscriberMap = null;
+ private HashMap subscriberGroups = null;
- public Subscriber retrieve(String id) {
- return (Subscriber) subscriberMap.get(id);
- }
+ public DefaultSubscriberStore() {
+ subscriberMap = new HashMap();
+ subscriberGroups = new HashMap();
+ }
- public void store(Subscriber s) {
- URI subscriberID = s.getId();
- String key = subscriberID.toString();
- subscriberMap.put(key,s);
- }
+ public void init(ConfigurationContext configurationContext) throws SavanException {
+ // TODO Auto-generated method stub
+ }
- public void delete(String subscriberID) {
- subscriberMap.remove(subscriberID);
- }
+ public Subscriber retrieve(String id) {
+ return (Subscriber)subscriberMap.get(id);
+ }
- public Iterator retrieveAllSubscribers () {
- ArrayList allSubscribers = new ArrayList ();
- for (Iterator iter=subscriberMap.keySet().iterator();iter.hasNext();) {
- Object key = iter.next();
- allSubscribers.add(subscriberMap.get(key));
- }
- return allSubscribers.iterator();
- }
+ public void store(Subscriber s) {
+ URI subscriberID = s.getId();
+ String key = subscriberID.toString();
+ subscriberMap.put(key, s);
+ }
- public Iterator retrieveAllSubscriberGroups () {
- ArrayList allSubscriberGroups = new ArrayList ();
- for (Iterator iter=subscriberGroups.keySet().iterator();iter.hasNext();) {
- Object key = iter.next();
- allSubscriberGroups.add(subscriberGroups.get(key));
- }
- return allSubscriberGroups.iterator();
- }
-
- public void addSubscriberGroup(String groupId) {
- subscriberGroups.put(groupId, new SubscriberGroup ());
- }
+ public void delete(String subscriberID) {
+ subscriberMap.remove(subscriberID);
+ }
- public void addSubscriberToGroup(String listId, Subscriber subscriber) throws SavanException {
- SubscriberGroup subscriberGroup = (SubscriberGroup) subscriberGroups.get(listId);
- if (subscriberGroup!=null)
- subscriberGroup.addSubscriber (subscriber);
- else
- throw new SavanException ("Cannot find the Subscriber store");
- }
+ public Iterator retrieveAllSubscribers() {
+ ArrayList allSubscribers = new ArrayList();
+ for (Iterator iter = subscriberMap.keySet().iterator(); iter.hasNext();) {
+ Object key = iter.next();
+ allSubscribers.add(subscriberMap.get(key));
+ }
+ return allSubscribers.iterator();
+ }
- public SubscriberGroup getSubscriberGroup(String groupId) {
- return (SubscriberGroup) subscriberGroups.get(groupId);
- }
+ public Iterator retrieveAllSubscriberGroups() {
+ ArrayList allSubscriberGroups = new ArrayList();
+ for (Iterator iter = subscriberGroups.keySet().iterator(); iter.hasNext();) {
+ Object key = iter.next();
+ allSubscriberGroups.add(subscriberGroups.get(key));
+ }
+ return allSubscriberGroups.iterator();
+ }
+
+ public void addSubscriberGroup(String groupId) {
+ subscriberGroups.put(groupId, new SubscriberGroup());
+ }
+
+ public void addSubscriberToGroup(String listId, Subscriber subscriber) throws SavanException {
+ SubscriberGroup subscriberGroup = (SubscriberGroup)subscriberGroups.get(listId);
+ if (subscriberGroup != null)
+ subscriberGroup.addSubscriber(subscriber);
+ else
+ throw new SavanException("Cannot find the Subscriber store");
+ }
+
+ public SubscriberGroup getSubscriberGroup(String groupId) {
+ return (SubscriberGroup)subscriberGroups.get(groupId);
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/storage/SubscriberStore.java b/modules/core/src/main/java/org/apache/savan/storage/SubscriberStore.java
index 697e6d3..a8072a9 100644
--- a/modules/core/src/main/java/org/apache/savan/storage/SubscriberStore.java
+++ b/modules/core/src/main/java/org/apache/savan/storage/SubscriberStore.java
@@ -16,66 +16,63 @@
package org.apache.savan.storage;
-import java.util.Iterator;
-import java.util.List;
-
import org.apache.axis2.context.ConfigurationContext;
import org.apache.savan.SavanException;
import org.apache.savan.subscribers.Subscriber;
import org.apache.savan.subscribers.SubscriberGroup;
-/**
- * Defines the Storage for storing subscribers.
- */
+import java.util.Iterator;
+
+/** 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 retrieveAllSubscribers () throws SavanException;
+ /**
+ * To Initialize the storage.
+ *
+ * @param configurationContext
+ * @throws SavanException
+ */
+ void init(ConfigurationContext configurationContext) throws SavanException;
- Iterator retrieveAllSubscriberGroups () throws SavanException;
-
- /**
- * To delete a previously stored subscriber.
- *
- * @param subscriberID
- * @throws SavanException
- */
- void delete (String subscriberID) throws SavanException;
-
- SubscriberGroup getSubscriberGroup (String groupId) throws SavanException;
-
- void addSubscriberGroup (String subscriberList) throws SavanException;
-
- void addSubscriberToGroup (String groupId, Subscriber subscriber) 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 retrieveAllSubscribers() throws SavanException;
+
+ Iterator retrieveAllSubscriberGroups() throws SavanException;
+
+ /**
+ * To delete a previously stored subscriber.
+ *
+ * @param subscriberID
+ * @throws SavanException
+ */
+ void delete(String subscriberID) throws SavanException;
+
+ SubscriberGroup getSubscriberGroup(String groupId) throws SavanException;
+
+ void addSubscriberGroup(String subscriberList) throws SavanException;
+
+ void addSubscriberToGroup (String groupId, Subscriber subscriber) throws SavanException;
}
diff --git a/modules/core/src/main/java/org/apache/savan/subscribers/Subscriber.java b/modules/core/src/main/java/org/apache/savan/subscribers/Subscriber.java
index e768796..ba3fbc5 100644
--- a/modules/core/src/main/java/org/apache/savan/subscribers/Subscriber.java
+++ b/modules/core/src/main/java/org/apache/savan/subscribers/Subscriber.java
@@ -17,22 +17,24 @@
package org.apache.savan.subscribers;
-import java.net.URI;
-
import org.apache.axiom.om.OMElement;
import org.apache.savan.SavanException;
import org.apache.savan.subscription.ExpirationBean;
+import java.net.URI;
+
/**
- * Defines a subscriber which is the entity that define a specific subscription
- * in savan. Independent of the protocol type.
- *
+ * Defines a subscriber which is the entity that define a specific subscription in savan.
+ * Independent of the protocol type.
*/
-public interface Subscriber {
-
- public URI getId();
- public void setId(URI id);
- public void sendEventData (OMElement eventData) throws SavanException;
- public void renewSubscription (ExpirationBean bean);
-
+public interface Subscriber {
+
+ public URI getId();
+
+ public void setId(URI id);
+
+ public void sendEventData(OMElement eventData) throws SavanException;
+
+ public void renewSubscription(ExpirationBean bean);
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/subscribers/SubscriberGroup.java b/modules/core/src/main/java/org/apache/savan/subscribers/SubscriberGroup.java
index 1367c0a..9ae66c2 100644
--- a/modules/core/src/main/java/org/apache/savan/subscribers/SubscriberGroup.java
+++ b/modules/core/src/main/java/org/apache/savan/subscribers/SubscriberGroup.java
@@ -17,44 +17,41 @@
package org.apache.savan.subscribers;
+import org.apache.axiom.om.OMElement;
+import org.apache.savan.SavanException;
+
import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
-import org.apache.axiom.om.OMElement;
-import org.apache.savan.SavanException;
+/** Defines a set of subscribers that are acting as a group or a Topic. */
+public class SubscriberGroup {
-/**
- * Defines a set of subscribers that are acting as a group or a Topic.
- *
- */
-public class SubscriberGroup {
+ protected ArrayList subscribers = null;
- protected ArrayList subscribers = null;
-
- private URI id;
-
- public URI getId() {
- return id;
- }
+ private URI id;
- public void setId(URI id) {
- this.id = id;
- }
+ public URI getId() {
+ return id;
+ }
- public SubscriberGroup (){
- subscribers = new ArrayList ();
- }
-
- public void addSubscriber (Subscriber subscriber) throws SavanException {
- subscribers.add(subscriber);
- }
+ public void setId(URI id) {
+ this.id = id;
+ }
- public void sendEventDataToGroup(OMElement eventData) throws SavanException {
- for (Iterator it = subscribers.iterator();it.hasNext();) {
- Subscriber subscriber = (Subscriber) it.next();
- subscriber.sendEventData(eventData);
- }
- }
-
+ public SubscriberGroup() {
+ subscribers = new ArrayList();
+ }
+
+ public void addSubscriber(Subscriber subscriber) throws SavanException {
+ subscribers.add(subscriber);
+ }
+
+ public void sendEventDataToGroup(OMElement eventData) throws SavanException {
+ for (Iterator it = subscribers.iterator(); it.hasNext();) {
+ Subscriber subscriber = (Subscriber)it.next();
+ subscriber.sendEventData(eventData);
+ }
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/subscription/ExpirationBean.java b/modules/core/src/main/java/org/apache/savan/subscription/ExpirationBean.java
index 7969429..0294839 100644
--- a/modules/core/src/main/java/org/apache/savan/subscription/ExpirationBean.java
+++ b/modules/core/src/main/java/org/apache/savan/subscription/ExpirationBean.java
@@ -17,49 +17,47 @@
package org.apache.savan.subscription;
-import java.util.Date;
-
import org.apache.axis2.databinding.types.Duration;
-/**
- * Defines a expiration. Could be based on a specific time in the future or a duration.
- */
+import java.util.Date;
+
+/** Defines a expiration. Could be based on a specific time in the future or a duration. */
public class ExpirationBean {
- Date dateValue;
- Duration durationValue;
- String subscriberID;
- boolean duration;
-
- public String getSubscriberID() {
- return subscriberID;
- }
-
- public void setSubscriberID(String subscriberID) {
- this.subscriberID = subscriberID;
- }
-
- public boolean isDuration() {
- return duration;
- }
-
- public void setDuration(boolean duration) {
- this.duration = duration;
- }
+ Date dateValue;
+ Duration durationValue;
+ String subscriberID;
+ boolean duration;
- public Date getDateValue() {
- return dateValue;
- }
+ public String getSubscriberID() {
+ return subscriberID;
+ }
- public Duration getDurationValue() {
- return durationValue;
- }
+ public void setSubscriberID(String subscriberID) {
+ this.subscriberID = subscriberID;
+ }
- public void setDateValue(Date dateValue) {
- this.dateValue = dateValue;
- }
+ public boolean isDuration() {
+ return duration;
+ }
- public void setDurationValue(Duration durationValue) {
- this.durationValue = durationValue;
- }
+ public void setDuration(boolean duration) {
+ this.duration = duration;
+ }
+
+ public Date getDateValue() {
+ return dateValue;
+ }
+
+ public Duration getDurationValue() {
+ return durationValue;
+ }
+
+ public void setDateValue(Date dateValue) {
+ this.dateValue = dateValue;
+ }
+
+ public void setDurationValue(Duration durationValue) {
+ this.durationValue = durationValue;
+ }
}
diff --git a/modules/core/src/main/java/org/apache/savan/subscription/RenewBean.java b/modules/core/src/main/java/org/apache/savan/subscription/RenewBean.java
index 5f0b3ae..7228908 100644
--- a/modules/core/src/main/java/org/apache/savan/subscription/RenewBean.java
+++ b/modules/core/src/main/java/org/apache/savan/subscription/RenewBean.java
@@ -17,26 +17,27 @@
package org.apache.savan.subscription;
-/**
- * Encapsulates a data for a subscrpition renewal.
- */
+/** Encapsulates a data for a subscrpition renewal. */
public class RenewBean {
- long renewMount;
- String subscriberID;
-
- public long getRenewMount() {
- return renewMount;
- }
- public String getSubscriberID() {
- return subscriberID;
- }
- public void setRenewMount(long renewMount) {
- this.renewMount = renewMount;
- }
- public void setSubscriberID(String subscriberID) {
- this.subscriberID = subscriberID;
- }
-
-
+ long renewMount;
+ String subscriberID;
+
+ public long getRenewMount() {
+ return renewMount;
+ }
+
+ public String getSubscriberID() {
+ return subscriberID;
+ }
+
+ public void setRenewMount(long renewMount) {
+ this.renewMount = renewMount;
+ }
+
+ public void setSubscriberID(String subscriberID) {
+ this.subscriberID = subscriberID;
+ }
+
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/subscription/SubscriptionProcessor.java b/modules/core/src/main/java/org/apache/savan/subscription/SubscriptionProcessor.java
index 8088600..02eff7d 100644
--- a/modules/core/src/main/java/org/apache/savan/subscription/SubscriptionProcessor.java
+++ b/modules/core/src/main/java/org/apache/savan/subscription/SubscriptionProcessor.java
@@ -26,86 +26,88 @@
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.
- */
+/** 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 {
- String subscriberID = getSubscriberID (endSubscriptionMessage);
- if (subscriberID==null) {
- String message = "Cannot find the subscriber ID";
- throw new SavanException (message);
- }
-
- SubscriberStore store = endSubscriptionMessage.getSubscriberStore();
- if (store==null)
- throw new SavanException ("AbstractSubscriber store not found");
-
- store.delete (subscriberID);
- }
- public void renewSubscription(SavanMessageContext renewMessage) throws SavanException {
- SubscriberStore store = renewMessage.getSubscriberStore();
- if (store==null)
- throw new SavanException ("AbstractSubscriber store not found");
-
- ExpirationBean bean = getExpirationBean(renewMessage);
- Subscriber subscriber = (Subscriber) store.retrieve(bean.getSubscriberID());
- if (subscriber==null) {
- throw new SavanException ("Given subscriber is not present");
- }
-
- subscriber.renewSubscription(bean);
- }
+ public abstract void init(SavanMessageContext smc) throws SavanException;
- public void subscribe(SavanMessageContext subscriptionMessage) throws SavanException {
- SubscriberStore store = subscriptionMessage.getSubscriberStore();
- if (store==null)
- throw new SavanException ("AbstractSubscriber store not found");
-
- if (store==null)
- throw new SavanException ("Sabscriber store not found");
-
- Subscriber subscriber = getSubscriberFromMessage (subscriptionMessage);
- 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);
+ public void unsubscribe(SavanMessageContext endSubscriptionMessage) throws SavanException {
+ String subscriberID = getSubscriberID(endSubscriptionMessage);
+ if (subscriberID == null) {
+ String message = "Cannot find the subscriber ID";
+ throw new SavanException(message);
+ }
+
+ SubscriberStore store = endSubscriptionMessage.getSubscriberStore();
+ if (store == null)
+ throw new SavanException("AbstractSubscriber store not found");
+
+ store.delete(subscriberID);
+ }
+
+ public void renewSubscription(SavanMessageContext renewMessage) throws SavanException {
+ SubscriberStore store = renewMessage.getSubscriberStore();
+ if (store == null)
+ throw new SavanException("AbstractSubscriber store not found");
+
+ ExpirationBean bean = getExpirationBean(renewMessage);
+ Subscriber subscriber = (Subscriber)store.retrieve(bean.getSubscriberID());
+ if (subscriber == null) {
+ throw new SavanException("Given subscriber is not present");
+ }
+
+ subscriber.renewSubscription(bean);
+ }
+
+ public void subscribe(SavanMessageContext subscriptionMessage) throws SavanException {
+ SubscriberStore store = subscriptionMessage.getSubscriberStore();
+ if (store == null)
+ throw new SavanException("AbstractSubscriber store not found");
+
+ if (store == null)
+ throw new SavanException("Sabscriber store not found");
+
+ Subscriber subscriber = getSubscriberFromMessage(subscriptionMessage);
+ 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 void publish(SavanMessageContext publishMessage) throws SavanException{
- //TODO handle Topics
- SOAPEnvelope requestEnvelope = publishMessage.getEnvelope();
- ServiceContext serviceContext = publishMessage.getMessageContext().getServiceContext();
- PublicationClient client = new PublicationClient(serviceContext.getConfigurationContext());
- client.sendPublication(requestEnvelope.getBody().getFirstElement(),serviceContext.getAxisService(),null);
- }
-
-
-
- public abstract void pauseSubscription (SavanMessageContext pauseSubscriptionMessage) throws SavanException;
-
- public abstract void resumeSubscription (SavanMessageContext resumeSubscriptionMessage) throws SavanException;
-
- public abstract Subscriber getSubscriberFromMessage (SavanMessageContext smc) throws SavanException;
-
- public abstract ExpirationBean getExpirationBean (SavanMessageContext renewMessage) throws SavanException;
-
- public abstract String getSubscriberID (SavanMessageContext smc) throws SavanException;
-
+
+ store.delete(subscriberID);
+ }
+
+ public void publish(SavanMessageContext publishMessage) throws SavanException {
+ //TODO handle Topics
+ SOAPEnvelope requestEnvelope = publishMessage.getEnvelope();
+ ServiceContext serviceContext = publishMessage.getMessageContext().getServiceContext();
+ PublicationClient client = new PublicationClient(serviceContext.getConfigurationContext());
+ client.sendPublication(requestEnvelope.getBody().getFirstElement(),
+ serviceContext.getAxisService(), null);
+ }
+
+
+ public abstract void pauseSubscription(SavanMessageContext pauseSubscriptionMessage)
+ throws SavanException;
+
+ public abstract void resumeSubscription(SavanMessageContext resumeSubscriptionMessage)
+ throws SavanException;
+
+ public abstract Subscriber getSubscriberFromMessage(SavanMessageContext smc)
+ throws SavanException;
+
+ public abstract ExpirationBean getExpirationBean(SavanMessageContext renewMessage)
+ throws SavanException;
+
+ public abstract String getSubscriberID(SavanMessageContext smc) throws SavanException;
+
}
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 df6c28a..aef08c0 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
@@ -17,16 +17,6 @@
package org.apache.savan.util;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Calendar;
-
-import javax.xml.stream.XMLInputFactory;
-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;
@@ -39,60 +29,71 @@
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.
- */
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Calendar;
+
+/** 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) {
- calendar.add(Calendar.YEAR,duration.getYears());
- calendar.add(Calendar.MONTH,duration.getMonths());
- calendar.add(Calendar.DATE,duration.getDays());
- calendar.add(Calendar.HOUR,duration.getHours());
- calendar.add(Calendar.MINUTE,duration.getMinutes());
- calendar.add(Calendar.SECOND,(int) duration.getSeconds());
-
- return calendar;
- }
-
- /**
- * Will be used by test cases to load XML files from test-resources as Envelopes
- * SOAP 1.1 is assumed
- *
- * @param path
- * @param name
- * @return
- */
- public static SOAPEnvelope getTestEnvelopeFromFile (String path, String name, SOAPFactory factory) throws IOException {
+ public static Calendar addDurationToCalendar(Calendar calendar, Duration duration) {
+ calendar.add(Calendar.YEAR, duration.getYears());
+ calendar.add(Calendar.MONTH, duration.getMonths());
+ calendar.add(Calendar.DATE, duration.getDays());
+ calendar.add(Calendar.HOUR, duration.getHours());
+ calendar.add(Calendar.MINUTE, duration.getMinutes());
+ calendar.add(Calendar.SECOND, (int)duration.getSeconds());
+
+ return calendar;
+ }
+
+ /**
+ * Will be used by test cases to load XML files from test-resources as Envelopes SOAP 1.1 is
+ * assumed
+ *
+ * @param path
+ * @param name
+ * @return
+ */
+ public static SOAPEnvelope getTestEnvelopeFromFile(String path,
+ String name,
+ SOAPFactory factory) throws IOException {
try {
- String fullName = path + File.separator + name;
+ String fullName = path + File.separator + name;
FileReader reader = new FileReader(fullName);
XMLStreamReader streamReader = XMLInputFactory.newInstance().createXMLStreamReader(
reader);
StAXSOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
- factory, streamReader);
+ factory, streamReader);
return builder.getSOAPEnvelope();
} catch (XMLStreamException e) {
throw new RuntimeException(e);
}
- }
-
- public static boolean isDuration (String timeStr) {
- return timeStr.startsWith("p") || timeStr.startsWith("P") || timeStr.startsWith("-p") || timeStr.startsWith("-P");
+ }
+
+ public static boolean isDuration(String timeStr) {
+ return timeStr.startsWith("p") || timeStr.startsWith("P") || timeStr.startsWith("-p") ||
+ timeStr.startsWith("-P");
}
-
- public static SubscriberStore getSubscriberStore (AxisService axisService) {
- Parameter parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
- if (parameter==null)
- return null;
-
- 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();
+
+ public static SubscriberStore getSubscriberStore(AxisService axisService) {
+ Parameter parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
+ if (parameter == null)
+ return null;
+
+ 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/core/src/main/java/org/apache/savan/util/ProtocolManager.java b/modules/core/src/main/java/org/apache/savan/util/ProtocolManager.java
index fe100ea..daa499c 100644
--- a/modules/core/src/main/java/org/apache/savan/util/ProtocolManager.java
+++ b/modules/core/src/main/java/org/apache/savan/util/ProtocolManager.java
@@ -17,9 +17,6 @@
package org.apache.savan.util;
-import java.util.HashMap;
-import java.util.Iterator;
-
import org.apache.savan.SavanConstants;
import org.apache.savan.SavanException;
import org.apache.savan.SavanMessageContext;
@@ -27,32 +24,34 @@
import org.apache.savan.configuration.MappingRules;
import org.apache.savan.configuration.Protocol;
-/**
- * Utility class to extract the Protocol type from a MessageContext
- */
+import java.util.HashMap;
+import java.util.Iterator;
+
+/** Utility class to extract the Protocol type from a MessageContext */
public class ProtocolManager {
- 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");
-
- String action = smc.getMessageContext().getOptions().getAction();
- if (action!=null) {
- HashMap map = configurationManager.getProtocolMap();
- Iterator iter = map.values().iterator();
- while (iter.hasNext()) {
- Protocol protocol = (Protocol) iter.next();
- MappingRules mappingRules = protocol.getMappingRules();
- if (mappingRules.ruleMatched (MappingRules.MAPPING_TYPE_ACTION, action)) {
- return protocol;
- }
- }
- }
-
- return null;
- }
-
+ 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");
+
+ String action = smc.getMessageContext().getOptions().getAction();
+ if (action != null) {
+ HashMap map = configurationManager.getProtocolMap();
+ Iterator iter = map.values().iterator();
+ while (iter.hasNext()) {
+ Protocol protocol = (Protocol)iter.next();
+ MappingRules mappingRules = protocol.getMappingRules();
+ if (mappingRules.ruleMatched(MappingRules.MAPPING_TYPE_ACTION, action)) {
+ return protocol;
+ }
+ }
+ }
+
+ return null;
+ }
+
}
diff --git a/modules/core/src/main/java/org/apache/savan/util/UtilFactory.java b/modules/core/src/main/java/org/apache/savan/util/UtilFactory.java
index 2263c19..a7b2547 100644
--- a/modules/core/src/main/java/org/apache/savan/util/UtilFactory.java
+++ b/modules/core/src/main/java/org/apache/savan/util/UtilFactory.java
@@ -18,20 +18,19 @@
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.
+ * 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 SavanMessageContext initializeMessage(SavanMessageContext messageContext);
+
+ public abstract SubscriptionProcessor createSubscriptionProcessor();
+
+ public abstract MessageReceiverDeligater createMessageReceiverDeligater();
+
}
diff --git a/modules/core/src/main/resources/savan-atom.xsd b/modules/core/src/main/resources/savan-atom.xsd
index b32ac26..680b45a 100644
--- a/modules/core/src/main/resources/savan-atom.xsd
+++ b/modules/core/src/main/resources/savan-atom.xsd
@@ -1,74 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
-<xs:schema targetNamespace="http://wso2.com/eventing/atom/"
- xmlns:savanAtom="http://wso2.com/eventing/atom/"
- xmlns:wsa="http://www.w3.org/2005/08/addressing"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:xwsdm="http://extreme.indiana.edu/wsdm/config/"
- elementFormDefault="qualified" attributeFormDefault="unqualified">
-
-
- <xs:import namespace="http://www.w3.org/2005/08/addressing"
+<xs:schema targetNamespace="http://wso2.com/eventing/atom/"
+ xmlns:savanAtom="http://wso2.com/eventing/atom/"
+ xmlns:wsa="http://www.w3.org/2005/08/addressing"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:xwsdm="http://extreme.indiana.edu/wsdm/config/"
+ elementFormDefault="qualified" attributeFormDefault="unqualified">
+
+
+ <xs:import namespace="http://www.w3.org/2005/08/addressing"
schemaLocation="ws-addr.xsd"/>
-
- <xs:element name="createFeed">
- <xs:complexType>
- <xs:all>
- <xs:element name="EndTo" type="wsa:EndpointReferenceType" minOccurs="0" maxOccurs="1" />
- <xs:element name="Expires" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
- <xs:element name="Filter" type="savanAtom:FilterType" minOccurs="0" maxOccurs="1" />
- <xs:element name="id" type="xs:string" minOccurs="0" maxOccurs="1" />
- <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1" />
- <xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1" />
- </xs:all>
- </xs:complexType>
- </xs:element>
-
-
- <xs:complexType name="DeliveryType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="Mode" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- <xs:complexType name="FilterType">
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="Dialect" type="xs:anyURI"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
-
- <xs:element name="createFeedResponse">
- <xs:complexType>
- <xs:all>
- <xs:element name="SubscriptionManager" type="wsa:EndpointReferenceType" minOccurs="1" maxOccurs="1" />
- <xs:element name="Expires" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
- <xs:element name="FeedUrl" type="xs:string" minOccurs="1" maxOccurs="1" />
- </xs:all>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="RenewFeed">
- <xs:complexType>
- <xs:all>
- <xs:element name="Expires" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
- </xs:all>
- </xs:complexType>
- </xs:element>
- <xs:element name="RenewFeedResponse">
- <xs:complexType>
- <xs:all>
- <xs:element name="Expires" type="xs:dateTime" minOccurs="0" maxOccurs="1" />
- </xs:all>
- </xs:complexType>
- </xs:element>
-
- <xs:element name="DeleteFeed" type="xs:string"/>
- <xs:element name="DeleteFeedResponse" type="xs:string"/>
-
+ <xs:element name="createFeed">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="EndTo" type="wsa:EndpointReferenceType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="Expires" type="xs:dateTime" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="Filter" type="savanAtom:FilterType" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="id" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"/>
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+
+ <xs:complexType name="DeliveryType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="Mode" type="xs:string"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="FilterType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute name="Dialect" type="xs:anyURI"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+
+ <xs:element name="createFeedResponse">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="SubscriptionManager" type="wsa:EndpointReferenceType" minOccurs="1"
+ maxOccurs="1"/>
+ <xs:element name="Expires" type="xs:dateTime" minOccurs="0" maxOccurs="1"/>
+ <xs:element name="FeedUrl" type="xs:string" minOccurs="1" maxOccurs="1"/>
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="RenewFeed">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="Expires" type="xs:dateTime" minOccurs="0" maxOccurs="1"/>
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="RenewFeedResponse">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="Expires" type="xs:dateTime" minOccurs="0" maxOccurs="1"/>
+ </xs:all>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="DeleteFeed" type="xs:string"/>
+ <xs:element name="DeleteFeedResponse" type="xs:string"/>
+
</xs:schema>
\ No newline at end of file
diff --git a/modules/core/src/main/resources/ws-addr.xsd b/modules/core/src/main/resources/ws-addr.xsd
index 29f13ec..34e0c0d 100644
--- a/modules/core/src/main/resources/ws-addr.xsd
+++ b/modules/core/src/main/resources/ws-addr.xsd
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "http://www.w3.org/2001/XMLSchema.dtd">
+<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN"
+ "http://www.w3.org/2001/XMLSchema.dtd">
<!--
W3C XML Schema defined in the Web Services Addressing 1.0 specification
http://www.w3.org/TR/ws-addr-core
@@ -16,130 +17,134 @@
$Id: ws-addr.xsd,v 1.3 2005/08/09 13:17:35 hugo Exp $
-->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.w3.org/2005/08/addressing" targetNamespace="http://www.w3.org/2005/08/addressing" blockDefault="#all" elementFormDefault="qualified" finalDefault="" attributeFormDefault="unqualified">
-
- <!-- Constructs from the WS-Addressing Core -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:tns="http://www.w3.org/2005/08/addressing"
+ targetNamespace="http://www.w3.org/2005/08/addressing" blockDefault="#all"
+ elementFormDefault="qualified" finalDefault="" attributeFormDefault="unqualified">
- <xs:element name="EndpointReference" type="tns:EndpointReferenceType"/>
- <xs:complexType name="EndpointReferenceType" mixed="false">
- <xs:sequence>
- <xs:element name="Address" type="tns:AttributedURIType"/>
- <xs:element name="ReferenceParameters" type="tns:ReferenceParametersType" minOccurs="0"/>
- <xs:element ref="tns:Metadata" minOccurs="0"/>
- <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:anyAttribute namespace="##other" processContents="lax"/>
- </xs:complexType>
-
- <xs:complexType name="ReferenceParametersType" mixed="false">
- <xs:sequence>
- <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:anyAttribute namespace="##other" processContents="lax"/>
- </xs:complexType>
-
- <xs:element name="Metadata" type="tns:MetadataType"/>
- <xs:complexType name="MetadataType" mixed="false">
- <xs:sequence>
- <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
- </xs:sequence>
- <xs:anyAttribute namespace="##other" processContents="lax"/>
- </xs:complexType>
-
- <xs:element name="MessageID" type="tns:AttributedURIType"/>
- <xs:element name="RelatesTo" type="tns:RelatesToType"/>
- <xs:complexType name="RelatesToType" mixed="false">
- <xs:simpleContent>
- <xs:extension base="xs:anyURI">
- <xs:attribute name="RelationshipType" type="tns:RelationshipTypeOpenEnum" use="optional" default="http://www.w3.org/2005/08/addressing/reply"/>
- <xs:anyAttribute namespace="##other" processContents="lax"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
- <xs:simpleType name="RelationshipTypeOpenEnum">
- <xs:union memberTypes="tns:RelationshipType xs:anyURI"/>
- </xs:simpleType>
-
- <xs:simpleType name="RelationshipType">
- <xs:restriction base="xs:anyURI">
- <xs:enumeration value="http://www.w3.org/2005/08/addressing/reply"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:element name="ReplyTo" type="tns:EndpointReferenceType"/>
- <xs:element name="From" type="tns:EndpointReferenceType"/>
- <xs:element name="FaultTo" type="tns:EndpointReferenceType"/>
- <xs:element name="To" type="tns:AttributedURIType"/>
- <xs:element name="Action" type="tns:AttributedURIType"/>
+ <!-- Constructs from the WS-Addressing Core -->
- <xs:complexType name="AttributedURIType" mixed="false">
- <xs:simpleContent>
- <xs:extension base="xs:anyURI">
- <xs:anyAttribute namespace="##other" processContents="lax"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
- <!-- Constructs from the WS-Addressing SOAP binding -->
+ <xs:element name="EndpointReference" type="tns:EndpointReferenceType"/>
+ <xs:complexType name="EndpointReferenceType" mixed="false">
+ <xs:sequence>
+ <xs:element name="Address" type="tns:AttributedURIType"/>
+ <xs:element name="ReferenceParameters" type="tns:ReferenceParametersType" minOccurs="0"/>
+ <xs:element ref="tns:Metadata" minOccurs="0"/>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
- <xs:attribute name="IsReferenceParameter" type="xs:boolean"/>
-
- <xs:simpleType name="FaultCodesOpenEnumType">
- <xs:union memberTypes="tns:FaultCodesType xs:QName"/>
- </xs:simpleType>
-
- <xs:simpleType name="FaultCodesType">
- <xs:restriction base="xs:QName">
- <xs:enumeration value="tns:InvalidAddressingHeader"/>
- <xs:enumeration value="tns:InvalidAddress"/>
- <xs:enumeration value="tns:InvalidEPR"/>
- <xs:enumeration value="tns:InvalidCardinality"/>
- <xs:enumeration value="tns:MissingAddressInEPR"/>
- <xs:enumeration value="tns:DuplicateMessageID"/>
- <xs:enumeration value="tns:ActionMismatch"/>
- <xs:enumeration value="tns:MessageAddressingHeaderRequired"/>
- <xs:enumeration value="tns:DestinationUnreachable"/>
- <xs:enumeration value="tns:ActionNotSupported"/>
- <xs:enumeration value="tns:EndpointUnavailable"/>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:element name="RetryAfter" type="tns:AttributedUnsignedLongType"/>
- <xs:complexType name="AttributedUnsignedLongType" mixed="false">
- <xs:simpleContent>
- <xs:extension base="xs:unsignedLong">
- <xs:anyAttribute namespace="##other" processContents="lax"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
- <xs:element name="ProblemHeaderQName" type="tns:AttributedQNameType"/>
- <xs:complexType name="AttributedQNameType" mixed="false">
- <xs:simpleContent>
- <xs:extension base="xs:QName">
- <xs:anyAttribute namespace="##other" processContents="lax"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
-
- <xs:element name="ProblemHeader" type="tns:AttributedAnyType"/>
- <xs:complexType name="AttributedAnyType" mixed="false">
- <xs:sequence>
- <xs:any namespace="##any" processContents="lax" minOccurs="1" maxOccurs="1"/>
- </xs:sequence>
- <xs:anyAttribute namespace="##other" processContents="lax"/>
- </xs:complexType>
-
- <xs:element name="ProblemIRI" type="tns:AttributedURIType"/>
-
- <xs:element name="ProblemAction" type="tns:ProblemActionType"/>
- <xs:complexType name="ProblemActionType" mixed="false">
- <xs:sequence>
- <xs:element ref="tns:Action" minOccurs="0"/>
- <xs:element name="SoapAction" minOccurs="0" type="xs:anyURI"/>
- </xs:sequence>
- <xs:anyAttribute namespace="##other" processContents="lax"/>
- </xs:complexType>
-
+ <xs:complexType name="ReferenceParametersType" mixed="false">
+ <xs:sequence>
+ <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+ <xs:element name="Metadata" type="tns:MetadataType"/>
+ <xs:complexType name="MetadataType" mixed="false">
+ <xs:sequence>
+ <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+ <xs:element name="MessageID" type="tns:AttributedURIType"/>
+ <xs:element name="RelatesTo" type="tns:RelatesToType"/>
+ <xs:complexType name="RelatesToType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:anyURI">
+ <xs:attribute name="RelationshipType" type="tns:RelationshipTypeOpenEnum" use="optional"
+ default="http://www.w3.org/2005/08/addressing/reply"/>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:simpleType name="RelationshipTypeOpenEnum">
+ <xs:union memberTypes="tns:RelationshipType xs:anyURI"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="RelationshipType">
+ <xs:restriction base="xs:anyURI">
+ <xs:enumeration value="http://www.w3.org/2005/08/addressing/reply"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:element name="ReplyTo" type="tns:EndpointReferenceType"/>
+ <xs:element name="From" type="tns:EndpointReferenceType"/>
+ <xs:element name="FaultTo" type="tns:EndpointReferenceType"/>
+ <xs:element name="To" type="tns:AttributedURIType"/>
+ <xs:element name="Action" type="tns:AttributedURIType"/>
+
+ <xs:complexType name="AttributedURIType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:anyURI">
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <!-- Constructs from the WS-Addressing SOAP binding -->
+
+ <xs:attribute name="IsReferenceParameter" type="xs:boolean"/>
+
+ <xs:simpleType name="FaultCodesOpenEnumType">
+ <xs:union memberTypes="tns:FaultCodesType xs:QName"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="FaultCodesType">
+ <xs:restriction base="xs:QName">
+ <xs:enumeration value="tns:InvalidAddressingHeader"/>
+ <xs:enumeration value="tns:InvalidAddress"/>
+ <xs:enumeration value="tns:InvalidEPR"/>
+ <xs:enumeration value="tns:InvalidCardinality"/>
+ <xs:enumeration value="tns:MissingAddressInEPR"/>
+ <xs:enumeration value="tns:DuplicateMessageID"/>
+ <xs:enumeration value="tns:ActionMismatch"/>
+ <xs:enumeration value="tns:MessageAddressingHeaderRequired"/>
+ <xs:enumeration value="tns:DestinationUnreachable"/>
+ <xs:enumeration value="tns:ActionNotSupported"/>
+ <xs:enumeration value="tns:EndpointUnavailable"/>
+ </xs:restriction>
+ </xs:simpleType>
+
+ <xs:element name="RetryAfter" type="tns:AttributedUnsignedLongType"/>
+ <xs:complexType name="AttributedUnsignedLongType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:unsignedLong">
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:element name="ProblemHeaderQName" type="tns:AttributedQNameType"/>
+ <xs:complexType name="AttributedQNameType" mixed="false">
+ <xs:simpleContent>
+ <xs:extension base="xs:QName">
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+
+ <xs:element name="ProblemHeader" type="tns:AttributedAnyType"/>
+ <xs:complexType name="AttributedAnyType" mixed="false">
+ <xs:sequence>
+ <xs:any namespace="##any" processContents="lax" minOccurs="1" maxOccurs="1"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
+ <xs:element name="ProblemIRI" type="tns:AttributedURIType"/>
+
+ <xs:element name="ProblemAction" type="tns:ProblemActionType"/>
+ <xs:complexType name="ProblemActionType" mixed="false">
+ <xs:sequence>
+ <xs:element ref="tns:Action" minOccurs="0"/>
+ <xs:element name="SoapAction" minOccurs="0" type="xs:anyURI"/>
+ </xs:sequence>
+ <xs:anyAttribute namespace="##other" processContents="lax"/>
+ </xs:complexType>
+
</xs:schema>
\ No newline at end of file
diff --git a/modules/core/src/site/site.xml b/modules/core/src/site/site.xml
index aac005c..9c3c10a 100644
--- a/modules/core/src/site/site.xml
+++ b/modules/core/src/site/site.xml
@@ -1,34 +1,34 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<site>
- <bannerLeft>
- <name>Apache XmlSchema</name>
- <src>http://www.apache.org/images/asf-logo.gif</src>
- <href>http://ws.apache.org/</href>
- </bannerLeft>
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/"/>
- <item name="WebServices" href="http://ws.apache.org/"/>
- <!-- <item name="Savan" href="http://ws.apache.org/savan/"/> -->
- </links>
- <menu name="Savan">
- <item name="Home" href="index.html"/>
- <item name="Downloads">
- <item name="Source Code" href="source-repository.html"/>
- </item>
- <item name="Documentation">
- <item name="Tutorial" href="savan-tutorial.html"/>
- <item name="Javadocs" href="/apidocs/index.html"/>
- <item name="View Source"
- href="http://svn.apache.org/viewvc/webservices/savan/?root=Apache-SVN"/>
- </item>
- <item name="Project Information">
- <item name="Mailing Lists" href="/mail-lists.html"/>
- <item name="Project Team" href="/team-list.html"/>
- <item name="Issue Tracking" href="issue-tracking.html"/>
- </item>
- <item name="License" href="/license.html"/>
- </menu>
-
- </body>
+ <bannerLeft>
+ <name>Apache XmlSchema</name>
+ <src>http://www.apache.org/images/asf-logo.gif</src>
+ <href>http://ws.apache.org/</href>
+ </bannerLeft>
+ <body>
+ <links>
+ <item name="Apache" href="http://www.apache.org/"/>
+ <item name="WebServices" href="http://ws.apache.org/"/>
+ <!-- <item name="Savan" href="http://ws.apache.org/savan/"/> -->
+ </links>
+ <menu name="Savan">
+ <item name="Home" href="index.html"/>
+ <item name="Downloads">
+ <item name="Source Code" href="source-repository.html"/>
+ </item>
+ <item name="Documentation">
+ <item name="Tutorial" href="savan-tutorial.html"/>
+ <item name="Javadocs" href="/apidocs/index.html"/>
+ <item name="View Source"
+ href="http://svn.apache.org/viewvc/webservices/savan/?root=Apache-SVN"/>
+ </item>
+ <item name="Project Information">
+ <item name="Mailing Lists" href="/mail-lists.html"/>
+ <item name="Project Team" href="/team-list.html"/>
+ <item name="Issue Tracking" href="issue-tracking.html"/>
+ </item>
+ <item name="License" href="/license.html"/>
+ </menu>
+
+ </body>
</site>
diff --git a/modules/core/src/site/xdoc/savan-tutorial.xml b/modules/core/src/site/xdoc/savan-tutorial.xml
index bf0d9d2..fdec5fa 100644
--- a/modules/core/src/site/xdoc/savan-tutorial.xml
+++ b/modules/core/src/site/xdoc/savan-tutorial.xml
@@ -1,14 +1,13 @@
-
<document>
- <properties>
- <author email="chamikara@wso2.com">Chamikara Jayalath</author>
- <title>Apache Savan Tutorial</title>
- </properties>
- <body>
- <section name="Introduction">
- <p>
- This is the Apache Savan Tutorial
- </p>
- </section>
- </body>
+ <properties>
+ <author email="chamikara@wso2.com">Chamikara Jayalath</author>
+ <title>Apache Savan Tutorial</title>
+ </properties>
+ <body>
+ <section name="Introduction">
+ <p>
+ This is the Apache Savan Tutorial
+ </p>
+ </section>
+ </body>
</document>
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/ConfigurationManagerTest.java b/modules/core/src/test/java/org/apache/axis2/savan/ConfigurationManagerTest.java
index 8531c0c..41eca13 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/ConfigurationManagerTest.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/ConfigurationManagerTest.java
@@ -16,29 +16,29 @@
package org.apache.axis2.savan;
-import java.io.File;
-
+import junit.framework.TestCase;
import org.apache.savan.SavanException;
import org.apache.savan.configuration.ConfigurationManager;
-import junit.framework.TestCase;
+import java.io.File;
public class ConfigurationManagerTest extends TestCase {
- public void testFromXMLFile () throws SavanException {
-
+ public void testFromXMLFile() throws SavanException {
+
File baseDir = new File("");
-
- String testRource = baseDir.getAbsolutePath() + File.separator + "src" + File.separator + "test" + File.separator + "resources";
+
+ String testRource = baseDir.getAbsolutePath() + File.separator + "src" + File.separator +
+ "test" + File.separator + "resources";
String testConfigurationFile = testRource + File.separator + "savan-config-test.xml";
-
- File f = new File (testConfigurationFile); //test-resources configuration file.
- if (!f.isFile())
- throw new SavanException ("Cant find the test configuration file");
-
- ConfigurationManager cm = new ConfigurationManager ();
- cm.configure(f);
-
-
- }
+
+ File f = new File(testConfigurationFile); //test-resources configuration file.
+ if (!f.isFile())
+ throw new SavanException("Cant find the test configuration file");
+
+ ConfigurationManager cm = new ConfigurationManager();
+ cm.configure(f);
+
+
+ }
}
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/EventingExpirationTypesTest.java b/modules/core/src/test/java/org/apache/axis2/savan/EventingExpirationTypesTest.java
index 7c1b019..13daa57 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/EventingExpirationTypesTest.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/EventingExpirationTypesTest.java
@@ -16,12 +16,7 @@
package org.apache.axis2.savan;
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import javax.xml.namespace.QName;
import junit.framework.TestCase;
-
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.addressing.EndpointReference;
@@ -34,49 +29,56 @@
import org.apache.savan.subscription.ExpirationBean;
import org.apache.savan.util.CommonUtil;
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+
public class EventingExpirationTypesTest extends TestCase {
- public void testDuration () throws Exception {
- SavanMessageContext renewMessage = getRenewMessage("eventing-renew-duration.xml");
- EventingSubscriptionProcessor processor = new EventingSubscriptionProcessor ();
- ExpirationBean expirationBean = processor.getExpirationBean(renewMessage);
- assertTrue(expirationBean.isDuration());
-
- Duration duration = ConverterUtil.convertToDuration("P1Y2M3DT10H30M");
- assertEquals(duration,expirationBean.getDurationValue());
- assertEquals (expirationBean.getSubscriberID(),"UUID:DummySubscriberID");
- }
-
- public void testDateTime () throws Exception {
- SavanMessageContext renewMessage = getRenewMessage("eventing-renew-datetime.xml");
- EventingSubscriptionProcessor processor = new EventingSubscriptionProcessor ();
- ExpirationBean expirationBean = processor.getExpirationBean(renewMessage);
- assertFalse(expirationBean.isDuration());
-
- Date date = ConverterUtil.convertToDateTime("2004-06-26T21:07:00.000-08:00").getTime();
- assertEquals(expirationBean.getDateValue(),date);
- assertEquals (expirationBean.getSubscriberID(),"UUID:DummySubscriberID");
- }
-
- private SavanMessageContext getRenewMessage (String name) throws IOException {
+ public void testDuration() throws Exception {
+ SavanMessageContext renewMessage = getRenewMessage("eventing-renew-duration.xml");
+ EventingSubscriptionProcessor processor = new EventingSubscriptionProcessor();
+ ExpirationBean expirationBean = processor.getExpirationBean(renewMessage);
+ assertTrue(expirationBean.isDuration());
+
+ Duration duration = ConverterUtil.convertToDuration("P1Y2M3DT10H30M");
+ assertEquals(duration, expirationBean.getDurationValue());
+ assertEquals(expirationBean.getSubscriberID(), "UUID:DummySubscriberID");
+ }
+
+ public void testDateTime() throws Exception {
+ SavanMessageContext renewMessage = getRenewMessage("eventing-renew-datetime.xml");
+ EventingSubscriptionProcessor processor = new EventingSubscriptionProcessor();
+ ExpirationBean expirationBean = processor.getExpirationBean(renewMessage);
+ assertFalse(expirationBean.isDuration());
+
+ Date date = ConverterUtil.convertToDateTime("2004-06-26T21:07:00.000-08:00").getTime();
+ assertEquals(expirationBean.getDateValue(), date);
+ assertEquals(expirationBean.getSubscriberID(), "UUID:DummySubscriberID");
+ }
+
+ private SavanMessageContext getRenewMessage(String name) throws IOException {
File baseDir = new File("");
- String testRource = baseDir.getAbsolutePath() + File.separator + "src" + File.separator + "test" + File.separator + "resources";
-
- SOAPEnvelope envelope = CommonUtil.getTestEnvelopeFromFile(testRource,name, OMAbstractFactory.getSOAP12Factory());
-
- MessageContext mc = new MessageContext ();
- SavanMessageContext smc = new SavanMessageContext (mc);
- mc.setEnvelope(envelope);
-
- Options options = new Options ();
- options.setTo(new EndpointReference ("http://DummyToAddress/"));
-
- EndpointReference replyToEPR = new EndpointReference ("http://DummyReplyToAddress/");
- replyToEPR.addReferenceParameter(new QName ("RefParam1"),"RefParamVal1");
- options.setTo(replyToEPR);
-
- options.setAction("urn:uuid:DummyAction");
-
- return smc;
- }
+ String testRource = baseDir.getAbsolutePath() + File.separator + "src" + File.separator +
+ "test" + File.separator + "resources";
+
+ SOAPEnvelope envelope = CommonUtil
+ .getTestEnvelopeFromFile(testRource, name, OMAbstractFactory.getSOAP12Factory());
+
+ MessageContext mc = new MessageContext();
+ SavanMessageContext smc = new SavanMessageContext(mc);
+ mc.setEnvelope(envelope);
+
+ Options options = new Options();
+ options.setTo(new EndpointReference("http://DummyToAddress/"));
+
+ EndpointReference replyToEPR = new EndpointReference("http://DummyReplyToAddress/");
+ replyToEPR.addReferenceParameter(new QName("RefParam1"), "RefParamVal1");
+ options.setTo(replyToEPR);
+
+ options.setAction("urn:uuid:DummyAction");
+
+ return smc;
+ }
}
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java b/modules/core/src/test/java/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java
index 3b5164d..a66f0c1 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java
@@ -16,6 +16,7 @@
package org.apache.axis2.savan;
+import junit.framework.TestCase;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.addressing.EndpointReference;
@@ -38,125 +39,133 @@
import org.apache.savan.util.CommonUtil;
import javax.xml.namespace.QName;
-
import java.io.File;
import java.io.IOException;
import java.util.Date;
-import junit.framework.TestCase;
-
public class EventingSubscripitonProcessorTest extends TestCase {
- private final String TEST_SAVAN_CONFIG = "savan-config-test.xml";
- private final String EVENTING_PROTOCOL_NAME = "eventing";
-
- public void testSubscriberExtraction () throws Exception {
- SavanMessageContext smc = getSubscriptionMessage();
-
+ private final String TEST_SAVAN_CONFIG = "savan-config-test.xml";
+ private final String EVENTING_PROTOCOL_NAME = "eventing";
+
+ public void testSubscriberExtraction() throws Exception {
+ SavanMessageContext smc = getSubscriptionMessage();
+
// Protocol protocol = new Protocol ();
// protocol.setName("eventing");
// protocol.setUtilFactory(new EventingUtilFactory ());
// protocol.setDefaultSubscriber("org.apache.savan.eventing.subscribers.EventingLeafSubscriber");
-
- SubscriberStore store = new DefaultSubscriberStore ();
-
+
+ SubscriberStore store = new DefaultSubscriberStore();
+
// smc.setProtocol(protocol);
-
- smc.setSubscriberStore(store);
-
- EventingSubscriptionProcessor esp = new EventingSubscriptionProcessor ();
- EventingSubscriber eventingSubscriber = (EventingSubscriber) esp.getSubscriberFromMessage(smc);
- assertNotNull(eventingSubscriber);
-
- assertNotNull(eventingSubscriber.getDelivery());
- assertNotNull(eventingSubscriber.getDelivery().getDeliveryEPR());
- assertNotNull(eventingSubscriber.getFilter());
- assertNotNull(eventingSubscriber.getEndToEPr());
- assertNotNull(eventingSubscriber.getId());
- assertNotNull(eventingSubscriber.getSubscriptionEndingTime());
-
- assertEquals(eventingSubscriber.getDelivery().getDeliveryMode(),EventingConstants.DEFAULT_DELIVERY_MODE);
-
- assertEquals(eventingSubscriber.getDelivery().getDeliveryEPR().getAddress() ,"http://www.other.example.com/OnStormWarning");
- assertEquals(eventingSubscriber.getEndToEPr().getAddress(),"http://www.example.com/MyEventSink");
- Date date = ConverterUtil.convertToDateTime("2004-06-26T21:07:00.000-08:00").getTime();
- assertEquals(eventingSubscriber.getSubscriptionEndingTime(),date);
- }
-
- public void testExpirationBeanExtraction () throws Exception {
- SavanMessageContext smc = getRenewMessage();
- EventingSubscriptionProcessor esp = new EventingSubscriptionProcessor ();
- ExpirationBean expirationBean = esp.getExpirationBean(smc);
-
- assertNotNull(expirationBean);
- assertNotNull(expirationBean.getSubscriberID());
-
- Date date = ConverterUtil.convertToDateTime("2004-06-26T21:07:00.000-08:00").getTime();
- assertEquals(expirationBean.getDateValue(),date);
- }
-
- private SavanMessageContext getSubscriptionMessage () throws IOException {
- File baseDir = new File("");
- String testRource = baseDir.getAbsolutePath() + File.separator + "src" + File.separator + "test" + File.separator + "resources";
- SOAPEnvelope envelope = CommonUtil.getTestEnvelopeFromFile(testRource,"eventing-subscription.xml", OMAbstractFactory.getSOAP12Factory());
-
- AxisConfiguration axisConfiguration = new AxisConfiguration ();
- ConfigurationContext configurationContext = new ConfigurationContext (axisConfiguration);
-
- MessageContext mc = new MessageContext ();
- SavanMessageContext smc = new SavanMessageContext (mc);
- mc.setEnvelope(envelope);
-
- mc.setConfigurationContext(configurationContext);
-
- Options options = new Options ();
- options.setTo(new EndpointReference ("http://DummyToAddress/"));
-
- EndpointReference replyToEPR = new EndpointReference ("http://DummyReplyToAddress/");
- replyToEPR.addReferenceParameter(new QName ("RefParam1"),"RefParamVal1");
- options.setTo(replyToEPR);
-
- //adding a dummy AxisService to avoid NullPointer Exceptions.
- mc.setAxisService(new AxisService ("DummyService"));
-
- options.setAction("urn:uuid:DummyAction");
-
- String savan_concig_file = testRource + File.separator + TEST_SAVAN_CONFIG;
- File file = new File (savan_concig_file);
- if (!file.exists())
- throw new IOException (TEST_SAVAN_CONFIG + " file is not available in test-resources.");
-
- ConfigurationManager configurationManager = new ConfigurationManager ();
- configurationManager.configure(file);
-
- configurationContext.setProperty(SavanConstants.CONFIGURATION_MANAGER,configurationManager);
-
- Protocol protocol = configurationManager.getProtocol(EVENTING_PROTOCOL_NAME);
- smc.setProtocol(protocol);
-
- return smc;
- }
-
- private SavanMessageContext getRenewMessage () throws IOException {
- File baseDir = new File("");
- String testRource = baseDir.getAbsolutePath() + File.separator + "src" + File.separator + "test" + File.separator + "resources";
+ smc.setSubscriberStore(store);
- SOAPEnvelope envelope = CommonUtil.getTestEnvelopeFromFile(testRource,"eventing-renew-datetime.xml", OMAbstractFactory.getSOAP12Factory());
-
- MessageContext mc = new MessageContext ();
- SavanMessageContext smc = new SavanMessageContext (mc);
- mc.setEnvelope(envelope);
-
- Options options = new Options ();
- options.setTo(new EndpointReference ("http://DummyToAddress/"));
-
- EndpointReference replyToEPR = new EndpointReference ("http://DummyReplyToAddress/");
- replyToEPR.addReferenceParameter(new QName ("RefParam1"),"RefParamVal1");
- options.setTo(replyToEPR);
-
- options.setAction("urn:uuid:DummyAction");
-
- return smc;
- }
+ EventingSubscriptionProcessor esp = new EventingSubscriptionProcessor();
+ EventingSubscriber eventingSubscriber =
+ (EventingSubscriber)esp.getSubscriberFromMessage(smc);
+ assertNotNull(eventingSubscriber);
+
+ assertNotNull(eventingSubscriber.getDelivery());
+ assertNotNull(eventingSubscriber.getDelivery().getDeliveryEPR());
+ assertNotNull(eventingSubscriber.getFilter());
+ assertNotNull(eventingSubscriber.getEndToEPr());
+ assertNotNull(eventingSubscriber.getId());
+ assertNotNull(eventingSubscriber.getSubscriptionEndingTime());
+
+ assertEquals(eventingSubscriber.getDelivery().getDeliveryMode(),
+ EventingConstants.DEFAULT_DELIVERY_MODE);
+
+ assertEquals(eventingSubscriber.getDelivery().getDeliveryEPR().getAddress(),
+ "http://www.other.example.com/OnStormWarning");
+ assertEquals(eventingSubscriber.getEndToEPr().getAddress(),
+ "http://www.example.com/MyEventSink");
+ Date date = ConverterUtil.convertToDateTime("2004-06-26T21:07:00.000-08:00").getTime();
+ assertEquals(eventingSubscriber.getSubscriptionEndingTime(), date);
+ }
+
+ public void testExpirationBeanExtraction() throws Exception {
+ SavanMessageContext smc = getRenewMessage();
+ EventingSubscriptionProcessor esp = new EventingSubscriptionProcessor();
+ ExpirationBean expirationBean = esp.getExpirationBean(smc);
+
+ assertNotNull(expirationBean);
+ assertNotNull(expirationBean.getSubscriberID());
+
+ Date date = ConverterUtil.convertToDateTime("2004-06-26T21:07:00.000-08:00").getTime();
+ assertEquals(expirationBean.getDateValue(), date);
+ }
+
+ private SavanMessageContext getSubscriptionMessage() throws IOException {
+ File baseDir = new File("");
+ String testRource = baseDir.getAbsolutePath() + File.separator + "src" + File.separator +
+ "test" + File.separator + "resources";
+
+ SOAPEnvelope envelope = CommonUtil.getTestEnvelopeFromFile(testRource,
+ "eventing-subscription.xml",
+ OMAbstractFactory.getSOAP12Factory());
+
+ AxisConfiguration axisConfiguration = new AxisConfiguration();
+ ConfigurationContext configurationContext = new ConfigurationContext(axisConfiguration);
+
+ MessageContext mc = new MessageContext();
+ SavanMessageContext smc = new SavanMessageContext(mc);
+ mc.setEnvelope(envelope);
+
+ mc.setConfigurationContext(configurationContext);
+
+ Options options = new Options();
+ options.setTo(new EndpointReference("http://DummyToAddress/"));
+
+ EndpointReference replyToEPR = new EndpointReference("http://DummyReplyToAddress/");
+ replyToEPR.addReferenceParameter(new QName("RefParam1"), "RefParamVal1");
+ options.setTo(replyToEPR);
+
+ //adding a dummy AxisService to avoid NullPointer Exceptions.
+ mc.setAxisService(new AxisService("DummyService"));
+
+ options.setAction("urn:uuid:DummyAction");
+
+ String savan_concig_file = testRource + File.separator + TEST_SAVAN_CONFIG;
+ File file = new File(savan_concig_file);
+ if (!file.exists())
+ throw new IOException(TEST_SAVAN_CONFIG + " file is not available in test-resources.");
+
+ ConfigurationManager configurationManager = new ConfigurationManager();
+ configurationManager.configure(file);
+
+ configurationContext
+ .setProperty(SavanConstants.CONFIGURATION_MANAGER, configurationManager);
+
+ Protocol protocol = configurationManager.getProtocol(EVENTING_PROTOCOL_NAME);
+ smc.setProtocol(protocol);
+
+ return smc;
+ }
+
+ private SavanMessageContext getRenewMessage() throws IOException {
+ File baseDir = new File("");
+ String testRource = baseDir.getAbsolutePath() + File.separator + "src" + File.separator +
+ "test" + File.separator + "resources";
+
+ SOAPEnvelope envelope = CommonUtil.getTestEnvelopeFromFile(testRource,
+ "eventing-renew-datetime.xml",
+ OMAbstractFactory.getSOAP12Factory());
+
+ MessageContext mc = new MessageContext();
+ SavanMessageContext smc = new SavanMessageContext(mc);
+ mc.setEnvelope(envelope);
+
+ Options options = new Options();
+ options.setTo(new EndpointReference("http://DummyToAddress/"));
+
+ EndpointReference replyToEPR = new EndpointReference("http://DummyReplyToAddress/");
+ replyToEPR.addReferenceParameter(new QName("RefParam1"), "RefParamVal1");
+ options.setTo(replyToEPR);
+
+ options.setAction("urn:uuid:DummyAction");
+
+ return smc;
+ }
}
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/XPathBasedFilterTest.java b/modules/core/src/test/java/org/apache/axis2/savan/XPathBasedFilterTest.java
index 8a2b6c6..65e3dea 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/XPathBasedFilterTest.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/XPathBasedFilterTest.java
@@ -18,7 +18,6 @@
package org.apache.axis2.savan;
import junit.framework.TestCase;
-
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNode;
@@ -31,39 +30,39 @@
public class XPathBasedFilterTest extends TestCase {
- String filterString = "//elem1";
-
- public void testMessageFiltering () throws AxisFault {
- SOAPEnvelope envelope = createTestEnvelope ();
-
- OMNode filterNode = getFilterElement ();
- Filter filter = new XPathBasedFilter ();
- filter.setUp(filterNode);
-
- assertTrue (filter.checkCompliance(envelope));
- }
-
- private SOAPEnvelope createTestEnvelope () {
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
-
- OMElement elem1 = factory.createOMElement("elem1",null);
- OMElement elem2 = factory.createOMElement("elem2",null);
- OMElement elem3 = factory.createOMElement("elem3",null);
+ String filterString = "//elem1";
- elem2.addChild(elem3);
- elem1.addChild(elem2);
-
- envelope.getBody().addChild(elem1);
- factory.createOMDocument().addChild(envelope);
-
- return envelope;
- }
-
- private OMNode getFilterElement () {
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- OMText text = factory.createOMText(filterString);
- return text;
- }
-
+ public void testMessageFiltering() throws AxisFault {
+ SOAPEnvelope envelope = createTestEnvelope();
+
+ OMNode filterNode = getFilterElement();
+ Filter filter = new XPathBasedFilter();
+ filter.setUp(filterNode);
+
+ assertTrue(filter.checkCompliance(envelope));
+ }
+
+ private SOAPEnvelope createTestEnvelope() {
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+
+ OMElement elem1 = factory.createOMElement("elem1", null);
+ OMElement elem2 = factory.createOMElement("elem2", null);
+ OMElement elem3 = factory.createOMElement("elem3", null);
+
+ elem2.addChild(elem3);
+ elem1.addChild(elem2);
+
+ envelope.getBody().addChild(elem1);
+ factory.createOMDocument().addChild(envelope);
+
+ return envelope;
+ }
+
+ private OMNode getFilterElement() {
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ OMText text = factory.createOMText(filterString);
+ return text;
+ }
+
}
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomSample.java b/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomSample.java
index 5c1d2b6..46091c8 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomSample.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomSample.java
@@ -1,71 +1,69 @@
package org.apache.axis2.savan.atom;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMOutputFormat;
-import org.apache.savan.atom.AtomEventingClient;
-
import com.wso2.eventing.atom.CreateFeedResponseDocument.CreateFeedResponse;
+import org.apache.axiom.om.*;
+import org.apache.savan.atom.AtomEventingClient;
public class AtomSample {
-
- /**
- * To run the sample
- * <ol>
- * <li>Install Axis2 with addressing Module</li>
- * <li>Install some service, engage Savan with that service</li>
- * <li>Set up Axis2 client repository in client machine with addressing module</li>
- * <li>Run the sample with http://serviceHost:servicePort/services/<Service-Name>
- * and <client-repostiory-location></li>
- * </ol>
- *
- * Samples shows how to Create,Delete, publish to with SOAP/REST, and retrive a Feed.
- * @param args
- */
-
- public static void main(String[] args){
- if(args.length != 2){
- System.out.println("Usage: serviceUrl clientRepository");
- }else{
-
- try {
- String serviceUrl = args[0];
- AtomEventingClient atomEventingClient = new AtomEventingClient(serviceUrl,args[1]);
- CreateFeedResponse createFeedResponse = atomEventingClient.createFeed("test Title","Srinath Perera");
- System.out.println("Created Feed "+createFeedResponse.getFeedUrl() + " Sucessfully");
-
- //publish to service using SOAP
- atomEventingClient.publishWithSOAP(serviceUrl, getDummyMethodRequestElement (1), null);
-
- //publish service using REST
- atomEventingClient.publishWithREST(serviceUrl, getDummyMethodRequestElement (2), null);
- //Get the feed using http GET
- OMElement feedAsXml = atomEventingClient.fetchFeed(createFeedResponse.getFeedUrl());
- feedAsXml.serialize(System.out,new OMOutputFormat());
-
- System.out.println("Fetch Feed using HTTP Get, copy and paste url " + createFeedResponse.getFeedUrl() + " in browser to retirve the feed ");
- System.out.println("Press any key to delete the feed");
- System.in.read();
- atomEventingClient.deleteFeed();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- private static final String applicationNamespaceName = "http://tempuri.org/";
- private static final String dummyMethod = "dummyMethod";
-
- private static OMElement getDummyMethodRequestElement(int i) {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
- OMElement de = fac.createOMElement(dummyMethod, namespace);
- de.setText(String.valueOf(i));
+ /**
+ * To run the sample <ol> <li>Install Axis2 with addressing Module</li> <li>Install some service,
+ * engage Savan with that service</li> <li>Set up Axis2 client repository in client machine with
+ * addressing module</li> <li>Run the sample with http://serviceHost:servicePort/services/<Service-Name>
+ * and <client-repostiory-location></li> </ol>
+ * <p/>
+ * Samples shows how to Create,Delete, publish to with SOAP/REST, and retrive a Feed.
+ *
+ * @param args
+ */
+
+ public static void main(String[] args) {
+ if (args.length != 2) {
+ System.out.println("Usage: serviceUrl clientRepository");
+ } else {
+
+ try {
+ String serviceUrl = args[0];
+ AtomEventingClient atomEventingClient = new AtomEventingClient(serviceUrl, args[1]);
+ CreateFeedResponse createFeedResponse =
+ atomEventingClient.createFeed("test Title", "Srinath Perera");
+ System.out.println(
+ "Created Feed " + createFeedResponse.getFeedUrl() + " Sucessfully");
+
+ //publish to service using SOAP
+ atomEventingClient
+ .publishWithSOAP(serviceUrl, getDummyMethodRequestElement(1), null);
+
+ //publish service using REST
+ atomEventingClient
+ .publishWithREST(serviceUrl, getDummyMethodRequestElement(2), null);
+
+ //Get the feed using http GET
+ OMElement feedAsXml = atomEventingClient.fetchFeed(createFeedResponse.getFeedUrl());
+ feedAsXml.serialize(System.out, new OMOutputFormat());
+
+ System.out.println("Fetch Feed using HTTP Get, copy and paste url " +
+ createFeedResponse.getFeedUrl() +
+ " in browser to retirve the feed ");
+ System.out.println("Press any key to delete the feed");
+ System.in.read();
+ atomEventingClient.deleteFeed();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static final String applicationNamespaceName = "http://tempuri.org/";
+ private static final String dummyMethod = "dummyMethod";
+
+ private static OMElement getDummyMethodRequestElement(int i) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName, "ns1");
+ OMElement de = fac.createOMElement(dummyMethod, namespace);
+ de.setText(String.valueOf(i));
return de;
}
}
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomTest.java b/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomTest.java
index 11ab4a9..232be42 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomTest.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/atom/AtomTest.java
@@ -18,16 +18,8 @@
//todo
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.OMOutputFormat;
+import com.wso2.eventing.atom.CreateFeedResponseDocument.CreateFeedResponse;
+import org.apache.axiom.om.*;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
@@ -42,35 +34,37 @@
import org.apache.savan.atom.AtomEventingClient;
import org.apache.savan.eventing.client.EventingClient;
-import com.wso2.eventing.atom.CreateFeedResponseDocument.CreateFeedResponse;
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.io.InputStream;
-public class AtomTest extends UtilServerBasedTestCase {
+public class AtomTest extends UtilServerBasedTestCase {
- private static final Log log = LogFactory.getLog(AtomTest.class);
+ private static final Log log = LogFactory.getLog(AtomTest.class);
protected QName transportName = new QName("http://localhost/my",
- "NullTransport");
+ "NullTransport");
private final int MIN_OPTION = 1;
private final int MAX_OPTION = 9;
-
+
private final String SUBSCRIBER_1_ID = "subscriber1";
private final String SUBSCRIBER_2_ID = "subscriber2";
-
+
private final String AXIS2_REPO = "target/repository/";
-
+
private ServiceClient serviceClient = null;
private Options options = null;
private EventingClient eventingClient = null;
-
+
private String toAddressPart = "/axis2/services/PublisherService";
- private String listner1AddressPart = "/axis2/services/ListnerService1";
- private String listner2AddressPart = "/axis2/services/ListnerService2";
-
- private final String applicationNamespaceName = "http://tempuri.org/";
- private final String dummyMethod = "dummyMethod";
-
- private static String repo = null;
- private static int port = 5556;
- private static String serverIP = "127.0.0.1";
+ private String listener1AddressPart = "/axis2/services/ListenerService1";
+ private String listener2AddressPart = "/axis2/services/ListenerService2";
+
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String dummyMethod = "dummyMethod";
+
+ private static String repo = null;
+ private static int port = 5556;
+ private static String serverIP = "127.0.0.1";
protected AxisConfiguration engineRegistry;
protected MessageContext mc;
@@ -88,22 +82,21 @@
super(testName);
}
-
protected void setUp() throws Exception {
- UtilServer.start(AXIS2_REPO);
+ UtilServer.start(AXIS2_REPO);
// service = Utils.createSimpleService(serviceName,
// PublisherService.class.getName(),
// new QName("dummyMethod"));
// service.addModuleref("savan");
//
// UtilServer.deployService(service);
-
-// AxisService service1 = Utils.createSimpleService(new QName("ListnerService1"),
+
+// AxisService service1 = Utils.createSimpleService(new QName("ListenerService1"),
// SavenTest.class.getName(),
// new QName("publish"));
// UtilServer.deployService(service1);
-
+
}
protected void tearDown() throws Exception {
@@ -112,73 +105,73 @@
}
- public void testAtomSubcription()throws Exception{
- //Thread.sleep(1000*60*100);
- ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_REPO,AXIS2_REPO+"/conf/axis2.xml");
- serviceClient = new ServiceClient (configContext,null); //TODO give a repo
-
- options = new Options ();
- serviceClient.setOptions(options);
- serviceClient.engageModule(new QName ("addressing"));
-
- eventingClient = new EventingClient (serviceClient);
-
- String toAddress = "http://" + serverIP + ":" + port + toAddressPart;
-
- //String toAddress = "http://" + serverIP + ":" + port + "/axis2/services/RMSampleService";
- options.setTo(new EndpointReference (toAddress));
-
-
- AtomEventingClient atomEventingClient = new AtomEventingClient(serviceClient);
- CreateFeedResponse createFeedResponse = atomEventingClient.createFeed("test Title","Srinath Perera");
-
- options.setAction("http://wso2.com/eventing/dummyMethod");
- serviceClient.fireAndForget(getDummyMethodRequestElement (0));
-
+ public void testAtomSubcription() throws Exception {
+ //Thread.sleep(1000*60*100);
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(AXIS2_REPO,
+ AXIS2_REPO + "/conf/axis2.xml");
+ serviceClient = new ServiceClient(configContext, null); //TODO give a repo
+
+ options = new Options();
+ serviceClient.setOptions(options);
+ serviceClient.engageModule(new QName("addressing"));
+
+ eventingClient = new EventingClient(serviceClient);
+
+ String toAddress = "http://" + serverIP + ":" + port + toAddressPart;
+
+ //String toAddress = "http://" + serverIP + ":" + port + "/axis2/services/RMSampleService";
+ options.setTo(new EndpointReference(toAddress));
+
+
+ AtomEventingClient atomEventingClient = new AtomEventingClient(serviceClient);
+ CreateFeedResponse createFeedResponse =
+ atomEventingClient.createFeed("test Title", "Srinath Perera");
+
+ options.setAction("http://wso2.com/eventing/dummyMethod");
+ serviceClient.fireAndForget(getDummyMethodRequestElement(0));
+
// options.setAction(EventingConstants.Actions.Publish);
// serviceClient.fireAndForget(getDummyMethodRequestElement ());
-
- atomEventingClient.publishWithSOAP(toAddress, getDummyMethodRequestElement (1), null);
- atomEventingClient.publishWithREST(toAddress, getDummyMethodRequestElement (2), null);
- //Thread.sleep(1000*10*1000);
-
+
+ atomEventingClient.publishWithSOAP(toAddress, getDummyMethodRequestElement(1), null);
+ atomEventingClient.publishWithREST(toAddress, getDummyMethodRequestElement(2), null);
+ //Thread.sleep(1000*10*1000);
+
// int i = 0;
// while(i<1){
- System.out.println(createFeedResponse.getFeedUrl());
- OMElement feedAsXml = atomEventingClient.fetchFeed(createFeedResponse.getFeedUrl());
- feedAsXml.serialize(System.out,new OMOutputFormat());
-
+ System.out.println(createFeedResponse.getFeedUrl());
+ OMElement feedAsXml = atomEventingClient.fetchFeed(createFeedResponse.getFeedUrl());
+ feedAsXml.serialize(System.out, new OMOutputFormat());
+
// URL url = new URL(createFeedResponse.getFeedUrl());
// System.out.println(readFromStream(url.openStream()));
// Thread.sleep(1000*10);
// i++;
// }
//
- feedAsXml = atomEventingClient.fetchFeed(createFeedResponse.getFeedUrl());
- feedAsXml.serialize(System.out,new OMOutputFormat());
-
-
- atomEventingClient.deleteFeed();
-
-
+ feedAsXml = atomEventingClient.fetchFeed(createFeedResponse.getFeedUrl());
+ feedAsXml.serialize(System.out, new OMOutputFormat());
+
+
+ atomEventingClient.deleteFeed();
+
+
}
-
-
-
+
// public void testEvents() throws Exception{
// initClient ();
// performAction (1);
// }
-
-
+
+
public void publish(OMElement param) throws Exception {
- System.out.println("\n");
- System.out.println("'1' got a new publication...");
- System.out.println(param);
- System.out.println("\n");
- }
-
-
+ System.out.println("\n");
+ System.out.println("'1' got a new publication...");
+ System.out.println(param);
+ System.out.println("\n");
+ }
+
// private void initClient () throws AxisFault {
//
//// String CLIENT_REPO = null;
@@ -242,15 +235,15 @@
// break;
// }
// }
-
+
// private void doSubscribe (String ID) throws Exception {
// EventingClientBean bean = new EventingClientBean ();
//
// String subscribingAddress = null;
// if (SUBSCRIBER_1_ID.equals(ID)) {
-// subscribingAddress = "http://" + serverIP + ":" + port + listner1AddressPart;
+// subscribingAddress = "http://" + serverIP + ":" + port + listener1AddressPart;
// } else if (SUBSCRIBER_2_ID.equals(ID)) {
-// subscribingAddress = "http://" + serverIP + ":" + port + listner2AddressPart;
+// subscribingAddress = "http://" + serverIP + ":" + port + listener2AddressPart;
// }
//
// bean.setDeliveryEPR(new EndpointReference (subscribingAddress));
@@ -276,30 +269,30 @@
// String statusValue = status.getExpirationValue();
// System.out.println("Status of the subscriber '" + ID +"' is" + statusValue);
// }
-
- private OMElement getDummyMethodRequestElement(int i) {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
- OMElement de = fac.createOMElement(dummyMethod, namespace);
- de.setText(String.valueOf(i));
- return de;
- }
-
- public static String readFromStream(InputStream in) throws Exception{
- try {
- StringBuffer wsdlStr = new StringBuffer();
-
- int read;
-
- byte[] buf = new byte[1024];
- while((read = in.read(buf)) > 0){
- wsdlStr.append(new String(buf,0,read));
- }
- in.close();
- return wsdlStr.toString();
- } catch (IOException e) {
- throw new Exception(e);
- }
+
+ private OMElement getDummyMethodRequestElement(int i) {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName, "ns1");
+ OMElement de = fac.createOMElement(dummyMethod, namespace);
+ de.setText(String.valueOf(i));
+ return de;
+ }
+
+ public static String readFromStream(InputStream in) throws Exception {
+ try {
+ StringBuffer wsdlStr = new StringBuffer();
+
+ int read;
+
+ byte[] buf = new byte[1024];
+ while ((read = in.read(buf)) > 0) {
+ wsdlStr.append(new String(buf, 0, read));
+ }
+ in.close();
+ return wsdlStr.toString();
+ } catch (IOException e) {
+ throw new Exception(e);
+ }
}
}
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/atom/DerbyTest.java b/modules/core/src/test/java/org/apache/axis2/savan/atom/DerbyTest.java
index e24a658..83b789f 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/atom/DerbyTest.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/atom/DerbyTest.java
@@ -1,48 +1,39 @@
package org.apache.axis2.savan.atom;
-import java.io.StringWriter;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Random;
-
+import junit.framework.TestCase;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
-import org.apache.savan.SavanException;
import org.apache.savan.atom.AtomDataSource;
-import junit.framework.TestCase;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Random;
-public class DerbyTest extends TestCase{
-
- /* the default framework is embedded*/
- public String framework = "embedded";
- public String driver = "org.apache.derby.jdbc.EmbeddedDriver";
- public String protocol = "jdbc:derby:";
-
- public void testDataSource() throws Exception{
- AtomDataSource dataSource = new AtomDataSource();
- String id = "id"+new Random().nextDouble();
- dataSource.addFeed(id, "foo", new Date(),"Srinath");
- dataSource.addEntry(id,getDummyMethodRequestElement());
- StringWriter w = new StringWriter();
-
- OMElement result = dataSource.getFeedAsXml(id);
+public class DerbyTest extends TestCase {
+
+ /* the default framework is embedded*/
+ public String framework = "embedded";
+ public String driver = "org.apache.derby.jdbc.EmbeddedDriver";
+ public String protocol = "jdbc:derby:";
+
+ public void testDataSource() throws Exception {
+ AtomDataSource dataSource = new AtomDataSource();
+ String id = "id" + new Random().nextDouble();
+ dataSource.addFeed(id, "foo", new Date(), "Srinath");
+ dataSource.addEntry(id, getDummyMethodRequestElement());
+ StringWriter w = new StringWriter();
+
+ OMElement result = dataSource.getFeedAsXml(id);
// Iterator it = result.getChildElements();
// while(it.hasNext()){
// System.out.println(it.next());
// }
-
- result.serialize(w);
- System.out.println(w.getBuffer().toString());
- }
+
+ result.serialize(w);
+ System.out.println(w.getBuffer().toString());
+ }
// public static void main(String[] args)
// {
@@ -235,12 +226,13 @@
// protocol = "jdbc:derby://localhost:1527/";
// }
// }
-// }
- private final String applicationNamespaceName = "http://tempuri.org/";
- private final String dummyMethod = "dummyMethod";
- private OMElement getDummyMethodRequestElement() {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
- return fac.createOMElement(dummyMethod, namespace);
- }
- }
+ // }
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String dummyMethod = "dummyMethod";
+
+ private OMElement getDummyMethodRequestElement() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName, "ns1");
+ return fac.createOMElement(dummyMethod, namespace);
+ }
+}
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java b/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java
index 2bea86c..5672a89 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/atom/PublisherService.java
@@ -16,9 +16,6 @@
package org.apache.axis2.savan.atom;
-import java.net.URI;
-import java.util.Random;
-
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
@@ -29,72 +26,75 @@
import org.apache.savan.storage.SubscriberStore;
import org.apache.savan.util.CommonUtil;
+import java.util.Random;
+
public class PublisherService {
-
- ServiceContext serviceContext = null;
- private String eventName = "testTopic";
-
- public void init(ServiceContext serviceContext) throws AxisFault {
- try {
- System.out.println("Eventing Service INIT called");
- this.serviceContext = serviceContext;
-
- PublisherThread thread = new PublisherThread ();
- thread.start();
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- throw AxisFault.makeFault(e);
- }
- }
-
- public void dummyMethod(OMElement param) throws Exception {
- System.out.println("Eventing Service dummy method called");
- }
-
- private class PublisherThread extends Thread {
-
- String Publication = "Publication";
- String publicationNamespaceValue = "http://tempuri/publication/";
- Random r = new Random ();
-
- public void run () {
- try {
- while (true) {
-
-
-
- //publishing
- System.out.println("Publishing next publication...");
-
- SubscriberStore store = CommonUtil.getSubscriberStore(serviceContext.getAxisService());
- if (store==null)
- throw new Exception ("Cant find the Savan subscriber store");
-
- OMElement envelope = getNextPublicationEvent ();
- PublicationClient client = new PublicationClient(serviceContext.getConfigurationContext());
- client.sendPublication(envelope,serviceContext.getAxisService(),null);
- Thread.sleep(10000);
- }
-
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- private int eventID = 0;
-
- public OMElement getNextPublicationEvent () {
- SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
- OMNamespace namespace = factory.createOMNamespace(publicationNamespaceValue,"ns1");
- OMElement publicationElement = factory.createOMElement(Publication,namespace);
-
- factory.createOMElement("foo",namespace,publicationElement).setText("Event "+eventID);
-
- OMElement publishMethod = factory.createOMElement("publish",namespace);
- publishMethod.addChild(publicationElement);
-
- return publishMethod;
- }
- }
+
+ ServiceContext serviceContext = null;
+ private String eventName = "testTopic";
+
+ public void init(ServiceContext serviceContext) throws AxisFault {
+ try {
+ System.out.println("Eventing Service INIT called");
+ this.serviceContext = serviceContext;
+
+ PublisherThread thread = new PublisherThread();
+ thread.start();
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ throw AxisFault.makeFault(e);
+ }
+ }
+
+ public void dummyMethod(OMElement param) throws Exception {
+ System.out.println("Eventing Service dummy method called");
+ }
+
+ private class PublisherThread extends Thread {
+
+ String Publication = "Publication";
+ String publicationNamespaceValue = "http://tempuri/publication/";
+ Random r = new Random();
+
+ public void run() {
+ try {
+ while (true) {
+
+ //publishing
+ System.out.println("Publishing next publication...");
+
+ SubscriberStore store =
+ CommonUtil.getSubscriberStore(serviceContext.getAxisService());
+ if (store == null)
+ throw new Exception("Cant find the Savan subscriber store");
+
+ OMElement envelope = getNextPublicationEvent();
+ PublicationClient client =
+ new PublicationClient(serviceContext.getConfigurationContext());
+ client.sendPublication(envelope, serviceContext.getAxisService(), null);
+ Thread.sleep(10000);
+ }
+
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private int eventID = 0;
+
+ public OMElement getNextPublicationEvent() {
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ OMNamespace namespace = factory.createOMNamespace(publicationNamespaceValue, "ns1");
+ OMElement publicationElement = factory.createOMElement(Publication, namespace);
+
+ factory.createOMElement("foo", namespace, publicationElement)
+ .setText("Event " + eventID);
+
+ OMElement publishMethod = factory.createOMElement("publish", namespace);
+ publishMethod.addChild(publicationElement);
+
+ return publishMethod;
+ }
+ }
}
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServer.java b/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServer.java
index cf9b96c..7592bc7 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServer.java
+++ b/modules/core/src/test/java/org/apache/axis2/savan/atom/UtilServer.java
@@ -1,191 +1,182 @@
package org.apache.axis2.savan.atom;
-import java.io.File;
-import java.io.FilenameFilter;
-
-import javax.xml.namespace.QName;
-
import junit.framework.TestCase;
-
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.context.ServiceContext;
import org.apache.axis2.context.ServiceGroupContext;
-import org.apache.axis2.deployment.DeploymentConstants;
import org.apache.axis2.deployment.DeploymentEngine;
-import org.apache.axis2.deployment.DeploymentException;
-import org.apache.axis2.deployment.repository.util.ArchiveReader;
-import org.apache.axis2.deployment.util.Utils;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.AxisServiceGroup;
-import org.apache.axis2.description.Flow;
-import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.ListenerManager;
import org.apache.axis2.transport.http.SimpleHTTPServer;
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.FilenameFilter;
+
/**
- *
+ *
*/
public class UtilServer {
- private static int count = 0;
+ private static int count = 0;
- private static SimpleHTTPServer receiver;
+ private static SimpleHTTPServer receiver;
- public static final int TESTING_PORT = 5555;
+ public static final int TESTING_PORT = 5555;
- public static synchronized void deployService(AxisService service)
- throws AxisFault {
- receiver.getConfigurationContext().getAxisConfiguration().addService(
- service);
- }
+ public static synchronized void deployService(AxisService service)
+ throws AxisFault {
+ receiver.getConfigurationContext().getAxisConfiguration().addService(
+ service);
+ }
- public static synchronized void unDeployService(QName service)
- throws AxisFault {
- receiver.getConfigurationContext().getAxisConfiguration()
- .removeService(service.getLocalPart());
- }
+ public static synchronized void unDeployService(QName service)
+ throws AxisFault {
+ receiver.getConfigurationContext().getAxisConfiguration()
+ .removeService(service.getLocalPart());
+ }
- public static synchronized void unDeployClientService() throws AxisFault {
- if (receiver.getConfigurationContext().getAxisConfiguration() != null) {
- receiver.getConfigurationContext().getAxisConfiguration()
- .removeService("AnonymousService");
- }
- }
+ public static synchronized void unDeployClientService() throws AxisFault {
+ if (receiver.getConfigurationContext().getAxisConfiguration() != null) {
+ receiver.getConfigurationContext().getAxisConfiguration()
+ .removeService("AnonymousService");
+ }
+ }
- public static synchronized void start() throws Exception {
- start(org.apache.axis2.Constants.TESTING_REPOSITORY);
- }
+ public static synchronized void start() throws Exception {
+ start(org.apache.axis2.Constants.TESTING_REPOSITORY);
+ }
- public static synchronized void start(String repository) throws Exception {
- if (count == 0) {
- ConfigurationContext er = getNewConfigurationContext(repository);
- // er.getAxisConfiguration().addModule(new DeploymentEngine().)
+ public static synchronized void start(String repository) throws Exception {
+ if (count == 0) {
+ ConfigurationContext er = getNewConfigurationContext(repository);
+ // er.getAxisConfiguration().addModule(new DeploymentEngine().)
- receiver = new SimpleHTTPServer(er, TESTING_PORT);
+ receiver = new SimpleHTTPServer(er, TESTING_PORT);
- receiver.start();
- System.out
- .print("Server started on port " + TESTING_PORT + ".....");
+ receiver.start();
+ System.out
+ .print("Server started on port " + TESTING_PORT + ".....");
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e1) {
- throw new AxisFault("Thread interupted", e1);
- }
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e1) {
+ throw new AxisFault("Thread interupted", e1);
+ }
- }
- count++;
- }
+ }
+ count++;
+ }
-
- public static ConfigurationContext getNewConfigurationContext(
- String repository) throws Exception {
- File file = new File(repository);
- if (!file.exists()) {
- throw new Exception("repository directory "
- + file.getAbsolutePath() + " does not exists");
- }
- return ConfigurationContextFactory
- .createConfigurationContextFromFileSystem(file
- .getAbsolutePath(), file.getAbsolutePath()+"/conf/axis2.xml");
- }
+ public static ConfigurationContext getNewConfigurationContext(
+ String repository) throws Exception {
+ File file = new File(repository);
+ if (!file.exists()) {
+ throw new Exception("repository directory "
+ + file.getAbsolutePath() + " does not exists");
+ }
+ return ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(file
+ .getAbsolutePath(), file.getAbsolutePath() + "/conf/axis2.xml");
+ }
- public static synchronized void stop() throws AxisFault {
- if (count == 1) {
- receiver.stop();
- while (receiver.isRunning()) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e1) {
- }
- }
- count = 0;
- System.out.print("Server stopped .....");
- } else {
- count--;
- }
- ListenerManager listenerManager = receiver.getConfigurationContext()
- .getListenerManager();
- if (listenerManager != null) {
- listenerManager.stop();
- }
- }
+ public static synchronized void stop() throws AxisFault {
+ if (count == 1) {
+ receiver.stop();
+ while (receiver.isRunning()) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e1) {
+ }
+ }
+ count = 0;
+ System.out.print("Server stopped .....");
+ } else {
+ count--;
+ }
+ ListenerManager listenerManager = receiver.getConfigurationContext()
+ .getListenerManager();
+ if (listenerManager != null) {
+ listenerManager.stop();
+ }
+ }
- public static ConfigurationContext getConfigurationContext() {
- return receiver.getConfigurationContext();
- }
+ public static ConfigurationContext getConfigurationContext() {
+ return receiver.getConfigurationContext();
+ }
- static class AddressingFilter implements FilenameFilter {
- public boolean accept(File dir, String name) {
- return name.startsWith("addressing") && name.endsWith(".mar");
- }
- }
+ static class AddressingFilter implements FilenameFilter {
+ public boolean accept(File dir, String name) {
+ return name.startsWith("addressing") && name.endsWith(".mar");
+ }
+ }
- private static File getAddressingMARFile() {
- File dir = new File(org.apache.axis2.Constants.TESTING_REPOSITORY);
- File[] files = dir.listFiles(new AddressingFilter());
- TestCase.assertTrue(files.length == 1);
- File file = files[0];
- TestCase.assertTrue(file.exists());
- return file;
- }
+ private static File getAddressingMARFile() {
+ File dir = new File(org.apache.axis2.Constants.TESTING_REPOSITORY);
+ File[] files = dir.listFiles(new AddressingFilter());
+ TestCase.assertTrue(files.length == 1);
+ File file = files[0];
+ TestCase.assertTrue(file.exists());
+ return file;
+ }
- public static ServiceContext createAdressedEnabledClientSide(
- AxisService service) throws AxisFault {
- File file = getAddressingMARFile();
- TestCase.assertTrue(file.exists());
+ public static ServiceContext createAdressedEnabledClientSide(
+ AxisService service) throws AxisFault {
+ File file = getAddressingMARFile();
+ TestCase.assertTrue(file.exists());
- ConfigurationContext configContext = ConfigurationContextFactory
- .createConfigurationContextFromFileSystem(
- "target/test-resources/integrationRepo", null);
- AxisModule axisModule = DeploymentEngine.buildModule(file,
- configContext.getAxisConfiguration());
- configContext.getAxisConfiguration().addModule(axisModule);
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(
+ "target/test-resources/integrationRepo", null);
+ AxisModule axisModule = DeploymentEngine.buildModule(file,
+ configContext.getAxisConfiguration());
+ configContext.getAxisConfiguration().addModule(axisModule);
- configContext.getAxisConfiguration().addService(service);
+ configContext.getAxisConfiguration().addService(service);
- return new ServiceGroupContext(configContext,
- (AxisServiceGroup) service.getParent())
- .getServiceContext(service);
- }
+ return new ServiceGroupContext(configContext,
+ (AxisServiceGroup)service.getParent())
+ .getServiceContext(service);
+ }
- public static ConfigurationContext createClientConfigurationContext()
- throws AxisFault {
- File file = getAddressingMARFile();
- TestCase.assertTrue(file.exists());
+ public static ConfigurationContext createClientConfigurationContext()
+ throws AxisFault {
+ File file = getAddressingMARFile();
+ TestCase.assertTrue(file.exists());
- ConfigurationContext configContext = ConfigurationContextFactory
- .createConfigurationContextFromFileSystem(
- "target/test-resources/integrationRepo", null);
- AxisModule axisModule = DeploymentEngine.buildModule(file,
- configContext.getAxisConfiguration());
- configContext.getAxisConfiguration().addModule(axisModule);
- configContext.getAxisConfiguration().engageModule(
- new QName("addressing"));
- return configContext;
- }
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(
+ "target/test-resources/integrationRepo", null);
+ AxisModule axisModule = DeploymentEngine.buildModule(file,
+ configContext.getAxisConfiguration());
+ configContext.getAxisConfiguration().addModule(axisModule);
+ configContext.getAxisConfiguration().engageModule(
+ new QName("addressing"));
+ return configContext;
+ }
- public static ServiceContext createAdressedEnabledClientSide(
- AxisService service, String clientHome) throws AxisFault {
- File file = getAddressingMARFile();
- TestCase.assertTrue(file.exists());
+ public static ServiceContext createAdressedEnabledClientSide(
+ AxisService service, String clientHome) throws AxisFault {
+ File file = getAddressingMARFile();
+ TestCase.assertTrue(file.exists());
- ConfigurationContext configContext = ConfigurationContextFactory
- .createConfigurationContextFromFileSystem(clientHome, null);
- AxisModule axisModule = DeploymentEngine.buildModule(file,
- configContext.getAxisConfiguration());
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(clientHome, null);
+ AxisModule axisModule = DeploymentEngine.buildModule(file,
+ configContext.getAxisConfiguration());
- configContext.getAxisConfiguration().addModule(axisModule);
- // sysContext.getAxisConfiguration().engageModule(moduleDesc.getName());
+ configContext.getAxisConfiguration().addModule(axisModule);
+ // sysContext.getAxisConfiguration().engageModule(moduleDesc.getName());
- configContext.getAxisConfiguration().addService(service);
+ configContext.getAxisConfiguration().addService(service);
- return new ServiceGroupContext(configContext,
- (AxisServiceGroup) service.getParent())
- .getServiceContext(service);
- }
+ return new ServiceGroupContext(configContext,
+ (AxisServiceGroup)service.getParent())
+ .getServiceContext(service);
+ }
}
diff --git a/modules/core/src/test/java/org/apache/axis2/savan/atom/publisher.services.xml b/modules/core/src/test/java/org/apache/axis2/savan/atom/publisher.services.xml
index 75ac177..daede45 100644
--- a/modules/core/src/test/java/org/apache/axis2/savan/atom/publisher.services.xml
+++ b/modules/core/src/test/java/org/apache/axis2/savan/atom/publisher.services.xml
@@ -17,17 +17,18 @@
-->
<service name="PublisherService">
- <parameter name="ServiceClass" locked="xsd:false">org.apache.axis2.savan.atom.PublisherService</parameter>
+ <parameter name="ServiceClass" locked="xsd:false">org.apache.axis2.savan.atom.PublisherService
+ </parameter>
- <description>
- The Publisher Service of the Axis2 Eventing sample.
- </description>
+ <description>
+ The Publisher Service of the Axis2 Eventing sample.
+ </description>
- <module ref="savan" />
-
- <operation name="dummyMethod" mep="http://www.w3.org/2004/08/wsdl/in-only">
- <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
- <actionMapping>http://wso2.com/eventing/dummyMethod</actionMapping>
- </operation>
-
+ <module ref="savan"/>
+
+ <operation name="dummyMethod" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <actionMapping>http://wso2.com/eventing/dummyMethod</actionMapping>
+ </operation>
+
</service>
\ No newline at end of file
diff --git a/modules/core/src/test/resources/eventing-renew-datetime.xml b/modules/core/src/test/resources/eventing-renew-datetime.xml
index 1a34fcd..541cdd2 100644
--- a/modules/core/src/test/resources/eventing-renew-datetime.xml
+++ b/modules/core/src/test/resources/eventing-renew-datetime.xml
@@ -1,14 +1,14 @@
-<s12:Envelope
-xmlns:s12='http://www.w3.org/2003/05/soap-envelope'
-xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing'
-xmlns:wse='http://schemas.xmlsoap.org/ws/2004/08/eventing'
-xmlns:ow='http://www.example.org/oceanwatch' >
- <s12:Header>
- <wse:Identifier>UUID:DummySubscriberID</wse:Identifier>
- </s12:Header>
- <s12:Body>
- <wse:Renew>
- <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires>
- </wse:Renew>
- </s12:Body>
+<s12:Envelope
+ xmlns:s12='http://www.w3.org/2003/05/soap-envelope'
+ xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing'
+ xmlns:wse='http://schemas.xmlsoap.org/ws/2004/08/eventing'
+ xmlns:ow='http://www.example.org/oceanwatch'>
+ <s12:Header>
+ <wse:Identifier>UUID:DummySubscriberID</wse:Identifier>
+ </s12:Header>
+ <s12:Body>
+ <wse:Renew>
+ <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires>
+ </wse:Renew>
+ </s12:Body>
</s12:Envelope>
diff --git a/modules/core/src/test/resources/eventing-renew-duration.xml b/modules/core/src/test/resources/eventing-renew-duration.xml
index 4561cce..9f201f2 100644
--- a/modules/core/src/test/resources/eventing-renew-duration.xml
+++ b/modules/core/src/test/resources/eventing-renew-duration.xml
@@ -1,14 +1,14 @@
-<s12:Envelope
-xmlns:s12='http://www.w3.org/2003/05/soap-envelope'
-xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing'
-xmlns:wse='http://schemas.xmlsoap.org/ws/2004/08/eventing'
-xmlns:ow='http://www.example.org/oceanwatch' >
- <s12:Header>
- <wse:Identifier>UUID:DummySubscriberID</wse:Identifier>
- </s12:Header>
- <s12:Body>
- <wse:Renew>
- <wse:Expires>P1Y2M3DT10H30M</wse:Expires>
- </wse:Renew>
- </s12:Body>
+<s12:Envelope
+ xmlns:s12='http://www.w3.org/2003/05/soap-envelope'
+ xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing'
+ xmlns:wse='http://schemas.xmlsoap.org/ws/2004/08/eventing'
+ xmlns:ow='http://www.example.org/oceanwatch'>
+ <s12:Header>
+ <wse:Identifier>UUID:DummySubscriberID</wse:Identifier>
+ </s12:Header>
+ <s12:Body>
+ <wse:Renew>
+ <wse:Expires>P1Y2M3DT10H30M</wse:Expires>
+ </wse:Renew>
+ </s12:Body>
</s12:Envelope>
\ No newline at end of file
diff --git a/modules/core/src/test/resources/eventing-subscription.xml b/modules/core/src/test/resources/eventing-subscription.xml
index 8b27b5d..83b5656 100644
--- a/modules/core/src/test/resources/eventing-subscription.xml
+++ b/modules/core/src/test/resources/eventing-subscription.xml
@@ -1,28 +1,29 @@
-<s12:Envelope
- xmlns:s12='http://www.w3.org/2003/05/soap-envelope'
- xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing'
- xmlns:wse='http://schemas.xmlsoap.org/ws/2004/08/eventing'
- xmlns:ew='http://www.example.com/warnings' >
- <s12:Header />
- <s12:Body>
- <wse:Subscribe>
- <wse:EndTo>
- <wsa:Address>http://www.example.com/MyEventSink</wsa:Address>
- <wsa:ReferenceProperties>
- <ew:MySubscription>2597</ew:MySubscription>
- </wsa:ReferenceProperties>
- </wse:EndTo>
- <wse:Delivery>
- <wse:NotifyTo>
- <wsa:Address>http://www.other.example.com/OnStormWarning</wsa:Address>
- <wsa:ReferenceProperties>
- <ew:MySubscription>2597</ew:MySubscription>
- </wsa:ReferenceProperties>
- </wse:NotifyTo>
- </wse:Delivery>
- <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires>
- <wse:Filter xmlns:ow='http://www.example.org/oceanwatch'
- Dialect='http://www.w3.org/TR/1999/REC-xpath-19991116'>/</wse:Filter>
- </wse:Subscribe>
- </s12:Body>
- </s12:Envelope>
\ No newline at end of file
+<s12:Envelope
+ xmlns:s12='http://www.w3.org/2003/05/soap-envelope'
+ xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing'
+ xmlns:wse='http://schemas.xmlsoap.org/ws/2004/08/eventing'
+ xmlns:ew='http://www.example.com/warnings'>
+ <s12:Header/>
+ <s12:Body>
+ <wse:Subscribe>
+ <wse:EndTo>
+ <wsa:Address>http://www.example.com/MyEventSink</wsa:Address>
+ <wsa:ReferenceProperties>
+ <ew:MySubscription>2597</ew:MySubscription>
+ </wsa:ReferenceProperties>
+ </wse:EndTo>
+ <wse:Delivery>
+ <wse:NotifyTo>
+ <wsa:Address>http://www.other.example.com/OnStormWarning</wsa:Address>
+ <wsa:ReferenceProperties>
+ <ew:MySubscription>2597</ew:MySubscription>
+ </wsa:ReferenceProperties>
+ </wse:NotifyTo>
+ </wse:Delivery>
+ <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires>
+ <wse:Filter xmlns:ow='http://www.example.org/oceanwatch'
+ Dialect='http://www.w3.org/TR/1999/REC-xpath-19991116'>/
+ </wse:Filter>
+ </wse:Subscribe>
+ </s12:Body>
+</s12:Envelope>
\ No newline at end of file
diff --git a/modules/core/src/test/resources/savan-config-test.xml b/modules/core/src/test/resources/savan-config-test.xml
index 437271c..52e10f6 100644
--- a/modules/core/src/test/resources/savan-config-test.xml
+++ b/modules/core/src/test/resources/savan-config-test.xml
@@ -1,53 +1,53 @@
<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>
- <defaultSubscriber>eventing-leaf</defaultSubscriber>
- <defaultFilter>empty</defaultFilter>
- <!--
- <parameters>
- <parameter>
- <name>eventing-topic-subscriber</name>
- <value>eventing-topic</value>
- </parameter>
- </parameters>
- -->
- </protocol>
- </protocols>
-
- <subscriberStores>
- <subscriberStore>
- <key>default</key>
- <class>org.apache.savan.storage.DefaultSubscriberStore</class>
- </subscriberStore>
- </subscriberStores>
-
- <filters>
- <filter>
- <name>empty</name>
- <identifier>empty</identifier>
- <class>org.apache.savan.filters.EmptyFilter</class>
- </filter>
- <filter>
- <name>xpath</name>
- <identifier>http://www.w3.org/TR/1999/REC-xpath-19991116</identifier>
- <class>org.apache.savan.filters.XPathBasedFilter</class>
- </filter>
- </filters>
-
- <subscribers>
- <subscriber>
- <name>eventing-leaf</name>
- <class>org.apache.savan.eventing.subscribers.EventingSubscriber</class>
- </subscriber>
- </subscribers>
-
+ <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>
+ <defaultSubscriber>eventing-leaf</defaultSubscriber>
+ <defaultFilter>empty</defaultFilter>
+ <!--
+ <parameters>
+ <parameter>
+ <name>eventing-topic-subscriber</name>
+ <value>eventing-topic</value>
+ </parameter>
+ </parameters>
+ -->
+ </protocol>
+ </protocols>
+
+ <subscriberStores>
+ <subscriberStore>
+ <key>default</key>
+ <class>org.apache.savan.storage.DefaultSubscriberStore</class>
+ </subscriberStore>
+ </subscriberStores>
+
+ <filters>
+ <filter>
+ <name>empty</name>
+ <identifier>empty</identifier>
+ <class>org.apache.savan.filters.EmptyFilter</class>
+ </filter>
+ <filter>
+ <name>xpath</name>
+ <identifier>http://www.w3.org/TR/1999/REC-xpath-19991116</identifier>
+ <class>org.apache.savan.filters.XPathBasedFilter</class>
+ </filter>
+ </filters>
+
+ <subscribers>
+ <subscriber>
+ <name>eventing-leaf</name>
+ <class>org.apache.savan.eventing.subscribers.EventingSubscriber</class>
+ </subscriber>
+ </subscribers>
+
</savan-config>
\ No newline at end of file
diff --git a/modules/mar/module.xml b/modules/mar/module.xml
index d5b2b4b..05636b1 100644
--- a/modules/mar/module.xml
+++ b/modules/mar/module.xml
@@ -1,24 +1,24 @@
-<module name="Savan" class="org.apache.savan.module.SavanModule">
-
- <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>
-
- <operation name="atom" mep="http://www.w3.org/2004/08/wsdl/in-out">
- <messageReceiver class="org.apache.savan.atom.AtomMessageReceiver"/>
- </operation>
-
- <operation name="publish" mep="http://www.w3.org/2004/08/wsdl/in-out">
- <messageReceiver class="org.apache.savan.messagereceiver.PublishingMessageReceiver"/>
- <actionMapping>http://ws.apache.org/ws/2007/05/eventing-extended/Publish</actionMapping>
- </operation>
-
+<module name="Savan" class="org.apache.savan.module.SavanModule">
+
+ <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>
+
+ <operation name="atom" mep="http://www.w3.org/2004/08/wsdl/in-out">
+ <messageReceiver class="org.apache.savan.atom.AtomMessageReceiver"/>
+ </operation>
+
+ <operation name="publish" mep="http://www.w3.org/2004/08/wsdl/in-out">
+ <messageReceiver class="org.apache.savan.messagereceiver.PublishingMessageReceiver"/>
+ <actionMapping>http://ws.apache.org/ws/2007/05/eventing-extended/Publish</actionMapping>
+ </operation>
+
</module>
diff --git a/modules/mar/pom.xml b/modules/mar/pom.xml
index 35ad478..ccc3438 100644
--- a/modules/mar/pom.xml
+++ b/modules/mar/pom.xml
@@ -2,90 +2,90 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.ws.savan</groupId>
- <artifactId>savan-parent</artifactId>
- <version>SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
+ <parent>
<groupId>org.apache.ws.savan</groupId>
- <artifactId>savan</artifactId>
- <packaging>mar</packaging>
- <name>Savan - Mar</name>
+ <artifactId>savan-parent</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
- <build>
- <sourceDirectory>src/main/java</sourceDirectory>
- <testSourceDirectory>src/main/java</testSourceDirectory>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
-
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>create-test-resources</id>
- <phase>process-test-resources</phase>
- <configuration>
- <tasks>
- <!--copying classes from the core module-->
- <copydir src="../core/target/classes"
- dest="target/classes"/>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ws.savan</groupId>
+ <artifactId>savan</artifactId>
+ <packaging>mar</packaging>
+ <name>Savan - Mar</name>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.axis2</groupId>
- <artifactId>axis2-mar-maven-plugin</artifactId>
- <version>SNAPSHOT</version>
- <extensions>true</extensions>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-archiver</artifactId>
- <version>2.2</version>
- </dependency>
- </dependencies>
+ <build>
+ <sourceDirectory>src/main/java</sourceDirectory>
+ <testSourceDirectory>src/main/java</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
- <configuration>
- <includeDependencies>false</includeDependencies>
- <moduleXmlFile>module.xml</moduleXmlFile>
- </configuration>
- </plugin>
- </plugins>
+ <plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.sandesha2</groupId>
- <artifactId>sandesha2-core</artifactId>
- <version>SNAPSHOT</version>
- </dependency>
- </dependencies>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>create-test-resources</id>
+ <phase>process-test-resources</phase>
+ <configuration>
+ <tasks>
+ <!--copying classes from the core module-->
+ <copydir src="../core/target/classes"
+ dest="target/classes"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-mar-maven-plugin</artifactId>
+ <version>SNAPSHOT</version>
+ <extensions>true</extensions>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-archiver</artifactId>
+ <version>2.2</version>
+ </dependency>
+ </dependencies>
+
+ <configuration>
+ <includeDependencies>false</includeDependencies>
+ <moduleXmlFile>module.xml</moduleXmlFile>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.sandesha2</groupId>
+ <artifactId>sandesha2-core</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/modules/samples/eventing/build.xml b/modules/samples/eventing/build.xml
index 686570f..ac64102 100644
--- a/modules/samples/eventing/build.xml
+++ b/modules/samples/eventing/build.xml
@@ -1,103 +1,103 @@
<project default="build.sample">
- <property name="axis2.home" value="/mnt/win_d/projects/axis/Axis2-1.3/axis2-1.3" />
-
- <target name="build.sample">
- <property name="axis2.home" value="/mnt/win_d/projects/axis/Axis2-1.3/axis2-1.3" />
- <property name="eventing.temp.dir" value="build/temp" />
- <property name="listner1.temp.dir" value="${eventing.temp.dir}/listner1" />
- <property name="listner2.temp.dir" value="${eventing.temp.dir}/listner2" />
- <property name="publisher.temp.dir" value="${eventing.temp.dir}/publisher" />
-
-
- <mkdir dir="${listner1.temp.dir}" />
- <mkdir dir="${listner1.temp.dir}/META-INF" />
- <mkdir dir="${listner2.temp.dir}" />
- <mkdir dir="${listner2.temp.dir}/META-INF" />
- <mkdir dir="${publisher.temp.dir}" />
- <mkdir dir="${publisher.temp.dir}/META-INF" />
+ <property name="axis2.home" value="c:/temp/axis2-1.4"/>
- <mkdir dir="build/classes" />
- <mkdir dir="build/lib" />
-
- <javac srcdir="src" destdir="build/classes">
- <classpath>
- <fileset dir="../../core/target">
- <include name="*.jar"/>
- </fileset>
- <fileset dir="${axis2.home}/lib">
- <include name="*.jar"/>
- </fileset>
- </classpath>
- </javac>
-
- <copy toFile="${listner1.temp.dir}/META-INF/services.xml" file="listner1.services.xml"/>
- <copy toFile="${listner2.temp.dir}/META-INF/services.xml" file="listner2.services.xml"/>
- <copy toFile="${publisher.temp.dir}/META-INF/services.xml" file="publisher.services.xml"/>
-
- <jar destfile="build/ListnerService1.aar">
- <fileset dir="build/classes">
- <include name="sample/eventing/**/**/*ListnerService1*" />
- </fileset>
- <fileset dir="${listner1.temp.dir}">
- <include name="META-INF/**"/>
- </fileset>
- </jar>
-
- <jar destfile="build/ListnerService2.aar">
- <fileset dir="build/classes">
- <include name="sample/eventing/**/**/*ListnerService2*" />
- </fileset>
- <fileset dir="${listner2.temp.dir}">
- <include name="META-INF/**"/>
- </fileset>
- </jar>
-
- <jar destfile="build/PublisherService.aar">
- <fileset dir="build/classes">
- <include name="sample/eventing/**/**/*PublisherService*" />
- </fileset>
- <fileset dir="${publisher.temp.dir}">
- <include name="META-INF/**"/>
- </fileset>
- </jar>
-
- <jar destfile="build/ListnerService1.aar">
- <fileset dir="build/classes">
- <include name="sample/eventing/**/**/*ListnerService1*" />
- </fileset>
- <fileset dir="${listner1.temp.dir}">
- <include name="META-INF/**"/>
- </fileset>
- </jar>
-
- <jar destfile="build/EventingSample.jar">
- <fileset dir="build/classes">
- <include name="sample/eventing/**"/>
- </fileset>
- </jar>
-
- <copy todir="build">
- <fileset dir=".">
- <include name="*.sh"/>
- <include name="*.bat"/>
- </fileset>
- </copy>
- </target>
-
- <target name="clean">
- <delete dir="build"/>
- </target>
+ <target name="build.sample">
+ <property name="axis2.home" value="/mnt/win_d/projects/axis/Axis2-1.3/axis2-1.3"/>
+ <property name="eventing.temp.dir" value="build/temp"/>
+ <property name="listener1.temp.dir" value="${eventing.temp.dir}/listener1"/>
+ <property name="listener2.temp.dir" value="${eventing.temp.dir}/listener2"/>
+ <property name="publisher.temp.dir" value="${eventing.temp.dir}/publisher"/>
- <target name="deploy">
- <!-- deploy savan module to axis2 -->
- <copy todir="${axis2.home}/repository/modules">
- <fileset dir="../../mar/target" includes="savan-*.mar"/>
- </copy>
-
- <!-- deploy samples -->
- <copy todir="${axis2.home}/repository/services">
- <fileset dir="build" includes="*.aar"/>
- </copy>
- </target>
-
-</project>
\ No newline at end of file
+
+ <mkdir dir="${listener1.temp.dir}"/>
+ <mkdir dir="${listener1.temp.dir}/META-INF"/>
+ <mkdir dir="${listener2.temp.dir}"/>
+ <mkdir dir="${listener2.temp.dir}/META-INF"/>
+ <mkdir dir="${publisher.temp.dir}"/>
+ <mkdir dir="${publisher.temp.dir}/META-INF"/>
+
+ <mkdir dir="build/classes"/>
+ <mkdir dir="build/lib"/>
+
+ <javac srcdir="src" destdir="build/classes">
+ <classpath>
+ <fileset dir="../../core/target">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${axis2.home}/lib">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </javac>
+
+ <copy toFile="${listener1.temp.dir}/META-INF/services.xml" file="listener1.services.xml"/>
+ <copy toFile="${listener2.temp.dir}/META-INF/services.xml" file="listener2.services.xml"/>
+ <copy toFile="${publisher.temp.dir}/META-INF/services.xml" file="publisher.services.xml"/>
+
+ <jar destfile="build/ListenerService1.aar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**/**/*ListenerService1*"/>
+ </fileset>
+ <fileset dir="${listener1.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="build/ListenerService2.aar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**/**/*ListenerService2*"/>
+ </fileset>
+ <fileset dir="${listener2.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="build/PublisherService.aar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**/**/*PublisherService*"/>
+ </fileset>
+ <fileset dir="${publisher.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="build/ListenerService1.aar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**/**/*ListenerService1*"/>
+ </fileset>
+ <fileset dir="${listener1.temp.dir}">
+ <include name="META-INF/**"/>
+ </fileset>
+ </jar>
+
+ <jar destfile="build/EventingSample.jar">
+ <fileset dir="build/classes">
+ <include name="sample/eventing/**"/>
+ </fileset>
+ </jar>
+
+ <copy todir="build">
+ <fileset dir=".">
+ <include name="*.sh"/>
+ <include name="*.bat"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="clean">
+ <delete dir="build"/>
+ </target>
+
+ <target name="deploy">
+ <!-- deploy savan module to axis2 -->
+ <copy todir="${axis2.home}/repository/modules">
+ <fileset dir="../../mar/target" includes="savan-*.mar"/>
+ </copy>
+
+ <!-- deploy samples -->
+ <copy todir="${axis2.home}/repository/services">
+ <fileset dir="build" includes="*.aar"/>
+ </copy>
+ </target>
+
+</project>
diff --git a/modules/samples/eventing/listener1.services.xml b/modules/samples/eventing/listener1.services.xml
new file mode 100644
index 0000000..8bd337b
--- /dev/null
+++ b/modules/samples/eventing/listener1.services.xml
@@ -0,0 +1,13 @@
+<service name="ListenerService1">
+
+ <parameter name="ServiceClass" locked="xsd:false">sample.eventing.ListenerService1</parameter>
+
+ <description>
+ The Listener Service 1 of the Axis2 Eventing sample.
+ </description>
+
+ <operation name="publish" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ </operation>
+
+</service>
\ No newline at end of file
diff --git a/modules/samples/eventing/listener2.services.xml b/modules/samples/eventing/listener2.services.xml
new file mode 100644
index 0000000..c610371
--- /dev/null
+++ b/modules/samples/eventing/listener2.services.xml
@@ -0,0 +1,13 @@
+<service name="ListenerService2">
+
+ <parameter name="ServiceClass" locked="xsd:false">sample.eventing.ListenerService2</parameter>
+
+ <description>
+ The Listener Service 2 of the Axis2 Eventing sample.
+ </description>
+
+ <operation name="publish" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ </operation>
+
+</service>
\ No newline at end of file
diff --git a/modules/samples/eventing/listner1.services.xml b/modules/samples/eventing/listner1.services.xml
deleted file mode 100644
index cb050c5..0000000
--- a/modules/samples/eventing/listner1.services.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<service name="ListnerService1">
-
- <parameter name="ServiceClass" locked="xsd:false">sample.eventing.ListnerService1</parameter>
-
- <description>
- The Listner Service 1 of the Axis2 Eventing sample.
- </description>
-
- <operation name="publish" mep="http://www.w3.org/2004/08/wsdl/in-only">
- <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
- </operation>
-
-</service>
\ No newline at end of file
diff --git a/modules/samples/eventing/listner2.services.xml b/modules/samples/eventing/listner2.services.xml
deleted file mode 100644
index 0e5c9be..0000000
--- a/modules/samples/eventing/listner2.services.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<service name="ListnerService2">
-
- <parameter name="ServiceClass" locked="xsd:false">sample.eventing.ListnerService2</parameter>
-
- <description>
- The Listner Service 2 of the Axis2 Eventing sample.
- </description>
-
- <operation name="publish" mep="http://www.w3.org/2004/08/wsdl/in-only">
- <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
- </operation>
-
-</service>
\ No newline at end of file
diff --git a/modules/samples/eventing/publisher.services.xml b/modules/samples/eventing/publisher.services.xml
index 31f729a..39d9495 100644
--- a/modules/samples/eventing/publisher.services.xml
+++ b/modules/samples/eventing/publisher.services.xml
@@ -1,17 +1,17 @@
<service name="PublisherService">
- <parameter name="ServiceClass" locked="xsd:false">sample.eventing.PublisherService</parameter>
+ <parameter name="ServiceClass" locked="xsd:false">sample.eventing.PublisherService</parameter>
- <description>
- The Publisher Service of the Axis2 Eventing sample.
- </description>
+ <description>
+ The Publisher Service of the Axis2 Eventing sample.
+ </description>
- <module ref="savan" />
- <module ref="addressing" />
-
- <operation name="dummyMethod" mep="http://www.w3.org/2004/08/wsdl/in-only">
- <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver" />
- <actionMapping>uuid:DummyMethodAction</actionMapping>
- </operation>
-
+ <module ref="savan"/>
+ <module ref="addressing"/>
+
+ <operation name="dummyMethod" mep="http://www.w3.org/2004/08/wsdl/in-only">
+ <messageReceiver class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <actionMapping>uuid:DummyMethodAction</actionMapping>
+ </operation>
+
</service>
\ No newline at end of file
diff --git a/modules/samples/eventing/src/sample/eventing/Client.java b/modules/samples/eventing/src/sample/eventing/Client.java
index e0365eb..798f2ce 100644
--- a/modules/samples/eventing/src/sample/eventing/Client.java
+++ b/modules/samples/eventing/src/sample/eventing/Client.java
@@ -16,14 +16,6 @@
package sample.eventing;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-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.OMFactory;
@@ -38,67 +30,73 @@
import org.apache.savan.eventing.client.EventingClientBean;
import org.apache.savan.eventing.client.SubscriptionStatus;
+import javax.xml.namespace.QName;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
public class Client {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
-
+
private final int MIN_OPTION = 1;
private final int MAX_OPTION = 9;
-
+
private final String SUBSCRIBER_1_ID = "subscriber1";
private final String SUBSCRIBER_2_ID = "subscriber2";
-
+
private ServiceClient serviceClient = null;
private Options options = null;
private EventingClient eventingClient = null;
-
+
private String toAddressPart = "/axis2/services/PublisherService";
- private String listner1AddressPart = "/axis2/services/ListnerService1";
- private String listner2AddressPart = "/axis2/services/ListnerService2";
-
- private final String applicationNamespaceName = "http://tempuri.org/";
- private final String dummyMethod = "dummyMethod";
-
- private static String repo = null;
- private static int port = 8080;
- private static String serverIP = "127.0.0.1";
-
- private static final String portParam = "-p";
- private static final String repoParam = "-r";
- private static final String helpParam = "-h";
-
- public static void main (String[] args) throws Exception {
-
- for (int i=0;i<args.length;i++) {
- if (helpParam.equalsIgnoreCase(args[i])) {
- displayHelp ();
- System.exit(0);
- }
- }
-
- String portStr = getParam(portParam,args);
- if (portStr!=null) {
- port = Integer.parseInt(portStr);
- System.out.println("Server Port was set to:" + port);
- }
-
- String repoStr = getParam(repoParam,args);
- if (repoStr!=null) {
- repo = repoStr;
- System.out.println("Client Repository was set to:" + repo);
- }
-
- Client c = new Client ();
- c.run ();
- }
-
- private static void displayHelp () {
- System.out.println("Help page for the Eventing Client");
- System.out.println("---------------------------------");
- System.out.println("Set the client reposiory using the parameter -r");
- System.out.println("Set the server port using the parameter -p");
- }
-
+ private String listener1AddressPart = "/axis2/services/ListenerService1";
+ private String listener2AddressPart = "/axis2/services/ListenerService2";
+
+ private final String applicationNamespaceName = "http://tempuri.org/";
+ private final String dummyMethod = "dummyMethod";
+
+ private static String repo = null;
+ private static int port = 8080;
+ private static String serverIP = "127.0.0.1";
+
+ private static final String portParam = "-p";
+ private static final String repoParam = "-r";
+ private static final String helpParam = "-h";
+
+ public static void main(String[] args) throws Exception {
+
+ for (int i = 0; i < args.length; i++) {
+ if (helpParam.equalsIgnoreCase(args[i])) {
+ displayHelp();
+ System.exit(0);
+ }
+ }
+
+ String portStr = getParam(portParam, args);
+ if (portStr != null) {
+ port = Integer.parseInt(portStr);
+ System.out.println("Server Port was set to:" + port);
+ }
+
+ String repoStr = getParam(repoParam, args);
+ if (repoStr != null) {
+ repo = repoStr;
+ System.out.println("Client Repository was set to:" + repo);
+ }
+
+ Client c = new Client();
+ c.run();
+ }
+
+ private static void displayHelp() {
+ System.out.println("Help page for the Eventing Client");
+ System.out.println("---------------------------------");
+ System.out.println("Set the client reposiory using the parameter -r");
+ System.out.println("Set the server port using the parameter -p");
+ }
+
/**
* This will check the given parameter in the array and will return, if available
*
@@ -119,175 +117,176 @@
}
return null;
}
-
- public void run () throws Exception {
-
- System.out.println("\n");
- System.out.println("Welcome to Axis2 Eventing Sample");
- System.out.println("================================\n");
-
- boolean validOptionSelected = false;
- int selectedOption = -1;
- while (!validOptionSelected) {
- displayMenu();
- selectedOption = getIntInput();
- if (selectedOption>=MIN_OPTION && selectedOption<=MAX_OPTION)
- validOptionSelected = true;
- else
- System.out.println("\nInvalid Option \n\n");
- }
-
- initClient ();
- performAction (selectedOption);
-
- //TODO publish
-
- System.out.println("Press enter to initialize the publisher service.");
- reader.readLine();
-
- options.setAction("uuid:DummyMethodAction");
- serviceClient.fireAndForget(getDummyMethodRequestElement ());
-
- while (true) {
-
- validOptionSelected = false;
- selectedOption = -1;
- while (!validOptionSelected) {
- displayMenu();
- selectedOption = getIntInput();
- if (selectedOption>=MIN_OPTION && selectedOption<=MAX_OPTION)
- validOptionSelected = true;
- else
- System.out.println("\nInvalid Option \n\n");
- }
-
- performAction (selectedOption);
-
- }
- }
-
- private void displayMenu () {
- System.out.println("Press 1 to subscribe Listner Service 1");
- System.out.println("Press 2 to subscribe Listner Service 2");
- System.out.println("Press 3 to subscribe both listner services");
- System.out.println("Press 4 to unsubscribe Listner Service 1");
- System.out.println("Press 5 to unsubscribe Listner Service 2");
- System.out.println("Press 6 to unsubscribe both listner services");
- System.out.println("Press 7 to to get the status of the subscription to Service 1");
- System.out.println("Press 8 to to get the status of the subscription to Service 2");
- System.out.println("Press 9 to Exit");
- }
-
- private int getIntInput () throws IOException {
+
+ public void run() throws Exception {
+
+ System.out.println("\n");
+ System.out.println("Welcome to Axis2 Eventing Sample");
+ System.out.println("================================\n");
+
+ boolean validOptionSelected = false;
+ int selectedOption = -1;
+ while (!validOptionSelected) {
+ displayMenu();
+ selectedOption = getIntInput();
+ if (selectedOption >= MIN_OPTION && selectedOption <= MAX_OPTION)
+ validOptionSelected = true;
+ else
+ System.out.println("\nInvalid Option \n\n");
+ }
+
+ initClient();
+ performAction(selectedOption);
+
+ //TODO publish
+
+ System.out.println("Press enter to initialize the publisher service.");
+ reader.readLine();
+
+ options.setAction("uuid:DummyMethodAction");
+ serviceClient.fireAndForget(getDummyMethodRequestElement());
+
+ while (true) {
+
+ validOptionSelected = false;
+ selectedOption = -1;
+ while (!validOptionSelected) {
+ displayMenu();
+ selectedOption = getIntInput();
+ if (selectedOption >= MIN_OPTION && selectedOption <= MAX_OPTION)
+ validOptionSelected = true;
+ else
+ System.out.println("\nInvalid Option \n\n");
+ }
+
+ performAction(selectedOption);
+
+ }
+ }
+
+ private void displayMenu() {
+ System.out.println("Press 1 to subscribe Listener Service 1");
+ System.out.println("Press 2 to subscribe Listener Service 2");
+ System.out.println("Press 3 to subscribe both listener services");
+ System.out.println("Press 4 to unsubscribe Listener Service 1");
+ System.out.println("Press 5 to unsubscribe Listener Service 2");
+ System.out.println("Press 6 to unsubscribe both listener services");
+ System.out.println("Press 7 to to get the status of the subscription to Service 1");
+ System.out.println("Press 8 to to get the status of the subscription to Service 2");
+ System.out.println("Press 9 to Exit");
+ }
+
+ private int getIntInput() throws IOException {
String option = reader.readLine();
try {
return Integer.parseInt(option);
} catch (NumberFormatException e) {
- //invalid option
- return -1;
+ //invalid option
+ return -1;
}
- }
-
- private void initClient () throws AxisFault {
+ }
- String CLIENT_REPO = null;
- String AXIS2_XML = null;
-
- if (repo!=null) {
- CLIENT_REPO = repo;
- AXIS2_XML = repo + File.separator + "axis2.xml";
- } else {
+ private void initClient() throws AxisFault {
+
+ String CLIENT_REPO = null;
+ String AXIS2_XML = null;
+
+ if (repo != null) {
+ CLIENT_REPO = repo;
+ AXIS2_XML = repo + File.separator + "axis2.xml";
+ } else {
// throw new AxisFault ("Please specify the client repository as a program argument.Use '-h' for help.");
- }
-
- ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO,null);
- serviceClient = new ServiceClient (configContext,null); //TODO give a repo
-
- options = new Options ();
- serviceClient.setOptions(options);
- serviceClient.engageModule(new QName ("addressing"));
-
- eventingClient = new EventingClient (serviceClient);
-
- String toAddress = "http://" + serverIP + ":" + port + toAddressPart;
- options.setTo(new EndpointReference (toAddress));
- }
-
- private void performAction (int action) throws Exception {
-
- switch (action) {
- case 1:
- doSubscribe(SUBSCRIBER_1_ID);
- break;
- case 2:
- doSubscribe(SUBSCRIBER_2_ID);
- break;
- case 3:
- doSubscribe(SUBSCRIBER_1_ID);
- doSubscribe(SUBSCRIBER_2_ID);
- break;
- case 4:
- doUnsubscribe(SUBSCRIBER_1_ID);
- break;
- case 5:
- doUnsubscribe(SUBSCRIBER_2_ID);
- break;
- case 6:
- doUnsubscribe(SUBSCRIBER_1_ID);
- doUnsubscribe(SUBSCRIBER_2_ID);
- break;
- case 7:
- doGetStatus(SUBSCRIBER_1_ID);
- break;
- case 8:
- doGetStatus(SUBSCRIBER_2_ID);
- break;
- case 9:
- System.exit(0);
- break;
- default:
- break;
- }
- }
-
- private void doSubscribe (String ID) throws Exception {
- EventingClientBean bean = new EventingClientBean ();
-
- String subscribingAddress = null;
- if (SUBSCRIBER_1_ID.equals(ID)) {
- subscribingAddress = "http://" + serverIP + ":" + port + listner1AddressPart;
- } else if (SUBSCRIBER_2_ID.equals(ID)) {
- subscribingAddress = "http://" + serverIP + ":" + port + listner2AddressPart;
- }
-
- bean.setDeliveryEPR(new EndpointReference (subscribingAddress));
-
- //uncomment following to set an expiration time of 10 minutes.
+ }
+
+ ConfigurationContext configContext = ConfigurationContextFactory
+ .createConfigurationContextFromFileSystem(CLIENT_REPO, null);
+ serviceClient = new ServiceClient(configContext, null); //TODO give a repo
+
+ options = new Options();
+ serviceClient.setOptions(options);
+ serviceClient.engageModule(new QName("addressing"));
+
+ eventingClient = new EventingClient(serviceClient);
+
+ String toAddress = "http://" + serverIP + ":" + port + toAddressPart;
+ options.setTo(new EndpointReference(toAddress));
+ }
+
+ private void performAction(int action) throws Exception {
+
+ switch (action) {
+ case 1:
+ doSubscribe(SUBSCRIBER_1_ID);
+ break;
+ case 2:
+ doSubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 3:
+ doSubscribe(SUBSCRIBER_1_ID);
+ doSubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 4:
+ doUnsubscribe(SUBSCRIBER_1_ID);
+ break;
+ case 5:
+ doUnsubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 6:
+ doUnsubscribe(SUBSCRIBER_1_ID);
+ doUnsubscribe(SUBSCRIBER_2_ID);
+ break;
+ case 7:
+ doGetStatus(SUBSCRIBER_1_ID);
+ break;
+ case 8:
+ doGetStatus(SUBSCRIBER_2_ID);
+ break;
+ case 9:
+ System.exit(0);
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void doSubscribe(String ID) throws Exception {
+ EventingClientBean bean = new EventingClientBean();
+
+ String subscribingAddress = null;
+ if (SUBSCRIBER_1_ID.equals(ID)) {
+ subscribingAddress = "http://" + serverIP + ":" + port + listener1AddressPart;
+ } else if (SUBSCRIBER_2_ID.equals(ID)) {
+ subscribingAddress = "http://" + serverIP + ":" + port + listener2AddressPart;
+ }
+
+ bean.setDeliveryEPR(new EndpointReference(subscribingAddress));
+
+ //uncomment following to set an expiration time of 10 minutes.
// Date date = new Date ();
// date.setMinutes(date.getMinutes()+10);
// bean.setExpirationTime(date);
-
- eventingClient.subscribe(bean,ID);
- Thread.sleep(1000); //TODO remove if not sequired
- }
-
- private void doUnsubscribe (String ID) throws Exception {
- eventingClient.unsubscribe(ID);
- Thread.sleep(1000); //TODO remove if not sequired
- }
-
- private void doGetStatus (String ID) throws Exception {
- SubscriptionStatus status = eventingClient.getSubscriptionStatus(ID);
- Thread.sleep(1000); //TODO remove if not sequired
-
- String statusValue = status.getExpirationValue();
- System.out.println("Status of the subscriber '" + ID +"' is" + statusValue);
- }
-
- private OMElement getDummyMethodRequestElement() {
- OMFactory fac = OMAbstractFactory.getOMFactory();
- OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName,"ns1");
- return fac.createOMElement(dummyMethod, namespace);
- }
-
+
+ eventingClient.subscribe(bean, ID);
+ Thread.sleep(1000); //TODO remove if not sequired
+ }
+
+ private void doUnsubscribe(String ID) throws Exception {
+ eventingClient.unsubscribe(ID);
+ Thread.sleep(1000); //TODO remove if not sequired
+ }
+
+ private void doGetStatus(String ID) throws Exception {
+ SubscriptionStatus status = eventingClient.getSubscriptionStatus(ID);
+ Thread.sleep(1000); //TODO remove if not sequired
+
+ String statusValue = status.getExpirationValue();
+ System.out.println("Status of the subscriber '" + ID + "' is" + statusValue);
+ }
+
+ private OMElement getDummyMethodRequestElement() {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName, "ns1");
+ return fac.createOMElement(dummyMethod, namespace);
+ }
+
}
diff --git a/modules/samples/eventing/src/sample/eventing/ListnerService1.java b/modules/samples/eventing/src/sample/eventing/ListenerService1.java
similarity index 69%
rename from modules/samples/eventing/src/sample/eventing/ListnerService1.java
rename to modules/samples/eventing/src/sample/eventing/ListenerService1.java
index 5ac7c4b..a04e9ed 100644
--- a/modules/samples/eventing/src/sample/eventing/ListnerService1.java
+++ b/modules/samples/eventing/src/sample/eventing/ListenerService1.java
@@ -18,15 +18,15 @@
import org.apache.axiom.om.OMElement;
-public class ListnerService1 {
-
- String name = "ListnerService1";
+public class ListenerService1 {
- public void publish(OMElement param) throws Exception {
- System.out.println("\n");
- System.out.println("'" + name + "' got a new publication...");
- System.out.println(param);
- System.out.println("\n");
- }
+ String name = "ListenerService1";
+
+ public void publish(OMElement param) throws Exception {
+ System.out.println("\n");
+ System.out.println("'" + name + "' got a new publication...");
+ System.out.println(param);
+ System.out.println("\n");
+ }
}
diff --git a/modules/samples/eventing/src/sample/eventing/ListnerService2.java b/modules/samples/eventing/src/sample/eventing/ListenerService2.java
similarity index 69%
rename from modules/samples/eventing/src/sample/eventing/ListnerService2.java
rename to modules/samples/eventing/src/sample/eventing/ListenerService2.java
index d2b7657..540b283 100644
--- a/modules/samples/eventing/src/sample/eventing/ListnerService2.java
+++ b/modules/samples/eventing/src/sample/eventing/ListenerService2.java
@@ -18,15 +18,15 @@
import org.apache.axiom.om.OMElement;
-public class ListnerService2 {
-
- String name = "ListnerService2";
-
- public void publish(OMElement param) throws Exception {
- System.out.println("\n");
- System.out.println("'" + name + "' got a new publication...");
- System.out.println(param);
- System.out.println("\n");
- }
+public class ListenerService2 {
+
+ String name = "ListenerService2";
+
+ public void publish(OMElement param) throws Exception {
+ System.out.println("\n");
+ System.out.println("'" + name + "' got a new publication...");
+ System.out.println(param);
+ System.out.println("\n");
+ }
}
diff --git a/modules/samples/eventing/src/sample/eventing/PublisherService.java b/modules/samples/eventing/src/sample/eventing/PublisherService.java
index 6eacefb..0f02141 100644
--- a/modules/samples/eventing/src/sample/eventing/PublisherService.java
+++ b/modules/samples/eventing/src/sample/eventing/PublisherService.java
@@ -16,9 +16,6 @@
package sample.eventing;
-import java.net.URI;
-import java.util.Random;
-
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
@@ -29,65 +26,69 @@
import org.apache.savan.storage.SubscriberStore;
import org.apache.savan.util.CommonUtil;
+import java.util.Random;
+
public class PublisherService {
-
- ServiceContext serviceContext = null;
-
- public void init(ServiceContext serviceContext) throws AxisFault {
- System.out.println("Eventing Service INIT called");
- this.serviceContext = serviceContext;
-
- PublisherThread thread = new PublisherThread ();
- thread.start();
- }
-
- public void dummyMethod(OMElement param) throws Exception {
- System.out.println("Eventing Service dummy method called");
- }
-
- private class PublisherThread extends Thread {
-
- String Publication = "Publication";
- String publicationNamespaceValue = "http://tempuri/publication/";
- Random r = new Random ();
-
- public void run () {
- try {
- while (true) {
-
- Thread.sleep(5000);
-
- //publishing
- System.out.println("Publishing next publication...");
-
- SubscriberStore store = CommonUtil.getSubscriberStore(serviceContext.getAxisService());
- if (store==null)
- throw new Exception ("Cant find the Savan subscriber store");
-
- OMElement data = getNextPublicationData ();
-
- PublicationClient publicationClient = new PublicationClient (serviceContext.getConfigurationContext());
- publicationClient.sendPublication(data,serviceContext.getAxisService(),null);
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public OMElement getNextPublicationData () {
- OMFactory factory = OMAbstractFactory.getOMFactory();
- OMNamespace namespace = factory.createOMNamespace(publicationNamespaceValue,"ns1");
- OMElement publicationElement = factory.createOMElement(Publication,namespace);
-
- int value = r.nextInt();
- publicationElement.setText(Integer.toString(value));
-
- OMElement data = factory.createOMElement("publish",namespace);
- data.addChild(publicationElement);
-
-
- return data;
- }
- }
+
+ ServiceContext serviceContext = null;
+
+ public void init(ServiceContext serviceContext) throws AxisFault {
+ System.out.println("Eventing Service INIT called");
+ this.serviceContext = serviceContext;
+
+ PublisherThread thread = new PublisherThread();
+ thread.start();
+ }
+
+ public void dummyMethod(OMElement param) throws Exception {
+ System.out.println("Eventing Service dummy method called");
+ }
+
+ private class PublisherThread extends Thread {
+
+ String Publication = "Publication";
+ String publicationNamespaceValue = "http://tempuri/publication/";
+ Random r = new Random();
+
+ public void run() {
+ try {
+ while (true) {
+
+ Thread.sleep(5000);
+
+ //publishing
+ System.out.println("Publishing next publication...");
+
+ SubscriberStore store =
+ CommonUtil.getSubscriberStore(serviceContext.getAxisService());
+ if (store == null)
+ throw new Exception("Cant find the Savan subscriber store");
+
+ OMElement data = getNextPublicationData();
+
+ PublicationClient publicationClient =
+ new PublicationClient(serviceContext.getConfigurationContext());
+ publicationClient.sendPublication(data, serviceContext.getAxisService(), null);
+ }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public OMElement getNextPublicationData() {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMNamespace namespace = factory.createOMNamespace(publicationNamespaceValue, "ns1");
+ OMElement publicationElement = factory.createOMElement(Publication, namespace);
+
+ int value = r.nextInt();
+ publicationElement.setText(Integer.toString(value));
+
+ OMElement data = factory.createOMElement("publish", namespace);
+ data.addChild(publicationElement);
+
+
+ return data;
+ }
+ }
}
diff --git a/modules/samples/pom.xml b/modules/samples/pom.xml
index 3d9f79f..1a05b04 100755
--- a/modules/samples/pom.xml
+++ b/modules/samples/pom.xml
@@ -2,58 +2,58 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.ws.savan</groupId>
- <artifactId>savan-parent</artifactId>
- <version>SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
+ <parent>
<groupId>org.apache.ws.savan</groupId>
- <artifactId>savan-samples</artifactId>
- <packaging>jar</packaging>
- <name>Savan - Samples</name>
+ <artifactId>savan-parent</artifactId>
+ <version>SNAPSHOT</version>
+ </parent>
- <dependencies>
- <dependency>
- <groupId>org.apache.ws.savan</groupId>
- <artifactId>savan-core</artifactId>
- <version>SNAPSHOT</version>
- </dependency>
- </dependencies>
-
- <build>
- <sourceDirectory>eventing/src</sourceDirectory>
- <testSourceDirectory>eventing/src</testSourceDirectory>
- <resources>
- <resource>
- <directory>eventing</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- <!--
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <inherited>true</inherited>
- <configuration>
- <skip>false</skip>
- <excludes>
- <exclude>**/*Abstract*.java</exclude>
- <exclude>**/*Util*.java</exclude>
- <exclude>**/AtomTest.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- -->
- </plugins>
- </build>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ws.savan</groupId>
+ <artifactId>savan-samples</artifactId>
+ <packaging>jar</packaging>
+ <name>Savan - Samples</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ws.savan</groupId>
+ <artifactId>savan-core</artifactId>
+ <version>SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <sourceDirectory>eventing/src</sourceDirectory>
+ <testSourceDirectory>eventing/src</testSourceDirectory>
+ <resources>
+ <resource>
+ <directory>eventing</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ <!--
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <skip>false</skip>
+ <excludes>
+ <exclude>**/*Abstract*.java</exclude>
+ <exclude>**/*Util*.java</exclude>
+ <exclude>**/AtomTest.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ -->
+ </plugins>
+ </build>
</project>