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 da...@apache.org on 2007/01/07 00:42:46 UTC

svn commit: r493598 - /webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java

Author: danj
Date: Sat Jan  6 15:42:45 2007
New Revision: 493598

URL: http://svn.apache.org/viewvc?view=rev&rev=493598
Log:
Fix for MUSE-170 - because we were adding subscription resources to our internal table via 
resourceAdded(), each instance of SimpleNotificationProducer was being alerted (and adding) 
every instance of a subscription, even if it were created by other SimpleNPs (for other 
resource instances).

I fixed this by putting the resourceAdded() code in subscribe() and then altering the 
resourceRemoved() code to check if the SimpleNP had the subscription in its internal 
table before doing destroy/persistence tasks.

Modified:
    webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java

Modified: webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java?view=diff&rev=493598&r1=493597&r2=493598
==============================================================================
--- webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java (original)
+++ webservices/muse/trunk/modules/muse-wsn-impl/src/org/apache/muse/ws/notification/impl/SimpleNotificationProducer.java Sat Jan  6 15:42:45 2007
@@ -275,6 +275,11 @@
     {
         return _topicSet;
     }
+    
+    protected boolean hasSubscription(EndpointReference subscriptionEPR)
+    {
+        return _subscriptionsByEPR.containsKey(subscriptionEPR);
+    }
 
     public boolean hasTopic(QName topicName)
     {
@@ -444,23 +449,10 @@
 
     public void resourceAdded(EndpointReference epr, Resource resource)
     {
-        if (resource.hasCapability(WsnConstants.SUBSCRIPTION_MGR_URI))
-        {
-            addSubscription((WsResource)resource);
-        
-            NotificationProducerPersistence persistence = (NotificationProducerPersistence)getPersistence();
-            
-            try
-            {
-                if (persistence != null)
-                    persistence.resourceAdded(epr, resource);
-            }
-            
-            catch (SoapFault fault)
-            {
-                LoggingUtils.logError(getLog(), fault);
-            }
-        }
+        //
+        // no action taken - we only need to listen for resourceRemoved() 
+        // so that we can remove subscriptions that have been destroyed
+        //
     }
 
     public void resourceRemoved(EndpointReference epr)
@@ -469,6 +461,11 @@
         // this call is synchronized, so if we're publishing, the 
         // collection will not be updated until afterwards
         //
+        boolean subExists = hasSubscription(epr);
+        
+        if (!subExists)
+            return;
+        
         removeSubscription(epr);
         
         NotificationProducerPersistence persistence = (NotificationProducerPersistence)getPersistence();
@@ -590,6 +587,21 @@
             {
                 throw new UnacceptableInitialTerminationTimeFault(error);
             }
+        }
+        
+        addSubscription(sub);
+        
+        NotificationProducerPersistence persistence = (NotificationProducerPersistence)getPersistence();
+        
+        try
+        {
+            if (persistence != null)
+                persistence.resourceAdded(sub.getEndpointReference(), sub);
+        }
+        
+        catch (SoapFault fault)
+        {
+            LoggingUtils.logError(getLog(), fault);
         }
         
         return sub;



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org