You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by bi...@apache.org on 2020/04/16 07:38:53 UTC
[axis-axis2-java-savan] 02/03: Created a copy of the current
codebase - some users may need this
This is an automated email from the ASF dual-hosted git repository.
billblough pushed a commit to branch java
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-savan.git
commit 8637b0a4c6de0c10cfcb76982be43847d699552b
Author: Chamikara Madhusanka Jayalath <ch...@apache.org>
AuthorDate: Sun May 20 03:08:42 2007 +0000
Created a copy of the current codebase - some users may need this
---
development/savan_old/pom.xml | 217 +++++++++++
.../savan_old/src/main/config/savan-config.xml | 61 +++
.../java/org/apache/savan/MessageInitializer.java | 26 ++
.../main/java/org/apache/savan/SavanConstants.java | 62 +++
.../main/java/org/apache/savan/SavanException.java | 39 ++
.../java/org/apache/savan/SavanMessageContext.java | 106 ++++++
.../savan/configuration/ConfigurationManager.java | 423 +++++++++++++++++++++
.../org/apache/savan/configuration/FilterBean.java | 49 +++
.../apache/savan/configuration/MappingRules.java | 52 +++
.../org/apache/savan/configuration/Protocol.java | 73 ++++
.../apache/savan/configuration/SubscriberBean.java | 39 ++
.../java/org/apache/savan/eventing/Delivery.java | 45 +++
.../apache/savan/eventing/EventingConstants.java | 68 ++++
.../eventing/EventingMessageReceiverDeligater.java | 255 +++++++++++++
.../eventing/EventingSubscriptionProcessor.java | 339 +++++++++++++++++
.../apache/savan/eventing/EventingUtilFactory.java | 71 ++++
.../savan/eventing/client/EventingClient.java | 358 +++++++++++++++++
.../savan/eventing/client/EventingClientBean.java | 80 ++++
.../eventing/client/SubscriptionResponseData.java | 47 +++
.../savan/eventing/client/SubscriptionStatus.java | 34 ++
.../subscribers/EventingLeafSubscriber.java | 85 +++++
.../eventing/subscribers/EventingSubscriber.java | 52 +++
.../subscribers/EventingTopicSubscriber.java | 46 +++
.../java/org/apache/savan/filters/EmptyFilter.java | 40 ++
.../main/java/org/apache/savan/filters/Filter.java | 52 +++
.../org/apache/savan/filters/XPathBasedFilter.java | 97 +++++
.../org/apache/savan/handlers/SavanInHandler.java | 102 +++++
.../org/apache/savan/handlers/SavanOutHandler.java | 88 +++++
.../messagereceiver/MessageReceiverDeligater.java | 69 ++++
.../SavanInOnlyMessageReceiver.java | 35 ++
.../messagereceiver/SavanInOutMessageReceiver.java | 63 +++
.../java/org/apache/savan/module/SavanModule.java | 81 ++++
.../savan/publication/PublicationReport.java | 65 ++++
.../publication/client/PublicationClient.java | 107 ++++++
.../savan/storage/DefaultSubscriberStore.java | 63 +++
.../org/apache/savan/storage/SubscriberStore.java | 70 ++++
.../savan/subscribers/AbstractSubscriber.java | 105 +++++
.../savan/subscribers/CompositeSubscriber.java | 65 ++++
.../apache/savan/subscribers/LeafSubscriber.java | 93 +++++
.../org/apache/savan/subscribers/Subscriber.java | 100 +++++
.../apache/savan/subscription/ExpirationBean.java | 65 ++++
.../org/apache/savan/subscription/RenewBean.java | 42 ++
.../savan/subscription/SubscriptionProcessor.java | 102 +++++
.../java/org/apache/savan/util/CommonUtil.java | 90 +++++
.../org/apache/savan/util/ProtocolManager.java | 42 ++
.../java/org/apache/savan/util/UtilFactory.java | 38 ++
.../src/main/resources/META-INF/module.xml | 24 ++
development/savan_old/src/site/site.xml | 34 ++
.../savan_old/src/site/xdoc/savan-tutorial.xml | 14 +
.../axis2/savan/CompositeSubscriberTest.java | 61 +++
.../axis2/savan/ConfigurationManagerTest.java | 44 +++
.../axis2/savan/ConpositeSubscriberTest.java | 54 +++
.../axis2/savan/EventingExpirationTypesTest.java | 82 ++++
.../savan/EventingSubscripitonProcessorTest.java | 162 ++++++++
.../apache/axis2/savan/XPathBasedFilterTest.java | 69 ++++
.../src/test/resources/eventing-renew-datetime.xml | 14 +
.../src/test/resources/eventing-renew-duration.xml | 14 +
.../src/test/resources/eventing-subscription.xml | 28 ++
.../src/test/resources/savan-config-test.xml | 61 +++
59 files changed, 4962 insertions(+)
diff --git a/development/savan_old/pom.xml b/development/savan_old/pom.xml
new file mode 100644
index 0000000..5b49568
--- /dev/null
+++ b/development/savan_old/pom.xml
@@ -0,0 +1,217 @@
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ 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">
+
+ <groupId>org.apache.savan</groupId>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>savan</artifactId>
+ <packaging>jar</packaging>
+ <version>SNAPSHOT</version>
+
+ <name>Apache Savan</name>
+ <url>http://ws.apache.org/savan/</url>
+
+ <developers>
+ <developer>
+ <name>Davanam Srinivas</name>
+ <email>dims@wso2.com</email>
+ </developer>
+ <developer>
+ <name>Chamikara Jayalath</name>
+ <email>chamikara@wso2.com</email>
+ </developer>
+ </developers>
+
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ <distribution>repo</distribution>
+ </license>
+ </licenses>
+
+ <issueManagement>
+ <system>JRIA</system>
+ <url>https://issues.apache.org/jira/</url>
+ </issueManagement>
+
+ <mailingLists>
+ <mailingList>
+ <name>Apache Savan project mailing list</name>
+ <subscribe>savan-dev-subscribe@ws.apache.org</subscribe>
+ <unsubscribe>savan-dev-unsubscribe@ws.apache.org</unsubscribe>
+ <post>savan-dev@ws.apache.org</post>
+ </mailingList>
+ </mailingLists>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/webservices/savan/trunk/java</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/webservices/savan/trunk/java</developerConnection>
+ <url>http://svn.apache.org/viewvc/webservices/savan</url>
+ </scm>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jxr-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <distributionManagement>
+ <repository>
+ <id>apache-repo</id>
+ <name>Maven Central Repository</name>
+ <url>scpexe://people.apache.org/www/www.apache.org/dist/maven-repository</url>
+ </repository>
+ <snapshotRepository>
+ <id>apache-snapshots</id>
+ <name>Apache Development Repository</name>
+ <url>scpexe://minotaur.apache.org/www/cvs.apache.org/maven-snapshot-repository</url>
+ </snapshotRepository>
+ <site>
+ <id>website</id>
+ <url>scpexe://people.apache.org/www/ws.apache.org/savan</url>
+ </site>
+
+ </distributionManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-addressing</artifactId>
+ <version>${axis2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>${axis2.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb</artifactId>
+ <version>${axis2.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>mar</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <copy file="target/savan-${savan.version}.jar"
+ tofile="target/savan-${savan.version}.mar"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>mar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>target/savan-${savan.version}.mar</file>
+ <type>mar</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>maven-snapshots</id>
+ <name>Maven Central Development Repository</name>
+ <url>http://snapshots.maven.codehaus.org/maven2</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ <repository>
+ <id>dist-wso2</id>
+ <name>WSO2 Standard Repository</name>
+ <url>http://dist.wso2.org/maven</url>
+ <layout>legacy</layout>
+ </repository>
+ <repository>
+ <id>apache-zones</id>
+ <url>http://ws.zones.apache.org/repository</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>snapshot-apache</id>
+ <name>Apache Snapshot repository</name>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </pluginRepository>
+ <pluginRepository>
+ <id>snapshot</id>
+ <name>Snapshot repository</name>
+ <url>http://snapshots.maven.codehaus.org/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <properties>
+ <axis2.version>1.2</axis2.version>
+ <savan.version>SNAPSHOT</savan.version>
+ </properties>
+
+</project>
+
diff --git a/development/savan_old/src/main/config/savan-config.xml b/development/savan_old/src/main/config/savan-config.xml
new file mode 100644
index 0000000..1773586
--- /dev/null
+++ b/development/savan_old/src/main/config/savan-config.xml
@@ -0,0 +1,61 @@
+<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>composite</name>
+ <class>org.apache.savan.subscribers.CompositeSubscriber</class>
+ </subscriber>
+ <subscriber>
+ <name>eventing-leaf</name>
+ <class>org.apache.savan.eventing.subscribers.EventingLeafSubscriber</class>
+ </subscriber>
+ <subscriber>
+ <name>eventing-topic</name>
+ <class>org.apache.savan.eventing.subscribers.EventingTopicSubscriber</class>
+ </subscriber>
+ </subscribers>
+
+</savan-config>
\ No newline at end of file
diff --git a/development/savan_old/src/main/java/org/apache/savan/MessageInitializer.java b/development/savan_old/src/main/java/org/apache/savan/MessageInitializer.java
new file mode 100644
index 0000000..ab53c1f
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/MessageInitializer.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan;
+
+public class MessageInitializer {
+
+ public static void initializeMessage (SavanMessageContext smc) {
+ //TODO fill the properties in to the SMC,
+ //For e.g. UtilFactory and the SubscriberStore
+ }
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/SavanConstants.java b/development/savan_old/src/main/java/org/apache/savan/SavanConstants.java
new file mode 100644
index 0000000..2ffc465
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/SavanConstants.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan;
+
+/**
+ * Contains the constants used by Savan
+ *
+ *
+ */
+public interface SavanConstants {
+
+ String CONFIGURATION_MANAGER = "SavanConfigurationManager"; //Property name to store the CM in the ConfigCtx.
+
+ String VALUE_TRUE = "true";
+ String VALUE_FALSE = "false";
+
+ String MESSAGE_TYPE = "SavanMessageType";
+ String PUBLICATION_MESSAGE = "SavanPublicationMessage";
+
+ 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;
+ }
+
+ interface Properties {
+ String SUBSCRIBER_STORE = "SubscriberStore";
+ }
+
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/SavanException.java b/development/savan_old/src/main/java/org/apache/savan/SavanException.java
new file mode 100644
index 0000000..5f07afa
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/SavanException.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan;
+
+import org.apache.axis2.AxisFault;
+
+/**
+ * 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);
+ }
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/SavanMessageContext.java b/development/savan_old/src/main/java/org/apache/savan/SavanMessageContext.java
new file mode 100644
index 0000000..98209ea
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/SavanMessageContext.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.Parameter;
+import org.apache.savan.configuration.Protocol;
+import org.apache.savan.storage.SubscriberStore;
+
+/**
+ * This encaptulates a Axis2 Message Context.
+ * Provide some easy methods to access Savan specific properties easily.
+ */
+public class SavanMessageContext {
+
+ MessageContext messageContext = null;
+
+ 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/development/savan_old/src/main/java/org/apache/savan/configuration/ConfigurationManager.java b/development/savan_old/src/main/java/org/apache/savan/configuration/ConfigurationManager.java
new file mode 100644
index 0000000..a0ee012
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/configuration/ConfigurationManager.java
@@ -0,0 +1,423 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.configuration;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import 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;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.subscribers.AbstractSubscriber;
+import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.util.UtilFactory;
+
+/**
+ * This is responsible for loading Savan configuration data from a resource
+ * for e.g. from a savan-config.xml fie
+ */
+public class ConfigurationManager {
+
+ private HashMap protocolMap = null;
+ private HashMap subscriberStoreNamesMap = null;
+ private 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 = "mapping-rules";
+ private final String SOAP_ACTION = "mapping-rules";
+ 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);
+
+ 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 = new MappingRules ();
+
+ Iterator actionsIterator = element.getChildrenWithName(new QName (ACTION));
+ while (actionsIterator.hasNext()) {
+ OMElement actionElement = (OMElement) actionsIterator.next();
+ String action = actionElement.getText();
+ mappingRules.addAction(action);
+ }
+
+ Iterator SOAPActionsIterator = element.getChildrenWithName(new QName (SOAP_ACTION));
+ while (SOAPActionsIterator.hasNext()) {
+ OMElement SOAPactionElement = (OMElement) SOAPActionsIterator.next();
+ String SOAPaction = SOAPactionElement.getText();
+ mappingRules.addAction(SOAPaction);
+ }
+ }
+
+ private void processSubscriberStores (OMElement element) throws SavanException {
+ Iterator subscriberStoreElementsIterator = element.getChildrenWithName(new QName (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 AbstractSubscriber 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 (AbstractSubscriber) getObject(subscriberBean.getClazz());
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/configuration/FilterBean.java b/development/savan_old/src/main/java/org/apache/savan/configuration/FilterBean.java
new file mode 100644
index 0000000..2791196
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/configuration/FilterBean.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.savan.configuration;
+
+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;
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/configuration/MappingRules.java b/development/savan_old/src/main/java/org/apache/savan/configuration/MappingRules.java
new file mode 100644
index 0000000..f12c089
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/configuration/MappingRules.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.configuration;
+
+import java.util.ArrayList;
+
+/**
+ *Encapsulates a date of a set of Mapping-Rules as defined by Savan configurations.
+ *(probably from a savan-config.xml file).
+ */
+public class MappingRules {
+
+ private ArrayList actionMap = null;
+ private ArrayList SOAPActionMap = null;
+
+ public MappingRules () {
+ actionMap = new ArrayList ();
+ SOAPActionMap = new ArrayList ();
+ }
+
+ public void addAction (String action) {
+ actionMap.add(action);
+ }
+
+ public boolean isActionPresent (String action) {
+ return actionMap.contains(action);
+ }
+
+ public void addSOAPAction (String SOAPAction) {
+ SOAPActionMap.add(SOAPAction);
+ }
+
+ public boolean isSOAPActionPresent (String SOAPAction) {
+ return SOAPActionMap.contains(SOAPAction);
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/configuration/Protocol.java b/development/savan_old/src/main/java/org/apache/savan/configuration/Protocol.java
new file mode 100644
index 0000000..c6d1df4
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/configuration/Protocol.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.configuration;
+
+import org.apache.savan.util.UtilFactory;
+
+/**
+ *Encapsulates a date of a Protocol as defined by Savan configurations.
+ *(probably from a savan-config.xml file).
+ */
+public class Protocol {
+
+ private String name;
+ private UtilFactory utilFactory;
+ private MappingRules mappingRules;
+ private String defaultSubscriber;
+ private String defaultFilter;
+
+ public String getDefaultFilter() {
+ return defaultFilter;
+ }
+
+ public String getDefaultSubscriber() {
+ return defaultSubscriber;
+ }
+
+ public void setDefaultFilter(String defaultFilter) {
+ this.defaultFilter = defaultFilter;
+ }
+
+ public void setDefaultSubscriber(String defaultSubscriber) {
+ this.defaultSubscriber = defaultSubscriber;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public UtilFactory getUtilFactory() {
+ return utilFactory;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setUtilFactory(UtilFactory utilFactory) {
+ this.utilFactory = utilFactory;
+ }
+
+ public MappingRules getMappingRules() {
+ return mappingRules;
+ }
+
+ public void setMappingRules(MappingRules mappingRule) {
+ this.mappingRules = mappingRule;
+ }
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/configuration/SubscriberBean.java b/development/savan_old/src/main/java/org/apache/savan/configuration/SubscriberBean.java
new file mode 100644
index 0000000..cad25d0
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/configuration/SubscriberBean.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.savan.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;
+ }
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/eventing/Delivery.java b/development/savan_old/src/main/java/org/apache/savan/eventing/Delivery.java
new file mode 100644
index 0000000..1beb747
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/Delivery.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.eventing;
+
+import org.apache.axis2.addressing.EndpointReference;
+
+public class Delivery {
+
+ EndpointReference deliveryEPR;
+ String deliveryMode;
+
+ public EndpointReference getDeliveryEPR() {
+ return deliveryEPR;
+ }
+
+ public String getDeliveryMode() {
+ return deliveryMode;
+ }
+
+ public void setDeliveryEPR(EndpointReference deliveryEPR) {
+ this.deliveryEPR = deliveryEPR;
+ }
+
+ public void setDeliveryMode(String deliveryMode) {
+ this.deliveryMode = deliveryMode;
+ }
+
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/eventing/EventingConstants.java b/development/savan_old/src/main/java/org/apache/savan/eventing/EventingConstants.java
new file mode 100644
index 0000000..763e1c7
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/EventingConstants.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.eventing;
+
+public interface EventingConstants {
+
+ String EVENTING_NAMESPACE = "http://schemas.xmlsoap.org/ws/2004/08/eventing";
+ String EVENTING_PREFIX = "wse";
+ String DEFAULT_DELIVERY_MODE = "http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push";
+ String DEFAULT_FILTER_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";
+ }
+
+ 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";
+ }
+
+ interface Properties {
+ String SOAPVersion = "SOAPVersion";
+ }
+
+ interface FilterDialects {
+ String XPath = "http://www.w3.org/TR/1999/REC-xpath-19991116";
+ }
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/eventing/EventingMessageReceiverDeligater.java b/development/savan_old/src/main/java/org/apache/savan/eventing/EventingMessageReceiverDeligater.java
new file mode 100644
index 0000000..ab0c6c5
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/EventingMessageReceiverDeligater.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.eventing;
+
+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.context.MessageContext;
+import org.apache.axis2.databinding.utils.ConverterUtil;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.eventing.subscribers.EventingLeafSubscriber;
+import org.apache.savan.messagereceiver.MessageReceiverDeligater;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.subscribers.AbstractSubscriber;
+import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.util.CommonUtil;
+
+
+public class EventingMessageReceiverDeligater implements MessageReceiverDeligater {
+
+ public 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);
+
+ 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));
+
+ }
+
+ 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 = 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);
+ EventingLeafSubscriber eventingSubscriber = (EventingLeafSubscriber) 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));
+ }
+
+ public 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");
+ }
+
+ EventingLeafSubscriber subscriber = (EventingLeafSubscriber) 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));
+ }
+
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/eventing/EventingSubscriptionProcessor.java b/development/savan_old/src/main/java/org/apache/savan/eventing/EventingSubscriptionProcessor.java
new file mode 100644
index 0000000..106314f
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/EventingSubscriptionProcessor.java
@@ -0,0 +1,339 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.eventing;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.databinding.types.Duration;
+import org.apache.axis2.databinding.utils.ConverterUtil;
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.configuration.ConfigurationManager;
+import org.apache.savan.configuration.Protocol;
+import org.apache.savan.configuration.SubscriberBean;
+import org.apache.savan.eventing.subscribers.EventingSubscriber;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.subscribers.AbstractSubscriber;
+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;
+
+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 {
+
+ 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);
+
+ AbstractSubscriber 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);
+
+ eventingSubscriber.setId(id);
+
+ 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;
+
+ try {
+ notifyToEPr = EndpointReferenceHelper.fromOM(notifyToElement);
+ }
+ 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;
+ }
+
+ 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;
+ }
+
+ public void doProtocolSpecificEndSubscription(Subscriber subscriber, String reason, ConfigurationContext configurationContext) throws SavanException {
+ String SOAPVersion = (String) subscriber.getProperty(EventingConstants.Properties.SOAPVersion);
+ if (SOAPVersion==null)
+ throw new SavanException ("Cant find the SOAP version of the subscriber");
+
+ SOAPFactory factory = null;
+ if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(SOAPVersion))
+ factory = OMAbstractFactory.getSOAP11Factory();
+ else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(SOAPVersion))
+ factory = OMAbstractFactory.getSOAP12Factory();
+ else
+ throw new SavanException ("The subscriber has a unknown SOAP version property set");
+
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ }
+
+ 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/development/savan_old/src/main/java/org/apache/savan/eventing/EventingUtilFactory.java b/development/savan_old/src/main/java/org/apache/savan/eventing/EventingUtilFactory.java
new file mode 100644
index 0000000..1fd326e
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/EventingUtilFactory.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.eventing;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.eventing.subscribers.EventingLeafSubscriber;
+import org.apache.savan.messagereceiver.MessageReceiverDeligater;
+import org.apache.savan.subscribers.AbstractSubscriber;
+import org.apache.savan.subscription.SubscriptionProcessor;
+import org.apache.savan.util.UtilFactory;
+
+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
+ smc.setMessageType(SavanConstants.MessageTypes.UNKNOWN);
+
+ return smc;
+ }
+
+ public SubscriptionProcessor createSubscriptionProcessor() {
+ return new EventingSubscriptionProcessor ();
+ }
+
+ public MessageReceiverDeligater createMessageReceiverDeligater() {
+ return new EventingMessageReceiverDeligater ();
+ }
+
+ public AbstractSubscriber createSubscriber() {
+ return new EventingLeafSubscriber ();
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/eventing/client/EventingClient.java b/development/savan_old/src/main/java/org/apache/savan/eventing/client/EventingClient.java
new file mode 100644
index 0000000..79bc06c
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/client/EventingClient.java
@@ -0,0 +1,358 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.eventing.client;
+
+import 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.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.databinding.types.Duration;
+import org.apache.axis2.databinding.utils.ConverterUtil;
+import org.apache.savan.eventing.EventingConstants;
+import org.apache.savan.subscription.ExpirationBean;
+import org.apache.savan.util.CommonUtil;
+
+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);
+ }
+
+ public 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);
+
+ 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/development/savan_old/src/main/java/org/apache/savan/eventing/client/EventingClientBean.java b/development/savan_old/src/main/java/org/apache/savan/eventing/client/EventingClientBean.java
new file mode 100644
index 0000000..6205655
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/client/EventingClientBean.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.eventing.client;
+
+import java.util.Date;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.databinding.types.Duration;
+
+public class EventingClientBean {
+
+ EndpointReference deliveryEPR;
+ EndpointReference endToEPR;
+ String filterDialect;
+ String filter;
+ Date expirationTime;
+ Duration expirationDuration;
+
+ public Duration getExpirationDuration() {
+ return expirationDuration;
+ }
+
+ 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/development/savan_old/src/main/java/org/apache/savan/eventing/client/SubscriptionResponseData.java b/development/savan_old/src/main/java/org/apache/savan/eventing/client/SubscriptionResponseData.java
new file mode 100644
index 0000000..95f5414
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/client/SubscriptionResponseData.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.eventing.client;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.savan.subscription.ExpirationBean;
+
+public class SubscriptionResponseData {
+
+ EndpointReference subscriptionManager = null;
+ ExpirationBean expiration = null;
+
+ public SubscriptionResponseData () {
+ expiration = new ExpirationBean ();
+ }
+
+ public EndpointReference getSubscriptionManager() {
+ return subscriptionManager;
+ }
+
+ public ExpirationBean getExpiration() {
+ return expiration;
+ }
+
+ public void setExpiration(ExpirationBean expiration) {
+ this.expiration = expiration;
+ }
+
+ public void setSubscriptionManager(EndpointReference subscriptionManager) {
+ this.subscriptionManager = subscriptionManager;
+ }
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/eventing/client/SubscriptionStatus.java b/development/savan_old/src/main/java/org/apache/savan/eventing/client/SubscriptionStatus.java
new file mode 100644
index 0000000..33075d5
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/client/SubscriptionStatus.java
@@ -0,0 +1,34 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.savan.eventing.client;
+
+public class SubscriptionStatus {
+
+ String expirationValue;
+
+ public String getExpirationValue() {
+ return expirationValue;
+ }
+
+ public void setExpirationValue(String expirationValue) {
+ this.expirationValue = expirationValue;
+ }
+
+
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/eventing/subscribers/EventingLeafSubscriber.java b/development/savan_old/src/main/java/org/apache/savan/eventing/subscribers/EventingLeafSubscriber.java
new file mode 100644
index 0000000..85ffdf8
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/subscribers/EventingLeafSubscriber.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.eventing.subscribers;
+
+import javax.xml.namespace.QName;
+
+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.MessageContext;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.eventing.Delivery;
+import org.apache.savan.subscribers.LeafSubscriber;
+
+public class EventingLeafSubscriber extends LeafSubscriber implements EventingSubscriber {
+
+ private EndpointReference endToEPr;
+
+ private Delivery delivery;
+
+ public Delivery getDelivery() {
+ return delivery;
+ }
+
+ public EndpointReference getEndToEPr() {
+ return endToEPr;
+ }
+
+ public void setDelivery(Delivery delivery) {
+ this.delivery = delivery;
+ }
+
+ public void setEndToEPr(EndpointReference errorReportingEPR) {
+ this.endToEPr = errorReportingEPR;
+ }
+
+ public void doProtocolSpecificPublication(SavanMessageContext publication) throws SavanException {
+
+ EndpointReference deliveryEPR = delivery.getDeliveryEPR();
+
+ try {
+ ServiceClient sc = new ServiceClient (publication.getConfigurationContext(),null);
+
+ Options options = publication.getMessageContext().getOptions();
+ if (options==null) {
+ options = new Options ();
+ }
+
+ sc.engageModule(new QName ("addressing"));
+
+ options.setProperty("xmppasync", "true");
+ sc.setOptions(options);
+
+ options.setTo(deliveryEPR);
+ MessageContext mc = new MessageContext ();
+ mc.setEnvelope(publication.getEnvelope());
+ OperationClient client = sc.createClient(ServiceClient.ANON_OUT_ONLY_OP);
+ client.addMessageContext(mc);
+ client.execute(true);
+ } catch (AxisFault e) {
+ throw new SavanException (e);
+ }
+
+
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/eventing/subscribers/EventingSubscriber.java b/development/savan_old/src/main/java/org/apache/savan/eventing/subscribers/EventingSubscriber.java
new file mode 100644
index 0000000..81059cd
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/subscribers/EventingSubscriber.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.savan.eventing.subscribers;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.savan.eventing.Delivery;
+import org.apache.savan.subscribers.Subscriber;
+
+/**
+ * Defines methods common to all eventing subscribers.
+ */
+public interface EventingSubscriber extends Subscriber {
+
+ /**
+ * To get the EndTo EPR
+ * @return
+ */
+ EndpointReference getEndToEPr();
+
+ /**
+ * To get the Delivery object
+ * @return
+ */
+ Delivery getDelivery();
+
+ /**
+ * To se the Delivery object
+ * @param delivery
+ */
+ void setDelivery(Delivery delivery);
+
+ /**
+ * To set the EndTo EPR
+ * @param errorReportingEPR
+ */
+ void setEndToEPr(EndpointReference errorReportingEPR);
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/eventing/subscribers/EventingTopicSubscriber.java b/development/savan_old/src/main/java/org/apache/savan/eventing/subscribers/EventingTopicSubscriber.java
new file mode 100644
index 0000000..b0f7646
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/eventing/subscribers/EventingTopicSubscriber.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.savan.eventing.subscribers;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.savan.eventing.Delivery;
+import org.apache.savan.subscribers.CompositeSubscriber;
+
+public class EventingTopicSubscriber extends CompositeSubscriber implements EventingSubscriber {
+
+ private EndpointReference endToEPr;
+
+ private Delivery delivery;
+
+ public Delivery getDelivery() {
+ return delivery;
+ }
+
+ public EndpointReference getEndToEPr() {
+ return endToEPr;
+ }
+
+ public void setDelivery(Delivery delivery) {
+ this.delivery = delivery;
+ }
+
+ public void setEndToEPr(EndpointReference errorReportingEPR) {
+ this.endToEPr = errorReportingEPR;
+ }
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/filters/EmptyFilter.java b/development/savan_old/src/main/java/org/apache/savan/filters/EmptyFilter.java
new file mode 100644
index 0000000..46e2f68
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/filters/EmptyFilter.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.savan.filters;
+
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.savan.SavanException;
+
+/**
+ * This filter does not do any affective filtering.
+ * May be the default for some protocols.
+ */
+public class EmptyFilter extends Filter {
+
+ public boolean checkEnvelopeCompliance(SOAPEnvelope envelope) throws SavanException {
+ return true;
+ }
+
+ public Object getFilterValue() {
+ return null;
+ }
+
+ public void setUp(OMNode element) {
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/filters/Filter.java b/development/savan_old/src/main/java/org/apache/savan/filters/Filter.java
new file mode 100644
index 0000000..26ccab2
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/filters/Filter.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.filters;
+
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.savan.SavanException;
+
+/**
+ * Defines a filter used by Savan.
+ *
+ */
+public abstract class Filter {
+
+ /**
+ * To check weather the passed envelope is compliant with the current filter.
+ * @param envelope
+ * @return
+ * @throws SavanException
+ */
+ public abstract boolean checkEnvelopeCompliance (SOAPEnvelope envelope) throws SavanException;
+
+ /**
+ * To initialize the filter. The filter value should be sent to the argument
+ * (for e.g. As a OMText for a String)
+ *
+ * @param element
+ */
+ public abstract void setUp (OMNode element);
+
+ /**
+ * Returns a previously set filter value.
+ *
+ * @return
+ */
+ public abstract Object getFilterValue ();
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/filters/XPathBasedFilter.java b/development/savan_old/src/main/java/org/apache/savan/filters/XPathBasedFilter.java
new file mode 100644
index 0000000..97680b1
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/filters/XPathBasedFilter.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.filters;
+
+import java.util.List;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.savan.SavanException;
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import org.jaxen.JaxenException;
+
+/**
+ * A filter that does filtering of messages based on a XPath string.
+ *
+ */
+public class XPathBasedFilter extends Filter {
+
+ private String XPathString = null;
+
+ public String getXPathString() {
+ return XPathString;
+ }
+
+ public void setXPathString(String XPathString) {
+ this.XPathString = XPathString;
+ }
+
+ /**
+ * This method may fail due to the JIRA issues WS-Commons(40) amd WS-Commons (41)
+ */
+ public boolean checkEnvelopeCompliance(SOAPEnvelope envelope) throws SavanException {
+ OMElement firstChild = envelope.getBody().getFirstElement();
+ if (firstChild==null)
+ return false;
+
+ if (XPathString==null)
+ return true;
+
+ try {
+ AXIOMXPath xpath = new AXIOMXPath (XPathString);
+ List resultList = xpath.selectNodes(firstChild);
+
+ return resultList.size() > 0;
+ } 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 Object getFilterValue() {
+ return XPathString;
+ }
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/handlers/SavanInHandler.java b/development/savan_old/src/main/java/org/apache/savan/handlers/SavanInHandler.java
new file mode 100644
index 0000000..2b461f5
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/handlers/SavanInHandler.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.handlers;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.configuration.ConfigurationManager;
+import org.apache.savan.configuration.Protocol;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.subscription.SubscriptionProcessor;
+import org.apache.savan.util.UtilFactory;
+import org.apache.savan.util.ProtocolManager;
+
+/**
+ * The handler of Savan in the InFlow.
+ * Will handle the control messages like subscription, renew, unsubscription.
+ *
+ */
+public class SavanInHandler extends AbstractHandler {
+
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+ SavanMessageContext smc = new SavanMessageContext (msgContext);
+
+ //setting the Protocol
+ Protocol protocol = ProtocolManager.getMessageProtocol(smc);
+ smc.setProtocol(protocol);
+
+ AxisService axisService = msgContext.getAxisService();
+ if (axisService==null)
+ throw new SavanException ("Service context is null");
+
+ //setting the 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);
+ }
+ return InvocationResponse.CONTINUE;
+ }
+
+ 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);
+ }
+
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/handlers/SavanOutHandler.java b/development/savan_old/src/main/java/org/apache/savan/handlers/SavanOutHandler.java
new file mode 100644
index 0000000..12bae9c
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/handlers/SavanOutHandler.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.savan.handlers;
+
+import java.util.Iterator;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.publication.PublicationReport;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.subscribers.AbstractSubscriber;
+import org.apache.savan.util.CommonUtil;
+
+/**
+ * Handler of Savan in the outFlow.
+ * Notification messages should go through this handler and this will sent them to
+ * each subscriber based on their filter.
+ *
+ */
+public class SavanOutHandler extends AbstractHandler {
+
+ Log log = LogFactory.getLog(SavanOutHandler.class);
+
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+
+ SavanMessageContext smc = new SavanMessageContext (msgContext);
+ int messagetype = smc.getMessageType();
+
+ //TODO hv a better method to identify publication messages
+ if (messagetype == SavanConstants.MessageTypes.UNKNOWN) {
+ SavanMessageContext publication = new SavanMessageContext(msgContext);
+ SubscriberStore store = CommonUtil.getSubscriberStore(msgContext.getAxisService());
+ if (store != null) {
+
+ //building the publication envelope
+ msgContext.getEnvelope().build();
+
+ //this tell addressing to polulate the SOAP envelope with the new values set in the options object
+ //(i.e. by removing old headers) every time the message sent through it.
+ msgContext.setProperty(AddressingConstants.REPLACE_ADDRESSING_HEADERS, Boolean.TRUE);
+
+ PublicationReport report = new PublicationReport();
+ Iterator iterator = store.retrieveAll();
+ while (iterator.hasNext()) {
+ AbstractSubscriber subscriber = (AbstractSubscriber) iterator.next();
+ try {
+ subscriber.processPublication (publication, report);
+ } catch (SavanException e) {
+ report.addErrorReportEntry(subscriber.getId(),e);
+ e.printStackTrace();
+ }
+
+ //TODO do something with the report.
+ }
+ } else {
+ String message = "Couldnt send the message since the subscriber storage was not found";
+ log.debug(message);
+ }
+
+ msgContext.pause();
+ return InvocationResponse.SUSPEND;
+ }
+ return InvocationResponse.CONTINUE;
+
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/messagereceiver/MessageReceiverDeligater.java b/development/savan_old/src/main/java/org/apache/savan/messagereceiver/MessageReceiverDeligater.java
new file mode 100644
index 0000000..614001f
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/messagereceiver/MessageReceiverDeligater.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.messagereceiver;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+
+/**
+ * Provide abstract functions that may be done by protocols at the MessageReceiver level.
+ *
+ */
+public interface MessageReceiverDeligater {
+
+ /**
+ * Handles a subscription request at the MessageReceiver level.
+ * (may possibly send a subscription response).
+ *
+ * @param subscriptionMessage
+ * @param outMessage
+ * @throws SavanException
+ */
+ void handleSubscriptionRequest (SavanMessageContext subscriptionMessage, MessageContext outMessage) throws SavanException ;
+
+ /**
+ * Handles a renew request at the MessageReceiver level.
+ * (may possibly send a renew response)
+ *
+ * @param renewMessage
+ * @param outMessage
+ * @throws SavanException
+ */
+ void handleRenewRequest(SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException;
+
+ /**
+ * Handles an EndSubscription request at the MessageReceiver level.
+ * (may possibly send a EndSubscription response)
+ *
+ * @param renewMessage
+ * @param outMessage
+ * @throws SavanException
+ */
+ void handleEndSubscriptionRequest(SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException;
+
+ /**
+ * Handles a GetStatus request at the MessageReceiver level.
+ * (may possibly send a GetStatus response).
+ *
+ * @param renewMessage
+ * @param outMessage
+ * @throws SavanException
+ */
+ void handleGetStatusRequest (SavanMessageContext renewMessage, MessageContext outMessage) throws SavanException;
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java b/development/savan_old/src/main/java/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java
new file mode 100644
index 0000000..c8970a0
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/messagereceiver/SavanInOnlyMessageReceiver.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.messagereceiver;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractInMessageReceiver;
+
+/**
+ * InOnly message deceiver for Savan.
+ * May get called for control messages depending on the protocol.
+ *
+ */
+public class SavanInOnlyMessageReceiver extends AbstractInMessageReceiver {
+
+ public void invokeBusinessLogic(MessageContext inMessage) throws AxisFault {
+ }
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java b/development/savan_old/src/main/java/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java
new file mode 100644
index 0000000..45ae436
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/messagereceiver/SavanInOutMessageReceiver.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.messagereceiver;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.configuration.Protocol;
+import org.apache.savan.util.UtilFactory;
+
+/**
+ * InOut message deceiver for Savan.
+ * May get called for control messages depending on the protocol.
+ */
+public class SavanInOutMessageReceiver extends AbstractInOutSyncMessageReceiver {
+
+ public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMessage) throws AxisFault {
+
+ SavanMessageContext savanInMessage = new SavanMessageContext (inMessage);
+
+// Integer protocolVersion = (Integer) inMessage.getProperty(SavanConstants.PROTOCOL_VERSION);
+// UtilFactory utilFactory = AbstractSavanUtilFactory.getUtilFactory(protocolVersion.intValue());
+
+ Protocol protocol = savanInMessage.getProtocol();
+ if (protocol==null) {
+ throw new SavanException ("Protocol not found");
+ }
+
+ UtilFactory utilFactory = protocol.getUtilFactory();
+ MessageReceiverDeligater deligator = utilFactory.createMessageReceiverDeligater();
+
+ int messageType = savanInMessage.getMessageType();
+ if (messageType==SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE) {
+ deligator.handleSubscriptionRequest(savanInMessage,outMessage);
+ } else if (messageType==SavanConstants.MessageTypes.RENEW_MESSAGE) {
+ deligator.handleRenewRequest (savanInMessage,outMessage);
+ } else if (messageType==SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE) {
+ deligator.handleEndSubscriptionRequest (savanInMessage,outMessage);
+ } else if (messageType==SavanConstants.MessageTypes.GET_STATUS_MESSAGE) {
+ deligator.handleGetStatusRequest (savanInMessage,outMessage);
+ }
+
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/module/SavanModule.java b/development/savan_old/src/main/java/org/apache/savan/module/SavanModule.java
new file mode 100644
index 0000000..16a7ab4
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/module/SavanModule.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.module;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+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;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+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 {
+
+ 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
+
+ //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(moduleClassLoader);
+ } 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
+ }
+
+ public boolean canSupportAssertion(Assertion assertion) {
+ // TODO
+ return true;
+ }
+
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/publication/PublicationReport.java b/development/savan_old/src/main/java/org/apache/savan/publication/PublicationReport.java
new file mode 100644
index 0000000..2c03308
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/publication/PublicationReport.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.publication;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import org.apache.savan.SavanException;
+
+/**
+ * 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);
+ }
+
+ public Hashtable getErrors() {
+ return errors;
+ }
+
+ public ArrayList getNotifiedSubscribers() {
+ return notifiedSubscribers;
+ }
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/publication/client/PublicationClient.java b/development/savan_old/src/main/java/org/apache/savan/publication/client/PublicationClient.java
new file mode 100644
index 0000000..db77841
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/publication/client/PublicationClient.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.publication.client;
+
+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.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.util.CommonUtil;
+
+/**
+ * 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 publication - 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)
+ * @throws SavanException
+ */
+ public void sendPublication (OMElement publication, AxisService service) throws SavanException {
+
+ try {
+ ServiceClient sc = new ServiceClient (configurationContext,null);
+ Options options = new Options ();
+ sc.setOptions(options);
+
+ //Just a matter of getting it to the SavanOutHandler
+ options.setTo(new EndpointReference ("http://temp.publication.URI"));
+
+ if (options.getAction()==null)
+ options.setAction(TEMP_PUBLICATION_ACTION);
+
+ sc.setOptions(options);
+
+ //this will not be required when the
+ Parameter parameter = new Parameter ();
+ parameter.setName(SavanConstants.SUBSCRIBER_STORE);
+ SubscriberStore store = CommonUtil.getSubscriberStore(service);
+ parameter.setValue(store);
+ sc.getAxisService().addParameter(parameter);
+
+ //if already engaged, axis2 will neglect this engagement.
+ sc.engageModule( new QName("savan"));
+
+ MessageContext mc = new MessageContext ();
+ mc.setEnvelope(getEnvelopeFromPublication (publication));
+ OperationClient client = sc.createClient(ServiceClient.ANON_OUT_ONLY_OP);
+ client.addMessageContext(mc);
+ client.execute(true);
+ } catch (AxisFault e) {
+ String message = "Could not send the publication";
+ throw new SavanException (message,e);
+ }
+ }
+
+
+ private SOAPEnvelope getEnvelopeFromPublication (OMElement element) {
+
+ //for now we are sending SOAP 1.1
+ SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+ envelope.getBody().addChild(element);
+
+ return envelope;
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/storage/DefaultSubscriberStore.java b/development/savan_old/src/main/java/org/apache/savan/storage/DefaultSubscriberStore.java
new file mode 100644
index 0000000..38cceef
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/storage/DefaultSubscriberStore.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.storage;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.savan.SavanException;
+import org.apache.savan.subscribers.AbstractSubscriber;
+import org.apache.savan.subscribers.Subscriber;
+
+public class DefaultSubscriberStore implements SubscriberStore {
+
+ private HashMap subscriberMap = null;
+
+ public DefaultSubscriberStore () {
+ subscriberMap = new HashMap ();
+ }
+
+ public void init(ConfigurationContext configurationContext) throws SavanException {
+ // TODO Auto-generated method stub
+ }
+
+ public Subscriber retrieve(String id) {
+ return (AbstractSubscriber) subscriberMap.get(id);
+ }
+
+ public void store(Subscriber s) {
+ subscriberMap.put(s.getId(),s);
+ }
+
+ public void delete(String subscriberID) {
+ subscriberMap.remove(subscriberID);
+ }
+
+ public Iterator retrieveAll() {
+ ArrayList allSubscribers = new ArrayList ();
+ for (Iterator iter=subscriberMap.keySet().iterator();iter.hasNext();) {
+ Object key = iter.next();
+ allSubscribers.add(subscriberMap.get(key));
+ }
+ return allSubscribers.iterator();
+ }
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/storage/SubscriberStore.java b/development/savan_old/src/main/java/org/apache/savan/storage/SubscriberStore.java
new file mode 100644
index 0000000..33995d1
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/storage/SubscriberStore.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.savan.storage;
+
+import java.util.Iterator;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.savan.SavanException;
+import org.apache.savan.subscribers.Subscriber;
+
+/**
+ * Defines the Storage for storing subscribers.
+ */
+public interface SubscriberStore {
+
+ /**
+ * To Initialize the storage.
+ *
+ * @param configurationContext
+ * @throws SavanException
+ */
+ void init (ConfigurationContext configurationContext) throws SavanException;
+
+ /**
+ * To store the subscriber.
+ *
+ * @param s
+ * @throws SavanException
+ */
+ void store (Subscriber s) throws SavanException;
+
+ /**
+ * To retrieve a previously stored subscriber.
+ *
+ * @param subscriberID
+ * @return
+ * @throws SavanException
+ */
+ Subscriber retrieve (String subscriberID) throws SavanException;
+
+ /**
+ * To retrieve all subscribers stored upto now.
+ *
+ * @return
+ * @throws SavanException
+ */
+ Iterator retrieveAll () throws SavanException;
+
+ /**
+ * To delete a previously stored subscriber.
+ *
+ * @param subscriberID
+ * @throws SavanException
+ */
+ void delete (String subscriberID) throws SavanException;
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/subscribers/AbstractSubscriber.java b/development/savan_old/src/main/java/org/apache/savan/subscribers/AbstractSubscriber.java
new file mode 100644
index 0000000..e21c77b
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/subscribers/AbstractSubscriber.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.subscribers;
+
+import java.util.Date;
+import java.util.HashMap;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.publication.PublicationReport;
+import org.apache.savan.subscription.ExpirationBean;
+
+/**
+ * Defines a subscriber which is the entity that define a specific subscription
+ * in savan. Independent of the protocol type.
+ *
+ */
+public abstract class AbstractSubscriber implements Subscriber {
+
+ String id;
+ Filter filter = null;
+ HashMap properties = null;
+
+ public AbstractSubscriber () {
+ properties = new HashMap ();
+ }
+
+ public void addProperty (String key, Object value) {
+ properties.put(key,value);
+ }
+
+ public Object getProperty (String key) {
+ return properties.get(key);
+ }
+
+ public Filter getFilter() {
+ return filter;
+ }
+
+ public void setFilter(Filter filter) {
+ this.filter = filter;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public boolean doesMessageBelongToTheFilter(SavanMessageContext smc) throws SavanException {
+ if (filter!=null) {
+ SOAPEnvelope envelope = smc.getEnvelope();
+ return filter.checkEnvelopeCompliance(envelope);
+ } else
+ return true;
+ }
+
+ /**
+ * This method first checks weather the passed message complies with the current filter.
+ * If so message is sent, and the subscriberID is added to the PublicationReport.
+ * Else message is ignored.
+ *
+ * @param smc
+ * @param report
+ * @throws SavanException
+ */
+ public void processPublication (SavanMessageContext publication,PublicationReport report) throws SavanException {
+ if (doesMessageBelongToTheFilter(publication)) {
+ sendPublication(publication,report);
+ if (getId()!=null)
+ report.addNotifiedSubscriber(getId());
+ }
+ }
+
+ public abstract void setSubscriptionEndingTime (Date subscriptionEndingTime);
+ public abstract void renewSubscription (ExpirationBean bean);
+
+ /**
+ * This should be used by based classes to sendThe publication in its own manner
+ *
+ * @param publication
+ * @param report
+ * @throws SavanException
+ */
+ protected abstract void sendPublication (SavanMessageContext publication,PublicationReport report) throws SavanException;
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/subscribers/CompositeSubscriber.java b/development/savan_old/src/main/java/org/apache/savan/subscribers/CompositeSubscriber.java
new file mode 100644
index 0000000..adea44a
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/subscribers/CompositeSubscriber.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.subscribers;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.publication.PublicationReport;
+import org.apache.savan.subscription.ExpirationBean;
+
+/**
+ * Defines a set of subscribers that are acting as a group or a Topic.
+ *
+ */
+public class CompositeSubscriber extends AbstractSubscriber {
+
+ ArrayList subscribers = null;
+
+ public CompositeSubscriber (){
+ subscribers = new ArrayList ();
+ }
+
+ public void addSubscriber (AbstractSubscriber subscriber) {
+ subscribers.add(subscriber);
+ }
+
+ public void sendPublication(SavanMessageContext publication, PublicationReport report) throws SavanException {
+ for (Iterator it = subscribers.iterator();it.hasNext();) {
+ AbstractSubscriber subscriber = (AbstractSubscriber) it.next();
+ subscriber.processPublication(publication,report);
+ }
+ }
+
+ public void renewSubscription(ExpirationBean bean) {
+ for (Iterator it = subscribers.iterator();it.hasNext();) {
+ AbstractSubscriber subscriber = (AbstractSubscriber) it.next();
+ subscriber.renewSubscription(bean);
+ }
+ }
+
+ public void setSubscriptionEndingTime(Date subscriptionEndingTime) {
+ for (Iterator it = subscribers.iterator();it.hasNext();) {
+ AbstractSubscriber subscriber = (AbstractSubscriber) it.next();
+ subscriber.setSubscriptionEndingTime(subscriptionEndingTime);
+ }
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/subscribers/LeafSubscriber.java b/development/savan_old/src/main/java/org/apache/savan/subscribers/LeafSubscriber.java
new file mode 100644
index 0000000..a7e6fdb
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/subscribers/LeafSubscriber.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.subscribers;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.module.SavanModule;
+import org.apache.savan.publication.PublicationReport;
+import org.apache.savan.subscription.ExpirationBean;
+import org.apache.savan.util.CommonUtil;
+
+/**
+ *Defines a single node subscriber.
+ *
+ */
+public abstract class LeafSubscriber extends AbstractSubscriber {
+
+ private static final Log log = LogFactory.getLog(LeafSubscriber.class);
+
+ /**
+ * The time at which further notification of messages should be avaoded
+ * to this subscriber.
+ */
+ private Date subscriptionEndingTime = null;
+
+ 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 Date getSubscriptionEndingTime () {
+ return subscriptionEndingTime;
+ }
+
+ public void setSubscriptionEndingTime () {
+
+ }
+
+ public void sendPublication(SavanMessageContext publication,PublicationReport report) throws SavanException {
+ 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);
+
+ //TODO inform in some other manner than sending an exception.
+// throw new SavanException (message);
+ }
+
+ doProtocolSpecificPublication (publication);
+ }
+
+ public void setSubscriptionEndingTime(Date subscriptionEndingTime) {
+ this.subscriptionEndingTime = subscriptionEndingTime;
+ }
+
+ public abstract void doProtocolSpecificPublication (SavanMessageContext publication) throws SavanException;
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/subscribers/Subscriber.java b/development/savan_old/src/main/java/org/apache/savan/subscribers/Subscriber.java
new file mode 100644
index 0000000..17691d7
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/subscribers/Subscriber.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.savan.subscribers;
+
+import java.util.Date;
+
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.publication.PublicationReport;
+import org.apache.savan.subscription.ExpirationBean;
+
+/**
+ * Defines methods common to all subscribers.
+ */
+public interface Subscriber {
+
+ /**
+ * To get the Filter object
+ * @return
+ */
+ Filter getFilter ();
+
+ /**
+ * To set the Filter object
+ * @param filter
+ */
+ void setFilter (Filter filter);
+
+ /**
+ * To get the subscriber Id.
+ * @return
+ */
+ String getId ();
+
+ /**
+ * To set the subscriber Id
+ * @param id
+ */
+ void setId (String id);
+
+ /**
+ * To add a property to the subscriber.
+ *
+ * @param key
+ * @param value
+ */
+ void addProperty (String key, Object value);
+
+ /**
+ * To get a property from the Subscriber.
+ *
+ * @param key
+ * @return
+ */
+ public Object getProperty (String key);
+
+ /**
+ * To check weather a certain message complies with the filter.
+ *
+ * @param smc
+ * @return
+ * @throws SavanException
+ */
+ boolean doesMessageBelongToTheFilter (SavanMessageContext smc) throws SavanException;
+
+
+ void processPublication (SavanMessageContext publication,PublicationReport report) throws SavanException;
+
+ /**
+ * To set the Subscription expiration time.
+ *
+ * @param subscriptionEndingTime
+ */
+ void setSubscriptionEndingTime (Date subscriptionEndingTime);
+
+ /**
+ * To renew a subscription.
+ *
+ * @param bean
+ */
+ void renewSubscription (ExpirationBean bean);
+
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/subscription/ExpirationBean.java b/development/savan_old/src/main/java/org/apache/savan/subscription/ExpirationBean.java
new file mode 100644
index 0000000..7969429
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/subscription/ExpirationBean.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.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.
+ */
+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;
+ }
+
+ 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/development/savan_old/src/main/java/org/apache/savan/subscription/RenewBean.java b/development/savan_old/src/main/java/org/apache/savan/subscription/RenewBean.java
new file mode 100644
index 0000000..5f0b3ae
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/subscription/RenewBean.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.subscription;
+
+/**
+ * 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;
+ }
+
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/subscription/SubscriptionProcessor.java b/development/savan_old/src/main/java/org/apache/savan/subscription/SubscriptionProcessor.java
new file mode 100644
index 0000000..abb398a
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/subscription/SubscriptionProcessor.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.subscription;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ServiceContext;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.storage.SubscriberStore;
+import org.apache.savan.subscribers.AbstractSubscriber;
+import org.apache.savan.subscribers.Subscriber;
+import org.apache.savan.util.CommonUtil;
+
+/**
+ * Abstractly defines subscription methods.
+ * Each protocol may extend this to add its own work.
+ */
+public abstract class SubscriptionProcessor {
+
+ public abstract void init (SavanMessageContext smc) throws SavanException;
+
+ public void unsubscribe(SavanMessageContext endSubscriptionMessage) throws SavanException {
+ 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);
+ AbstractSubscriber subscriber = (AbstractSubscriber) 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 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;
+
+ public abstract void doProtocolSpecificEndSubscription (Subscriber subscriber,String reason,ConfigurationContext configurationContext) throws SavanException;
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/util/CommonUtil.java b/development/savan_old/src/main/java/org/apache/savan/util/CommonUtil.java
new file mode 100644
index 0000000..9c61277
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/util/CommonUtil.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.util;
+
+import 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.impl.llom.factory.OMXMLBuilderFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
+import org.apache.axis2.databinding.types.Duration;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.storage.SubscriberStore;
+
+/**
+ * A common set of methods that may be used in various places of Savan.
+ */
+public class CommonUtil {
+
+ public static Calendar addDurationToCalendar (Calendar calendar,Duration duration) {
+ 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;
+ FileReader reader = new FileReader(fullName);
+ XMLStreamReader streamReader = XMLInputFactory.newInstance().createXMLStreamReader(
+ reader);
+ StAXSOAPModelBuilder builder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
+ 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 SubscriberStore getSubscriberStore (AxisService axisService) {
+ Parameter parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
+ if (parameter==null)
+ return null;
+
+ return (SubscriberStore) parameter.getValue();
+ }
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/util/ProtocolManager.java b/development/savan_old/src/main/java/org/apache/savan/util/ProtocolManager.java
new file mode 100644
index 0000000..fa280b5
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/util/ProtocolManager.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.util;
+
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.configuration.ConfigurationManager;
+import org.apache.savan.configuration.Protocol;
+
+/**
+ * Utility class to extract the Protocol type from a MessageContext
+ */
+public class ProtocolManager {
+
+ public static 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");
+
+ return (Protocol) configurationManager.getProtocolMap().get("eventing");
+
+ }
+
+}
diff --git a/development/savan_old/src/main/java/org/apache/savan/util/UtilFactory.java b/development/savan_old/src/main/java/org/apache/savan/util/UtilFactory.java
new file mode 100644
index 0000000..4b73868
--- /dev/null
+++ b/development/savan_old/src/main/java/org/apache/savan/util/UtilFactory.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.util;
+
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.messagereceiver.MessageReceiverDeligater;
+import org.apache.savan.subscribers.AbstractSubscriber;
+import org.apache.savan.subscription.SubscriptionProcessor;
+
+/**
+ * Defines a Utility Factory in Savan. Each Protocol will provide its own set of
+ * utilities.
+ * These utilities will be used in various levels in Savan.
+ */
+public interface UtilFactory {
+
+ public abstract SavanMessageContext initializeMessage (SavanMessageContext messageContext);
+ public abstract SubscriptionProcessor createSubscriptionProcessor ();
+ public abstract MessageReceiverDeligater createMessageReceiverDeligater ();
+// public abstract AbstractSubscriber createSubscriber ();
+
+}
diff --git a/development/savan_old/src/main/resources/META-INF/module.xml b/development/savan_old/src/main/resources/META-INF/module.xml
new file mode 100644
index 0000000..cf5e175
--- /dev/null
+++ b/development/savan_old/src/main/resources/META-INF/module.xml
@@ -0,0 +1,24 @@
+<module name="Savan" class="org.apache.savan.module.SavanModule">
+
+ <InFlow>
+ <handler name="SavanInHandler" class="org.apache.savan.handlers.SavanInHandler">
+ <order phase="OperationInPhase"/>
+ </handler>
+ </InFlow>
+
+ <OutFlow>
+ <handler name="SavanOutHandler" class="org.apache.savan.handlers.SavanOutHandler">
+ <order phase="OperationOutPhase"/>
+ </handler>
+ </OutFlow>
+
+ <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>
+ </operation>
+
+</module>
\ No newline at end of file
diff --git a/development/savan_old/src/site/site.xml b/development/savan_old/src/site/site.xml
new file mode 100644
index 0000000..aac005c
--- /dev/null
+++ b/development/savan_old/src/site/site.xml
@@ -0,0 +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>
+</site>
diff --git a/development/savan_old/src/site/xdoc/savan-tutorial.xml b/development/savan_old/src/site/xdoc/savan-tutorial.xml
new file mode 100644
index 0000000..bf0d9d2
--- /dev/null
+++ b/development/savan_old/src/site/xdoc/savan-tutorial.xml
@@ -0,0 +1,14 @@
+
+<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>
+</document>
diff --git a/development/savan_old/src/test/java/org/apache/axis2/savan/CompositeSubscriberTest.java b/development/savan_old/src/test/java/org/apache/axis2/savan/CompositeSubscriberTest.java
new file mode 100644
index 0000000..531bbe1
--- /dev/null
+++ b/development/savan_old/src/test/java/org/apache/axis2/savan/CompositeSubscriberTest.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.savan;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.publication.PublicationReport;
+import org.apache.savan.subscribers.CompositeSubscriber;
+import org.apache.savan.subscribers.LeafSubscriber;
+
+public class CompositeSubscriberTest extends TestCase {
+
+ public void testSubscribers () throws SavanException {
+
+ MessageContext mc = new MessageContext ();
+ SavanMessageContext smc = new SavanMessageContext (mc);
+
+ LeafSubscriberImpl leafSubscriber1 = new LeafSubscriberImpl ();
+ LeafSubscriberImpl leafSubscriber2 = new LeafSubscriberImpl ();
+ CompositeSubscriber compositeSubscriber = new CompositeSubscriber ();
+
+ compositeSubscriber.addSubscriber(leafSubscriber1);
+ compositeSubscriber.addSubscriber(leafSubscriber2);
+
+ PublicationReport report = new PublicationReport ();
+ compositeSubscriber.sendPublication(smc,report);
+ assertTrue(leafSubscriber1.isNotified());
+ assertTrue(leafSubscriber2.isNotified());
+ }
+
+ class LeafSubscriberImpl extends LeafSubscriber {
+
+ boolean notified = false;
+
+ public void doProtocolSpecificPublication(SavanMessageContext notificationMessage) {
+ notified = true;
+ }
+
+ public boolean isNotified () {
+ return notified;
+ }
+ }
+
+}
diff --git a/development/savan_old/src/test/java/org/apache/axis2/savan/ConfigurationManagerTest.java b/development/savan_old/src/test/java/org/apache/axis2/savan/ConfigurationManagerTest.java
new file mode 100644
index 0000000..8531c0c
--- /dev/null
+++ b/development/savan_old/src/test/java/org/apache/axis2/savan/ConfigurationManagerTest.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.savan;
+
+import java.io.File;
+
+import org.apache.savan.SavanException;
+import org.apache.savan.configuration.ConfigurationManager;
+
+import junit.framework.TestCase;
+
+public class ConfigurationManagerTest extends TestCase {
+
+ public void testFromXMLFile () throws SavanException {
+
+ File baseDir = new File("");
+
+ 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);
+
+
+ }
+}
diff --git a/development/savan_old/src/test/java/org/apache/axis2/savan/ConpositeSubscriberTest.java b/development/savan_old/src/test/java/org/apache/axis2/savan/ConpositeSubscriberTest.java
new file mode 100644
index 0000000..adbccf6
--- /dev/null
+++ b/development/savan_old/src/test/java/org/apache/axis2/savan/ConpositeSubscriberTest.java
@@ -0,0 +1,54 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package org.apache.axis2.savan;
+
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.subscribers.CompositeSubscriber;
+import org.apache.savan.subscribers.LeafSubscriber;
+
+import junit.framework.TestCase;
+
+public class ConpositeSubscriberTest extends TestCase {
+
+ public void testSubscribers () throws SavanException {
+ LeafSubscriberImpl leafSubscriber1 = new LeafSubscriberImpl ();
+ LeafSubscriberImpl leafSubscriber2 = new LeafSubscriberImpl ();
+ CompositeSubscriber compositeSubscriber = new CompositeSubscriber ();
+
+ compositeSubscriber.addSubscriber(leafSubscriber1);
+ compositeSubscriber.addSubscriber(leafSubscriber2);
+
+ compositeSubscriber.sendPublication(null,null);
+ assertTrue(leafSubscriber1.isNotified());
+ assertTrue(leafSubscriber2.isNotified());
+ }
+
+ class LeafSubscriberImpl extends LeafSubscriber {
+
+ boolean notified = false;
+
+ public void doProtocolSpecificPublication(SavanMessageContext notificationMessage) {
+ notified = true;
+ }
+
+ public boolean isNotified () {
+ return notified;
+ }
+ }
+
+}
diff --git a/development/savan_old/src/test/java/org/apache/axis2/savan/EventingExpirationTypesTest.java b/development/savan_old/src/test/java/org/apache/axis2/savan/EventingExpirationTypesTest.java
new file mode 100644
index 0000000..7c1b019
--- /dev/null
+++ b/development/savan_old/src/test/java/org/apache/axis2/savan/EventingExpirationTypesTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.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;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.databinding.types.Duration;
+import org.apache.axis2.databinding.utils.ConverterUtil;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.eventing.EventingSubscriptionProcessor;
+import org.apache.savan.subscription.ExpirationBean;
+import org.apache.savan.util.CommonUtil;
+
+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 {
+ 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;
+ }
+}
diff --git a/development/savan_old/src/test/java/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java b/development/savan_old/src/test/java/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java
new file mode 100644
index 0000000..1be93b8
--- /dev/null
+++ b/development/savan_old/src/test/java/org/apache/axis2/savan/EventingSubscripitonProcessorTest.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.axis2.savan;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.databinding.utils.ConverterUtil;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.configuration.ConfigurationManager;
+import org.apache.savan.configuration.Protocol;
+import org.apache.savan.eventing.EventingConstants;
+import org.apache.savan.eventing.EventingSubscriptionProcessor;
+import org.apache.savan.eventing.subscribers.EventingLeafSubscriber;
+import org.apache.savan.storage.DefaultSubscriberStore;
+import org.apache.savan.storage.SubscriberStore;
+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;
+
+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();
+
+// Protocol protocol = new Protocol ();
+// protocol.setName("eventing");
+// protocol.setUtilFactory(new EventingUtilFactory ());
+// protocol.setDefaultSubscriber("org.apache.savan.eventing.subscribers.EventingLeafSubscriber");
+
+ SubscriberStore store = new DefaultSubscriberStore ();
+
+// smc.setProtocol(protocol);
+
+ smc.setSubscriberStore(store);
+
+ EventingSubscriptionProcessor esp = new EventingSubscriptionProcessor ();
+ EventingLeafSubscriber eventingSubscriber = (EventingLeafSubscriber) 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/development/savan_old/src/test/java/org/apache/axis2/savan/XPathBasedFilterTest.java b/development/savan_old/src/test/java/org/apache/axis2/savan/XPathBasedFilterTest.java
new file mode 100644
index 0000000..3e6e45b
--- /dev/null
+++ b/development/savan_old/src/test/java/org/apache/axis2/savan/XPathBasedFilterTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.axis2.savan;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.savan.filters.Filter;
+import org.apache.savan.filters.XPathBasedFilter;
+
+public class XPathBasedFilterTest extends TestCase {
+
+ String filterString = "//elem1";
+
+ public void testMessageFiltering () throws AxisFault {
+ SOAPEnvelope envelope = createTestEnvelope ();
+
+ OMNode filterNode = getFilterElement ();
+ Filter filter = new XPathBasedFilter ();
+ filter.setUp(filterNode);
+
+ assertTrue (filter.checkEnvelopeCompliance(envelope));
+ }
+
+ private SOAPEnvelope createTestEnvelope () {
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+
+ OMElement elem1 = factory.createOMElement("elem1",null);
+ OMElement elem2 = factory.createOMElement("elem2",null);
+ OMElement elem3 = factory.createOMElement("elem3",null);
+
+ elem2.addChild(elem3);
+ elem1.addChild(elem2);
+
+ envelope.getBody().addChild(elem1);
+ factory.createOMDocument().addChild(envelope);
+
+ return envelope;
+ }
+
+ private OMNode getFilterElement () {
+ SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+ OMText text = factory.createOMText(filterString);
+ return text;
+ }
+
+}
diff --git a/development/savan_old/src/test/resources/eventing-renew-datetime.xml b/development/savan_old/src/test/resources/eventing-renew-datetime.xml
new file mode 100644
index 0000000..1a34fcd
--- /dev/null
+++ b/development/savan_old/src/test/resources/eventing-renew-datetime.xml
@@ -0,0 +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>
diff --git a/development/savan_old/src/test/resources/eventing-renew-duration.xml b/development/savan_old/src/test/resources/eventing-renew-duration.xml
new file mode 100644
index 0000000..4561cce
--- /dev/null
+++ b/development/savan_old/src/test/resources/eventing-renew-duration.xml
@@ -0,0 +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>
\ No newline at end of file
diff --git a/development/savan_old/src/test/resources/eventing-subscription.xml b/development/savan_old/src/test/resources/eventing-subscription.xml
new file mode 100644
index 0000000..8b27b5d
--- /dev/null
+++ b/development/savan_old/src/test/resources/eventing-subscription.xml
@@ -0,0 +1,28 @@
+<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/development/savan_old/src/test/resources/savan-config-test.xml b/development/savan_old/src/test/resources/savan-config-test.xml
new file mode 100644
index 0000000..1773586
--- /dev/null
+++ b/development/savan_old/src/test/resources/savan-config-test.xml
@@ -0,0 +1,61 @@
+<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>composite</name>
+ <class>org.apache.savan.subscribers.CompositeSubscriber</class>
+ </subscriber>
+ <subscriber>
+ <name>eventing-leaf</name>
+ <class>org.apache.savan.eventing.subscribers.EventingLeafSubscriber</class>
+ </subscriber>
+ <subscriber>
+ <name>eventing-topic</name>
+ <class>org.apache.savan.eventing.subscribers.EventingTopicSubscriber</class>
+ </subscriber>
+ </subscribers>
+
+</savan-config>
\ No newline at end of file