public synchronized boolean isNotificationEnabled(Notification notif) throws IllegalArgumentException {
if (notif == null) {
String excMsg = "Invalid parameter.";
throw new IllegalArgumentException(excMsg);
}
RELATION_LOGGER.entering(MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled", notif);
// Checks the type first
String ntfType = notif.getType();
Vector< String > enabledTypes = getEnabledTypes();
if (!(enabledTypes.contains(ntfType))) {
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"Type not selected, exiting");
return false;
}
// We have a MBeanServerNotification: downcasts it
MBeanServerNotification mbsNtf = (MBeanServerNotification)notif;
// Checks the ObjectName
ObjectName objName = mbsNtf.getMBeanName();
// Is it selected?
boolean isSelectedFlg = false;
if (selectedNames != null) {
// Not all are implicitly selected:
// checks for explicit selection
if (selectedNames.size() == 0) {
// All are explicitly not selected
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"No ObjectNames selected, exiting");
return false;
}
isSelectedFlg = selectedNames.contains(objName);
if (!isSelectedFlg) {
// Not in the explicit selected list
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"ObjectName not in selected list, exiting");
return false;
}
}
if (!isSelectedFlg) {
// Not explicitly selected: is it deselected?
if (deselectedNames == null) {
// All are implicitly deselected and it is not explicitly
// selected
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"ObjectName not selected, and all " +
"names deselected, exiting");
return false;
} else if (deselectedNames.contains(objName)) {
// Explicitly deselected
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"ObjectName explicitly not selected, exiting");
return false;
}
}
RELATION_LOGGER.logp(Level.FINER,
MBeanServerNotificationFilter.class.getName(),
"isNotificationEnabled",
"ObjectName selected, exiting");
return true;
}
Invoked before sending the specified notification to the listener.
If:
- the ObjectName of the concerned MBean is selected (explicitly OR
(implicitly and not explicitly deselected))
AND
- the type of the operation (registration or unregistration) is
selected
then the notification is sent to the listener. |