jdk/src/share/classes/javax/management/event/EventReceiver.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 javax.management.remote.NotificationResult;
       
    29 
       
    30 /**
       
    31  * An object implementing this interface is passed by an {@link EventClient}
       
    32  * to its {@link EventRelay}, to allow the {@code EventRelay} to communicate
       
    33  * received notifications to the {@code EventClient}.
       
    34  *
       
    35  * @see <a href="package-summary.html#transports">Custom notification
       
    36  * transports</a>
       
    37  */
       
    38 public interface EventReceiver {
       
    39 
       
    40     /**
       
    41      * This method is implemented by {@code EventClient} as a callback to
       
    42      * receive notifications from {@code EventRelay}.
       
    43      * <P>The notifications are included in an object specified by the class
       
    44      * {@link NotificationResult}. In
       
    45      * addition to a set of notifications, the class object also contains two values:
       
    46      * {@code earliestSequenceNumber} and {@code nextSequenceNumber}.
       
    47      * These two values determine whether any notifications have been lost.
       
    48      * The {@code nextSequenceNumber} value of the last time is compared
       
    49      * to the received value {@code earliestSequenceNumber}. If the
       
    50      * received {@code earliesSequenceNumber} is greater, than the difference
       
    51      * signifies the number of lost notifications. A sender should
       
    52      * ensure the sequence of notifications sent, meaning that the value
       
    53      * {@code earliestSequenceNumber} of the next return should be always equal to
       
    54      * or greater than the value {@code nextSequenceNumber} of the last return.
       
    55      *
       
    56      * @param nr the received notifications and sequence numbers.
       
    57      */
       
    58     public void receive(NotificationResult nr);
       
    59 
       
    60     /**
       
    61      * Allows the {@link EventRelay} to report when it receives an unexpected
       
    62      * exception, which may be fatal and which may make it stop receiving
       
    63      * notifications.
       
    64      *
       
    65      * @param t The unexpected exception received while {@link EventRelay} was running.
       
    66      */
       
    67     public void failed(Throwable t);
       
    68 
       
    69     /**
       
    70      * Allows the {@link EventRelay} to report when it receives an unexpected
       
    71      * exception that is not fatal. For example, a notification received is not
       
    72      * serializable or its class is not found.
       
    73      *
       
    74      * @param e The unexpected exception received while notifications are being received.
       
    75      */
       
    76     public void nonFatal(Exception e);
       
    77 }