You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2006/06/05 13:44:53 UTC
svn commit: r411752 [2/2] - in /webservices/axis2/trunk/java: etc/
modules/savan/ modules/savan/conf/ modules/savan/src/
modules/savan/src/org/ modules/savan/src/org/apache/
modules/savan/src/org/apache/savan/
modules/savan/src/org/apache/savan/eventin...
Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/CompositeSubscriber.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/CompositeSubscriber.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/CompositeSubscriber.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/CompositeSubscriber.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,54 @@
+/*
+ * 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.Iterator;
+
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.subscribers.Subscriber;
+
+
+public class CompositeSubscriber extends Subscriber {
+
+ ArrayList subscribers = null;
+
+ public CompositeSubscriber (){
+ subscribers = new ArrayList ();
+ }
+
+ public void addSubscriber (Subscriber subscriber) {
+ subscribers.add(subscriber);
+ }
+
+ public void sendNotification(SavanMessageContext notificationMessage) throws SavanException {
+ for (Iterator it = subscribers.iterator();it.hasNext();) {
+ Subscriber subscriber = (Subscriber) it.next();
+ subscriber.sendNotification(notificationMessage);
+ }
+ }
+
+ public void renewSubscription(long renewAmount) {
+ for (Iterator it = subscribers.iterator();it.hasNext();) {
+ Subscriber subscriber = (Subscriber) it.next();
+ subscriber.renewSubscription(renewAmount);
+ }
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/LeafSubscriber.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/LeafSubscriber.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/LeafSubscriber.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/LeafSubscriber.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,51 @@
+/*
+ * 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 org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+
+
+public abstract class LeafSubscriber extends Subscriber {
+
+ private long subscriptionEndingTime = -1;
+
+ public void renewSubscription (long renewAmount) {
+ if (subscriptionEndingTime<0)
+ subscriptionEndingTime = 0;
+
+ subscriptionEndingTime = subscriptionEndingTime + renewAmount;
+ }
+
+ public long getSubscriptionEndingTime () {
+ return subscriptionEndingTime;
+ }
+
+ public void sendNotification(SavanMessageContext notificationMessage) throws SavanException {
+ long timeNow = System.currentTimeMillis();
+
+ if (subscriptionEndingTime>0 && subscriptionEndingTime<=timeNow) {
+ String message = "Cant notify the listner since the subscription ending time has been passed";
+ throw new SavanException (message);
+ }
+
+ doProtocolSpecificNotification (notificationMessage);
+ }
+
+ public abstract void doProtocolSpecificNotification (SavanMessageContext notificationMessage) throws SavanException;
+}
Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/Subscriber.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/Subscriber.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/Subscriber.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscribers/Subscriber.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,37 @@
+/*
+ * 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 org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+
+public abstract class Subscriber {
+
+ String id;
+
+ public String getId() {
+ return id;
+ }
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public abstract void renewSubscription (long renewAmount);
+ public abstract void sendNotification (SavanMessageContext notificationMessage) throws SavanException;
+
+}
Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/RenewBean.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/RenewBean.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/RenewBean.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/RenewBean.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,39 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.savan.subscription;
+
+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;
+ }
+
+
+}
Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/SubscriptionProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/SubscriptionProcessor.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/SubscriptionProcessor.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/subscription/SubscriptionProcessor.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,88 @@
+/*
+ * 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.HashMap;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.savan.SavanConstants;
+import org.apache.savan.SavanException;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.subscribers.Subscriber;
+
+
+public abstract class SubscriptionProcessor {
+
+ public abstract void init (SavanMessageContext smc) throws SavanException;
+
+ public void unsubscribe(SavanMessageContext endSubscriptionMessage) throws SavanException {
+ ConfigurationContext configurationContext = endSubscriptionMessage.getConfigurationContext();
+ HashMap subscribers = (HashMap) configurationContext.getProperty(SavanConstants.SUBSCRIBER_TABLE);
+ if (subscribers==null) {
+ subscribers = new HashMap ();
+ configurationContext.setProperty(SavanConstants.SUBSCRIBER_TABLE,subscribers);
+ }
+
+ String subscriberID = getSubscriberID (endSubscriptionMessage);
+ if (subscriberID==null) {
+ String message = "Cannot find the subscriber ID";
+ throw new SavanException (message);
+ }
+
+ subscribers.remove(subscriberID);
+ }
+
+ public void renewSubscription(SavanMessageContext renewMessage) throws SavanException {
+
+ ConfigurationContext configurationContext = renewMessage.getConfigurationContext();
+ HashMap subscribers = (HashMap) configurationContext.getProperty(SavanConstants.SUBSCRIBER_TABLE);
+ if (subscribers==null) {
+ throw new SavanException ("Given subscriber is not present");
+ }
+
+ RenewBean renewBean = getRenewBean(renewMessage);
+ Subscriber subscriber = (Subscriber) subscribers.get(renewBean.getSubscriberID());
+ if (subscriber==null) {
+ throw new SavanException ("Given subscriber is not present");
+ }
+
+ subscriber.renewSubscription(renewBean.getRenewMount());
+ }
+
+ public void subscribe(SavanMessageContext subscriptionMessage) throws SavanException {
+ ConfigurationContext configurationContext = subscriptionMessage.getConfigurationContext();
+ HashMap subscribers = (HashMap) configurationContext.getProperty(SavanConstants.SUBSCRIBER_TABLE);
+ if (subscribers==null) {
+ subscribers = new HashMap ();
+ configurationContext.setProperty(SavanConstants.SUBSCRIBER_TABLE,subscribers);
+ }
+
+ Subscriber subscriber = getSubscriberFromMessage (subscriptionMessage);
+ subscribers.put(subscriber.getId(),subscriber);
+ }
+
+ 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 RenewBean getRenewBean (SavanMessageContext renewMessage) throws SavanException;
+
+ public abstract String getSubscriberID (SavanMessageContext smc) throws SavanException;
+
+}
Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/AbstractSavanUtilFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/AbstractSavanUtilFactory.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/AbstractSavanUtilFactory.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/AbstractSavanUtilFactory.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,32 @@
+/*
+ * 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.eventing.EventingUtilFactory;
+
+
+public class AbstractSavanUtilFactory {
+
+ public static SavanUtilFactory getUtilFactory (int protocolType) {
+ if (protocolType==SavanConstants.PROTOCOL_EVENTING)
+ return new EventingUtilFactory ();
+
+ return null;
+ }
+}
Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/CommonUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/CommonUtil.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/CommonUtil.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/CommonUtil.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,22 @@
+/*
+ * 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;
+
+public class CommonUtil {
+
+}
Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/ProtocolManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/ProtocolManager.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/ProtocolManager.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/ProtocolManager.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,31 @@
+/*
+ * 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.axis2.context.MessageContext;
+import org.apache.savan.SavanConstants;
+
+
+public class ProtocolManager {
+
+ public static int getMessageProtocol (MessageContext messageContext) {
+ //TODO to this depending on the message
+ return SavanConstants.PROTOCOL_EVENTING;
+ }
+
+}
Added: webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/SavanUtilFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/SavanUtilFactory.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/SavanUtilFactory.java (added)
+++ webservices/axis2/trunk/java/modules/savan/src/org/apache/savan/util/SavanUtilFactory.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,34 @@
+/*
+ * 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.axis2.context.MessageContext;
+import org.apache.savan.SavanMessageContext;
+import org.apache.savan.messagereceiver.MessageReceiverDeligater;
+import org.apache.savan.publication.PublicationProcessor;
+import org.apache.savan.subscription.SubscriptionProcessor;
+
+
+public interface SavanUtilFactory {
+
+ public SavanMessageContext createSavanMessageContext (MessageContext messageContext);
+ public SubscriptionProcessor createSubscriptionProcessor ();
+ public PublicationProcessor createPublicationProcessor ();
+ public MessageReceiverDeligater createMessageReceiverDeligater ();
+
+}
Added: webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/ConpositeSubscriberTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/ConpositeSubscriberTest.java?rev=411752&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/ConpositeSubscriberTest.java (added)
+++ webservices/axis2/trunk/java/modules/savan/test/org/apache/axis2/savan/ConpositeSubscriberTest.java Mon Jun 5 04:44:51 2006
@@ -0,0 +1,38 @@
+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.sendNotification(null);
+ assertTrue(leafSubscriber1.isNotified());
+ assertTrue(leafSubscriber2.isNotified());
+ }
+
+ class LeafSubscriberImpl extends LeafSubscriber {
+
+ boolean notified = false;
+
+ public void doProtocolSpecificNotification(SavanMessageContext notificationMessage) {
+ notified = true;
+ }
+
+ public boolean isNotified () {
+ return notified;
+ }
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org