/* * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javax.management.relation; import static com.sun.jmx.mbeanserver.Util.cast; import static com.sun.jmx.defaults.JmxProperties.RELATION_LOGGER; import com.sun.jmx.mbeanserver.GetPropertyAction; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamField; import java.security.AccessController; import java.util.List; import java.util.Vector; import javax.management.MBeanServerNotification; import javax.management.Notification; import javax.management.NotificationFilterSupport; import javax.management.ObjectName; import java.util.List; import java.util.logging.Level; import java.util.Vector; /** * Filter for {@link MBeanServerNotification}. * This filter filters MBeanServerNotification notifications by * selecting the ObjectNames of interest and the operations (registration, * unregistration, both) of interest (corresponding to notification * types). * *
The serialVersionUID of this class is 2605900539589789736L
.
*
* @since 1.5
*/
@SuppressWarnings("serial") // serialVersionUID must be constant
public class MBeanServerNotificationFilter extends NotificationFilterSupport {
// Serialization compatibility stuff:
// Two serial forms are supported in this class. The selected form depends
// on system property "jmx.serial.form":
// - "1.0" for JMX 1.0
// - any other value for JMX 1.1 and higher
//
// Serial version for old serial form
private static final long oldSerialVersionUID = 6001782699077323605L;
//
// Serial version for new serial form
private static final long newSerialVersionUID = 2605900539589789736L;
//
// Serializable fields in old serial form
private static final ObjectStreamField[] oldSerialPersistentFields =
{
new ObjectStreamField("mySelectObjNameList", Vector.class),
new ObjectStreamField("myDeselectObjNameList", Vector.class)
};
//
// Serializable fields in new serial form
private static final ObjectStreamField[] newSerialPersistentFields =
{
new ObjectStreamField("selectedNames", List.class),
new ObjectStreamField("deselectedNames", List.class)
};
//
// Actual serial version and serial form
private static final long serialVersionUID;
/**
* @serialField selectedNames List List of {@link ObjectName}s of interest
*
null
means that all {@link ObjectName}s are implicitly selected
* (check for explicit deselections)null
means that all {@link ObjectName}s are implicitly deselected
* (check for explicit selections))null
means that all {@link ObjectName}s are implicitly selected
* (check for explicit deselections)null
means that all {@link ObjectName}s are implicitly deselected
* (check for explicit selections))- null means all ObjectNames are implicitly selected, except the * ObjectNames explicitly deselected *
- empty means all ObjectNames are deselected, i.e. no ObjectName
* selected.
*/
public synchronized Vector - null means all ObjectNames are implicitly deselected, except the
* ObjectNames explicitly selected
* - empty means all ObjectNames are selected, i.e. no ObjectName
* deselected.
*/
public synchronized Vector 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.
*
* @param notif The notification to be sent.
*
* @return true if the notification has to be sent to the listener, false
* otherwise.
*
* @exception IllegalArgumentException if null parameter
*/
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