NotificationFilterSupport.java revision 2362
2362N/A * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Provides an implementation of the {@link javax.management.NotificationFilter} interface. 0N/A * The filtering is performed on the notification type attribute. 0N/A * Manages a list of enabled notification types. 0N/A * A method allows users to enable/disable as many notification types as required. 0N/A * Then, before sending a notification to a listener registered with a filter, 0N/A * the notification broadcaster compares this notification type with all notification types 0N/A * enabled by the filter. The notification will be sent to the listener 0N/A * only if its filter enables this notification type. 0N/A * NotificationFilterSupport myFilter = new NotificationFilterSupport(); 0N/A * myFilter.enableType("my_example.my_type"); 0N/A * myBroadcaster.addListener(myListener, myFilter, null); 0N/A * The listener <CODE>myListener</CODE> will only receive notifications the type of which equals/starts with "my_example.my_type". 0N/A * @see javax.management.NotificationBroadcaster#addNotificationListener 0N/A /* Serial version */ 0N/A * @serial {@link Vector} that contains the enabled notification types. 0N/A * The default value is an empty vector. 0N/A * Invoked before sending the specified notification to the listener. 0N/A * <BR>This filter compares the type of the specified notification with each enabled type. 0N/A * If the notification type matches one of the enabled types, 0N/A * the notification should be sent to the listener and this method returns <CODE>true</CODE>. 0N/A * @param notification The notification to be sent. 0N/A * @return <CODE>true</CODE> if the notification should be sent to the listener, <CODE>false</CODE> otherwise. 0N/A // Should never occurs... 0N/A * Enables all the notifications the type of which starts with the specified prefix 0N/A * to be sent to the listener. 0N/A * <BR>If the specified prefix is already in the list of enabled notification types, 0N/A * this method has no effect. 0N/A * // Enables all notifications the type of which starts with "my_example" to be sent. 0N/A * myFilter.enableType("my_example"); 0N/A * // Enables all notifications the type of which is "my_example.my_type" to be sent. 0N/A * myFilter.enableType("my_example.my_type"); 0N/A * <BLOCKQUOTE><CODE> 0N/A * myFilter.enableType("my_example.*"); 0N/A * </CODE></BLOCKQUOTE> 0N/A * will no match any notification type. 0N/A * @param prefix The prefix. 0N/A * @exception java.lang.IllegalArgumentException The prefix parameter is null. 0N/A * Removes the given prefix from the prefix list. 0N/A * <BR>If the specified prefix is not in the list of enabled notification types, 0N/A * this method has no effect. 0N/A * @param prefix The prefix. 0N/A * Disables all notification types. 0N/A * Gets all the enabled notification types for this filter. 0N/A * @return The list containing all the enabled notification types.