APIdia Launch Partner
Top Description Fields Constructors Methods
javax.management

public Class NotificationFilterSupport

extends Object
implements NotificationFilter
Class Inheritance
All Implemented Interfaces
javax.management.NotificationFilter, java.io.Serializable
Known Direct Subclasses
javax.management.relation.MBeanServerNotificationFilter
Imports
java.util.List, .Vector

Provides an implementation of the javax.management.NotificationFilter interface. The filtering is performed on the notification type attribute.

Manages a list of enabled notification types. A method allows users to enable/disable as many notification types as required.

Then, before sending a notification to a listener registered with a filter, the notification broadcaster compares this notification type with all notification types enabled by the filter. The notification will be sent to the listener only if its filter enables this notification type.

Example:

NotificationFilterSupport myFilter = new NotificationFilterSupport();
myFilter.enableType("my_example.my_type");
myBroadcaster.addListener(myListener, myFilter, null);
The listener myListener will only receive notifications the type of which equals/starts with "my_example.my_type".
Since
1.5
See Also
javax.management.NotificationBroadcaster#addNotificationListener

Field Summary

Modifier and TypeField and Description
private List<String>
private static final long

Constructor Summary

AccessConstructor and Description
public
NotificationFilterSupport()

Constructs a NotificationFilterSupport.

Method Summary

Modifier and TypeMethod and Description
public synchronized void
disableAllTypes()

Disables all notification types.

public synchronized void
disableType(String
The prefix.
prefix
)

Removes the given prefix from the prefix list.

public synchronized void
enableType(String
The prefix.
prefix
)

Enables all the notifications the type of which starts with the specified prefix to be sent to the listener.

public synchronized Vector<String>

Returns:

The list containing all the enabled notification types.
getEnabledTypes
()

Gets all the enabled notification types for this filter.

public synchronized boolean

Returns:

true if the notification should be sent to the listener, false otherwise.
isNotificationEnabled
(Notification
The notification to be sent.
notification
)

Implements javax.management.NotificationFilter.isNotificationEnabled.

Invoked before sending the specified notification to the listener.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

enabledTypesback to summary
private List<String> enabledTypes
Annotations
@SuppressWarnings:serial
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

NotificationFilterSupportback to summary
public NotificationFilterSupport()

Constructs a NotificationFilterSupport.

Method Detail

disableAllTypesback to summary
public synchronized void disableAllTypes()

Disables all notification types.

disableTypeback to summary
public synchronized void disableType(String prefix)

Removes the given prefix from the prefix list.
If the specified prefix is not in the list of enabled notification types, this method has no effect.

Parameters
prefix:String

The prefix.

enableTypeback to summary
public synchronized void enableType(String prefix) throws IllegalArgumentException

Enables all the notifications the type of which starts with the specified prefix to be sent to the listener.
If the specified prefix is already in the list of enabled notification types, this method has no effect.

Example:

// Enables all notifications the type of which starts with "my_example" to be sent.
myFilter.enableType("my_example");
// Enables all notifications the type of which is "my_example.my_type" to be sent.
myFilter.enableType("my_example.my_type");
Note that:
myFilter.enableType("my_example.*");
will no match any notification type.
Parameters
prefix:String

The prefix.

Exceptions
IllegalArgumentException:
The prefix parameter is null.
getEnabledTypesback to summary
public synchronized Vector<String> getEnabledTypes()

Gets all the enabled notification types for this filter.

Returns:Vector<String>

The list containing all the enabled notification types.

isNotificationEnabledback to summary
public synchronized boolean isNotificationEnabled(Notification notification)

Implements javax.management.NotificationFilter.isNotificationEnabled.

Invoked before sending the specified notification to the listener.
This filter compares the type of the specified notification with each enabled type. If the notification type matches one of the enabled types, the notification should be sent to the listener and this method returns true.

Parameters
notification:Notification

The notification to be sent.

Returns:boolean

true if the notification should be sent to the listener, false otherwise.