You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ti...@apache.org on 2021/09/14 15:17:43 UTC

[aries-rsa] 02/02: Ensure that Local Discovery tracks all listeners

This is an automated email from the ASF dual-hosted git repository.

timothyjward pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git

commit 33579827bc4533fde8fdedca8313a6ec039475ce
Author: Tim Ward <ti...@apache.org>
AuthorDate: Tue Sep 14 16:15:37 2021 +0100

    Ensure that Local Discovery tracks all listeners
---
 .../java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
index 63e5cf2..03350f6 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
@@ -41,6 +41,8 @@ import org.osgi.service.component.annotations.Activate;
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.component.annotations.Deactivate;
 import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
 import org.osgi.service.remoteserviceadmin.EndpointDescription;
 import org.osgi.service.remoteserviceadmin.EndpointEvent;
 import org.osgi.service.remoteserviceadmin.EndpointEventListener;
@@ -83,7 +85,7 @@ public class LocalDiscovery implements BundleListener {
         }
     }
 
-    @Reference
+    @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
     void bindListener(ServiceReference<EndpointEventListener> endpointListenerRef, EndpointEventListener endpointListener) {
         List<String> filters = StringPlus.normalize(endpointListenerRef.getProperty(EndpointEventListener.ENDPOINT_LISTENER_SCOPE));
         if (filters.isEmpty()) {
@@ -128,6 +130,10 @@ public class LocalDiscovery implements BundleListener {
     void updatedListener(ServiceReference<EndpointEventListener> endpointListenerRef, EndpointEventListener endpointListener) {
         // if service properties have been updated, the filter (scope)
         // might have changed so we remove and re-add the listener
+    	// TODO fix this so that we don't:
+    	// 1. remove and add when there is no change
+    	// 2. remove and add instead of modifying
+    	// 3. remove instead of modified end match
         synchronized (listenerToFilters) {
             unbindListener(endpointListener);
             bindListener(endpointListenerRef, endpointListener);