You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by ct...@apache.org on 2009/01/03 15:59:47 UTC
svn commit: r731001 - in
/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl:
SimplePullPoint.java SimplePullPointCreation.java SubscriptionPullPoint.java
Author: ctwiner
Date: Sat Jan 3 06:59:46 2009
New Revision: 731001
URL: http://svn.apache.org/viewvc?rev=731001&view=rev
Log:
MUSE-295 - fix bug in accepts for default implementation add standards compliant version for subscriptions.
Added:
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscriptionPullPoint.java
Modified:
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPoint.java
webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPointCreation.java
Modified: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPoint.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPoint.java?rev=731001&r1=731000&r2=731001&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPoint.java (original)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPoint.java Sat Jan 3 06:59:46 2009
@@ -68,7 +68,8 @@
public boolean accepts(NotificationMessage message)
{
EndpointReference subEPR = message.getSubscriptionReference();
- return subEPR != null && getSubscription().equals(subEPR);
+ // bug pointed out in http://marc.info/?l=muse-user&m=118538443013450&w=2 (MUSE-295)
+ return subEPR != null && getSubscription().getEndpointReference().equals(subEPR);
}
/**
Modified: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPointCreation.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPointCreation.java?rev=731001&r1=731000&r2=731001&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPointCreation.java (original)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimplePullPointCreation.java Sat Jan 3 06:59:46 2009
@@ -80,30 +80,33 @@
PullPoint pullPointCap = (PullPoint)pullPoint.getCapability(WsnConstants.PULL_POINT_URI);
Filter filter = pullPointCap.getFilter();
- //
- // create subscription that will send messages to the pullpoint
- //
- NotificationProducer wsn = (NotificationProducer)getResource().getCapability(WsnConstants.PRODUCER_URI);
- WsResource sub = null;
-
- try
- {
- sub = wsn.subscribe(epr, filter, null, null);
- }
-
- catch (BaseFault error)
- {
- throw new UnableToCreatePullPointFault(error);
- }
-
- pullPointCap.setSubscription(sub);
+ // only if the null filter is not used (for example an actual default filter). (MUSE-295)
+ if (filter != WsnConstants.NULL_FILTER) {
+ //
+ // create subscription that will send messages to the pullpoint
+ //
+ NotificationProducer wsn = (NotificationProducer)getResource().getCapability(WsnConstants.PRODUCER_URI);
+ WsResource sub = null;
+
+ try
+ {
+ sub = wsn.subscribe(epr, filter, null, null);
+ }
+
+ catch (BaseFault error)
+ {
+ throw new UnableToCreatePullPointFault(error);
+ }
+
+ pullPointCap.setSubscription(sub);
+ }
//
// initialize pullpoint to complete creation process
//
try
{
- pullPoint.initialize();
+ pullPoint.initialize(); // NOTE - adds itself to the consumer with SimplePullPoint
manager.addResource(epr, pullPoint);
}
Added: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscriptionPullPoint.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscriptionPullPoint.java?rev=731001&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscriptionPullPoint.java (added)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SubscriptionPullPoint.java Sat Jan 3 06:59:46 2009
@@ -0,0 +1,120 @@
+package org.apache.muse.ws.notification.impl;
+
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.notification.Filter;
+import org.apache.muse.ws.notification.NotificationConsumer;
+import org.apache.muse.ws.notification.NotificationMessage;
+import org.apache.muse.ws.notification.NotificationMessageListener;
+import org.apache.muse.ws.notification.PullPointDataStore;
+import org.apache.muse.ws.notification.WsnConstants;
+import org.apache.muse.ws.notification.faults.UnableToGetMessagesFault;
+import org.apache.muse.ws.notification.impl.SimplePullPointDataStore;
+import org.apache.muse.ws.resource.WsResource;
+import org.apache.muse.ws.resource.impl.AbstractWsResourceCapability;
+
+/**
+ * This version of PullPoint does not subscribe to ALL messages. Until a subscription is registered against it it will not recieve any messages at all.
+ * <br/><br/>
+ * Usage is <br/><br/>
+ * <pre>
+ * Element el = resource.createPullPoint();
+ EndpointReference pullpoint = new EndpointReference(el);
+
+ // register a consumer.
+ SubscriptionClient client = resource.subscribe(pullpoint,
+ new TopicFilter(TOPIC_Q_NAME), null);
+ * </pre>
+ * <br/><br/>
+ * where the target of the subscription is the pull point itself.
+ *
+ * @author Chris Twiner (ctwiner)
+ *
+ */
+public class SubscriptionPullPoint extends AbstractWsResourceCapability implements org.apache.muse.ws.notification.PullPoint, NotificationMessageListener {
+ //
+ // the place where we keep messages until a client asks for them
+ //
+ private PullPointDataStore _dataStore = null;
+
+ /**
+ *
+ * Users can override this method to provide an alternate implementation
+ * of the PullPointDataStore API.
+ *
+ * @return An instance of SimplePullPointDataStore
+ *
+ */
+ protected PullPointDataStore createDataStore()
+ {
+ return new SimplePullPointDataStore();
+ }
+
+ public PullPointDataStore getDataStore()
+ {
+ return _dataStore;
+ }
+
+ /**
+ *
+ * @return An instance of PublishAllMessagesFilter. This allows the pullpoint
+ * to add all messages to its data store.
+ *
+ */
+ public Filter getFilter()
+ {
+ return WsnConstants.NULL_FILTER;
+ }
+
+ public NotificationMessage[] getMessages(int maxNumber)
+ throws UnableToGetMessagesFault
+ {
+ return getDataStore().getMessages(maxNumber);
+ }
+
+ public void initialize()
+ throws SoapFault
+ {
+ super.initialize();
+
+ _dataStore = createDataStore();
+ _dataStore.initialize();
+
+ //
+ // register for messages so we can add them to the data store
+ //
+ NotificationConsumer wsn = (NotificationConsumer)getResource().getCapability(WsnConstants.CONSUMER_URI);
+ wsn.addMessageListener(this);
+ }
+
+ public void process(NotificationMessage message)
+ throws SoapFault
+ {
+ getDataStore().addMessage(message);
+ }
+
+ public void shutdown()
+ throws SoapFault
+ {
+ getDataStore().shutdown();
+ super.shutdown();
+ }
+
+ public boolean accepts(NotificationMessage message)
+ {
+ /* the fact its routed to here means the message headers MUST have the correct resource, when not automatically adding
+ a further subscription.
+ http://mail-archives.apache.org/mod_mbox/ws-muse-user/200707.mbox/%3CDD00ACEE56F4A04DB7092539C493FADC053CA05E@sxmbx06.corproot.net%3E
+ MUSE-295
+ */
+ return true;
+ }
+
+ // the subscription methods aren't used here, subscriptions belong to the client of a pullpoint
+ public WsResource getSubscription() {
+ return null;
+ }
+
+ public void setSubscription(WsResource arg0) {
+
+ }
+}