// Stack confinement
boolean isListening = false;
Object callbackParam = null;
Callback callback = null;
synchronized (this) {
isListening = m_isListening;
}
// Check if the subscriber's topic and filter match
Filter filter = subscriberMetadata.getFilter();
if (EventUtil.matches(topic, subscriberMetadata.getTopics())
&& (filter == null || event.matches(filter))) {
String name = subscriberMetadata.getName();
callback = (Callback) m_callbacksByName.get(name);
try {
// Depending on the subscriber type...
callbackParam = getCallbackParameter(event,
subscriberMetadata);
} catch (ClassCastException e) {
// Ignore the data event if type doesn't match
warn(LOG_PREFIX + "Ignoring data event : Bad data type", e);
} catch (NoSuchFieldException e) {
// Ignore events without data field for data events
// subscriber
warn(LOG_PREFIX + "Ignoring data event : No data", e);
}
}
// Run the callback (final check to avoid
// NullPointerExceptions)
if (isListening && callback != null && callbackParam != null) {
try {
callback.call(new Object[] { callbackParam });
} catch (InvocationTargetException e) {
error(LOG_PREFIX
+ "The callback has thrown an exception",
e.getTargetException());
} catch (Exception e) {