Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2014-06-18 17:59:36 +0000
committerslewis2014-06-18 17:59:36 +0000
commitb306d9de38b570c2fa8f7b45a6b4ecd34333c1e1 (patch)
treead2861c6011c66bd5241159cd9475c8f8bcca977
parent1c0fe617b154f7245e998a47dbd425c37af5249b (diff)
downloadorg.eclipse.ecf-b306d9de38b570c2fa8f7b45a6b4ecd34333c1e1.tar.gz
org.eclipse.ecf-b306d9de38b570c2fa8f7b45a6b4ecd34333c1e1.tar.xz
org.eclipse.ecf-b306d9de38b570c2fa8f7b45a6b4ecd34333c1e1.zip
Added behavior to EndpointDescriptionLocator to support
MODIFIED_ENDMATCH event type...i.e. when the properties are updated and no longer match the filter for a given Change-Id: I886705e6214a1ea6c25258fe6354d2875312da23
-rw-r--r--osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java50
1 files changed, 38 insertions, 12 deletions
diff --git a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
index e14a2f91b..12f42397a 100644
--- a/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
+++ b/osgi/bundles/org.eclipse.ecf.osgi.services.remoteserviceadmin/src/org/eclipse/ecf/osgi/services/remoteserviceadmin/EndpointDescriptionLocator.java
@@ -272,7 +272,7 @@ public class EndpointDescriptionLocator {
Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> allDiscoveredEndpointDescriptions = getAllDiscoveredEndpointDescriptions();
for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : allDiscoveredEndpointDescriptions) {
EndpointDescriptionLocator.EndpointEventListenerHolder[] endpointEventListenerHolders = getMatchingEndpointEventListenerHolders(
- new ServiceReference[] { reference }, ed);
+ new ServiceReference[] { reference }, ed, EndpointEvent.ADDED);
if (endpointEventListenerHolders != null) {
for (int i = 0; i < endpointEventListenerHolders.length; i++) {
queueEndpointDescription(
@@ -281,7 +281,8 @@ public class EndpointDescriptionLocator {
endpointEventListenerHolders[i]
.getDescription(),
endpointEventListenerHolders[i]
- .getMatchingFilter(), EndpointEvent.ADDED);
+ .getMatchingFilter(),
+ endpointEventListenerHolders[i].getType());
}
}
}
@@ -525,14 +526,14 @@ public class EndpointDescriptionLocator {
}
void queueEndpointEvent(org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription, int type) {
- EndpointEventListenerHolder[] endpointEventListenerHolders = getMatchingEndpointEventListenerHolders(endpointDescription);
+ EndpointEventListenerHolder[] endpointEventListenerHolders = getMatchingEndpointEventListenerHolders(endpointDescription, type);
if (endpointEventListenerHolders != null) {
for (int i = 0; i < endpointEventListenerHolders.length; i++) {
queueEndpointDescription(
endpointEventListenerHolders[i].getListener(),
endpointEventListenerHolders[i].getDescription(),
endpointEventListenerHolders[i].getMatchingFilter(),
- type);
+ endpointEventListenerHolders[i].getType());
}
} else {
@@ -753,7 +754,7 @@ public class EndpointDescriptionLocator {
* @since 4.1
*/
protected EndpointEventListenerHolder[] getMatchingEndpointEventListenerHolders(
- final EndpointDescription description) {
+ final EndpointDescription description, final int type) {
return AccessController
.doPrivileged(new PrivilegedAction<EndpointEventListenerHolder[]>() {
public EndpointEventListenerHolder[] run() {
@@ -761,7 +762,7 @@ public class EndpointDescriptionLocator {
return getMatchingEndpointEventListenerHolders(
endpointEventListenerTracker
.getServiceReferences(),
- description);
+ description, type);
}
}
});
@@ -774,11 +775,13 @@ public class EndpointDescriptionLocator {
private EndpointEventListener listener;
private EndpointDescription description;
private String matchingFilter;
+ private int type;
- public EndpointEventListenerHolder(EndpointEventListener l, EndpointDescription d, String f) {
+ public EndpointEventListenerHolder(EndpointEventListener l, EndpointDescription d, String f, int t) {
this.listener = l;
this.description = d;
this.matchingFilter = f;
+ this.type = t;
}
public EndpointEventListener getListener() {
@@ -792,6 +795,10 @@ public class EndpointDescriptionLocator {
public String getMatchingFilter() {
return matchingFilter;
}
+
+ public int getType() {
+ return type;
+ }
}
public class EndpointListenerHolder {
@@ -824,7 +831,7 @@ public class EndpointDescriptionLocator {
* @since 4.1
*/
public EndpointEventListenerHolder[] getMatchingEndpointEventListenerHolders(
- ServiceReference[] refs, EndpointDescription description) {
+ ServiceReference[] refs, EndpointDescription description, int type) {
if (refs == null)
return null;
List results = new ArrayList();
@@ -836,11 +843,30 @@ public class EndpointDescriptionLocator {
List<String> filters = PropertiesUtil.getStringPlusProperty(
getMapFromProperties(refs[i]),
EndpointEventListener.ENDPOINT_LISTENER_SCOPE);
+ // Only proceed if there is a filter present
if (filters.size() > 0) {
- String matchingFilter = isMatch(description, filters);
- if (matchingFilter != null)
- results.add(new EndpointEventListenerHolder(listener,
- description, matchingFilter));
+ if (type == EndpointEvent.MODIFIED) {
+ EndpointEventListenerHolder eh = null;
+ // If the type is modified, we determine whether it's a simple
+ // MODIFIED, or whether it's MODIFIED_ENDMATCH by whether
+ // there is still a matching filter for the new/modified
+ // EndpointDescription
+ String matchingFilter = isMatch(description, filters);
+ if (matchingFilter == null)
+ // no filters match, so this is a MODIFIED_ENDMATCH for the given
+ // EndpointEventListener
+ eh = new EndpointEventListenerHolder(listener, description, "", EndpointEvent.MODIFIED_ENDMATCH); //$NON-NLS-1$
+ else
+ // it still matches, so it's a simple MODIFIED
+ eh = new EndpointEventListenerHolder(listener, description, matchingFilter, EndpointEvent.MODIFIED);
+ // Add the eh to the results (to be notified)
+ results.add(eh);
+ } else {
+ String matchingFilter = isMatch(description, filters);
+ if (matchingFilter != null)
+ results.add(new EndpointEventListenerHolder(listener,
+ description, matchingFilter, type));
+ }
}
}
return (EndpointEventListenerHolder[]) results

Back to the top