Object listenerObject, int eventAction, Object eventObject) {
final String logMethodName = "dispatchEvent"; //$NON-NLS-1$
// We now dispatch both EndpointListenerEvents
if (eventObject instanceof EndpointListenerEvent) {
final EndpointListenerEvent event = (EndpointListenerEvent) eventObject;
final EndpointListener endpointListener = event
.getEndpointListener();
final EndpointDescription endpointDescription = event
.getEndointDescription();
final String matchingFilter = event.getMatchingFilter();
try {
boolean discovered = event.isDiscovered();
trace("endpointListener.discovered=" + discovered +" ", "fwk=" + getFrameworkUUID() + ", endpointListener=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ endpointListener
+ ", endpointDescription=" //$NON-NLS-1$
+ endpointDescription
+ ", matchingFilter=" //$NON-NLS-1$
+ matchingFilter);
if (discovered)
endpointListener.endpointAdded(endpointDescription,
matchingFilter);
else
endpointListener.endpointRemoved(
endpointDescription, matchingFilter);
} catch (Exception e) {
String message = "Exception in EndpointListener listener=" //$NON-NLS-1$
+ endpointListener + " description=" //$NON-NLS-1$
+ endpointDescription + " matchingFilter=" //$NON-NLS-1$
+ matchingFilter;
logError(logMethodName, message, e);
} catch (LinkageError e) {
String message = "LinkageError in EndpointListener listener=" //$NON-NLS-1$
+ endpointListener + " description=" //$NON-NLS-1$
+ endpointDescription + " matchingFilter=" //$NON-NLS-1$
+ matchingFilter;
logError(logMethodName, message, e);
} catch (AssertionError e) {
String message = "AssertionError in EndpointListener listener=" //$NON-NLS-1$
+ endpointListener + " description=" //$NON-NLS-1$
+ endpointDescription + " matchingFilter=" //$NON-NLS-1$
+ matchingFilter;
logError(logMethodName, message, e);
}
// and EndpointEventListenerEvents
} else if (eventObject instanceof EndpointEventListenerEvent) {
final EndpointEventListenerEvent event = (EndpointEventListenerEvent) eventObject;
final EndpointEventListener endpointEventListener = event.getEndpointEventListener();
final EndpointEvent endpointEvent = event.getEndpointEvent();
final String matchingFilter = event.getMatchingFilter();
try {
trace("endpointEventListener.discovered=" + getEndpointEventTypeAsString(endpointEvent.getType()) + " ", "fwk=" + getFrameworkUUID() + ", endpointEventListener=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ endpointEventListener
+ ", endpointEvent=" //$NON-NLS-1$
+ endpointEvent + ", matchingFilter=" //$NON-NLS-1$
+ matchingFilter);
endpointEventListener.endpointChanged(endpointEvent,
matchingFilter);
} catch (Exception e) {
String message = "Exception in EndpointEventListener listener=" //$NON-NLS-1$
+ endpointEventListener + " event=" //$NON-NLS-1$
+ endpointEvent + " matchingFilter=" //$NON-NLS-1$
+ matchingFilter;
logError(logMethodName, message, e);
} catch (LinkageError e) {
String message = "LinkageError in EndpointEventListener listener=" //$NON-NLS-1$
+ endpointEventListener + " event=" //$NON-NLS-1$
+ endpointEvent + " matchingFilter=" //$NON-NLS-1$
+ matchingFilter;
logError(logMethodName, message, e);
} catch (AssertionError e) {
String message = "AssertionError in EndpointEventListener listener=" //$NON-NLS-1$
+ endpointEventListener + " event=" //$NON-NLS-1$
+ endpointEvent + " matchingFilter=" //$NON-NLS-1$
+ matchingFilter;
logError(logMethodName, message, e);
}
}
}
});
// Register the endpoint listener tracker, so that endpoint listeners
// that are subsequently added
// will then be notified of discovered endpoints
endpointListenerTracker = new ServiceTracker(context,
EndpointListener.class.getName(),
new ServiceTrackerCustomizer() {
public Object addingService(ServiceReference reference) {
if (context == null)
return null;
EndpointListener listener = (EndpointListener) context
.getService(reference);
if (listener == null)
return null;
Collection<org.osgi.service.remoteserviceadmin.EndpointDescription> allDiscoveredEndpointDescriptions = getAllDiscoveredEndpointDescriptions();
for (org.osgi.service.remoteserviceadmin.EndpointDescription ed : allDiscoveredEndpointDescriptions) {