jdk/src/share/classes/javax/management/event/NotificationManager.java
changeset 4156 acaa49a2768a
parent 4155 460e37d40f12
child 4159 9e3aae7675f1
equal deleted inserted replaced
4155:460e37d40f12 4156:acaa49a2768a
     1 /*
       
     2  * Copyright 2007-2008 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 
       
    26 package javax.management.event;
       
    27 
       
    28 import java.io.IOException;
       
    29 import javax.management.InstanceNotFoundException;
       
    30 import javax.management.ListenerNotFoundException;
       
    31 import javax.management.NotificationFilter;
       
    32 import javax.management.NotificationListener;
       
    33 import javax.management.ObjectName;
       
    34 
       
    35 /**
       
    36  * This interface specifies methods to add and remove notification listeners
       
    37  * on named MBeans.
       
    38  */
       
    39 public interface NotificationManager {
       
    40     /**
       
    41      * <p>Adds a listener to a registered MBean.
       
    42      * Notifications emitted by the MBean will be forwarded
       
    43      * to the listener.
       
    44      *
       
    45      * @param name The name of the MBean on which the listener should
       
    46      * be added.
       
    47      * @param listener The listener object which will handle the
       
    48      * notifications emitted by the registered MBean.
       
    49      * @param filter The filter object. If filter is null, no
       
    50      * filtering will be performed before handling notifications.
       
    51      * @param handback The context to be sent to the listener when a
       
    52      * notification is emitted.
       
    53      *
       
    54      * @exception InstanceNotFoundException The MBean name provided
       
    55      * does not match any of the registered MBeans.
       
    56      * @exception IOException A communication problem occurred when
       
    57      * talking to the MBean server.
       
    58      *
       
    59      * @see #removeNotificationListener(ObjectName, NotificationListener)
       
    60      * @see #removeNotificationListener(ObjectName, NotificationListener,
       
    61      * NotificationFilter, Object)
       
    62      */
       
    63     public void addNotificationListener(ObjectName name,
       
    64             NotificationListener listener,
       
    65             NotificationFilter filter,
       
    66             Object handback)
       
    67             throws InstanceNotFoundException,
       
    68             IOException;
       
    69 
       
    70     /**
       
    71      * <p>Removes a listener from a registered MBean.</p>
       
    72      *
       
    73      * <P> If the listener is registered more than once, perhaps with
       
    74      * different filters or callbacks, this method will remove all
       
    75      * those registrations.
       
    76      *
       
    77      * @param name The name of the MBean on which the listener should
       
    78      * be removed.
       
    79      * @param listener The listener to be removed.
       
    80      *
       
    81      * @exception InstanceNotFoundException The MBean name provided
       
    82      * does not match any of the registered MBeans.
       
    83      * @exception ListenerNotFoundException The listener is not
       
    84      * registered in the MBean.
       
    85      * @exception IOException A communication problem occurred when
       
    86      * talking to the MBean server.
       
    87      *
       
    88      * @see #addNotificationListener(ObjectName, NotificationListener,
       
    89      * NotificationFilter, Object)
       
    90      */
       
    91     public void removeNotificationListener(ObjectName name,
       
    92             NotificationListener listener)
       
    93             throws InstanceNotFoundException,
       
    94             ListenerNotFoundException,
       
    95             IOException;
       
    96 
       
    97     /**
       
    98      * <p>Removes a listener from a registered MBean.</p>
       
    99      *
       
   100      * <p>The MBean must have a listener that exactly matches the
       
   101      * given <code>listener</code>, <code>filter</code>, and
       
   102      * <code>handback</code> parameters.  If there is more than one
       
   103      * such listener, only one is removed.</p>
       
   104      *
       
   105      * <p>The <code>filter</code> and <code>handback</code> parameters
       
   106      * may be null if and only if they are null in a listener to be
       
   107      * removed.</p>
       
   108      *
       
   109      * @param name The name of the MBean on which the listener should
       
   110      * be removed.
       
   111      * @param listener The listener to be removed.
       
   112      * @param filter The filter that was specified when the listener
       
   113      * was added.
       
   114      * @param handback The handback that was specified when the
       
   115      * listener was added.
       
   116      *
       
   117      * @exception InstanceNotFoundException The MBean name provided
       
   118      * does not match any of the registered MBeans.
       
   119      * @exception ListenerNotFoundException The listener is not
       
   120      * registered in the MBean, or it is not registered with the given
       
   121      * filter and handback.
       
   122      * @exception IOException A communication problem occurred when
       
   123      * talking to the MBean server.
       
   124      *
       
   125      * @see #addNotificationListener(ObjectName, NotificationListener,
       
   126      * NotificationFilter, Object)
       
   127      *
       
   128      */
       
   129     public void removeNotificationListener(ObjectName name,
       
   130             NotificationListener listener,
       
   131             NotificationFilter filter,
       
   132             Object handback)
       
   133             throws InstanceNotFoundException,
       
   134             ListenerNotFoundException,
       
   135             IOException;
       
   136 }