package org.jboss.mx.remote.event;
import javax.management.MBeanServerNotification;
import javax.management.Notification;
import javax.management.NotificationFilter;
import javax.management.ObjectName;
/**
* LocalMBeanEventFilter will filter out events that don't originate from the local MBeanServer
*
* @author <a href="mailto:jhaynie@vocalocity.net">Jeff Haynie</a>
*/
public class LocalMBeanEventFilter implements NotificationFilter
{
static final long serialVersionUID = 5891412135761783128L;
public boolean isNotificationEnabled(Notification notification)
{
Object src = notification.getSource();
ObjectName on = null;
if (notification instanceof MBeanServerNotification)
{
MBeanServerNotification mb = (MBeanServerNotification) notification;
on = mb.getMBeanName();
}
else if (src instanceof ObjectName)
{
on = (ObjectName) src;
}
return (on == null || on.getKeyProperty("MBeanServerId") == null);
}
}