J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1999 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.naming.event; |
| 27 | |
| 28 | import javax.naming.NamingException; |
| 29 | |
| 30 | /** |
| 31 | * This class represents an event fired when the procedures/processes |
| 32 | * used to collect information for notifying listeners of |
| 33 | * <tt>NamingEvent</tt>s threw a <tt>NamingException</tt>. |
| 34 | * This can happen, for example, if the server which the listener is using |
| 35 | * aborts subsequent to the <tt>addNamingListener()</tt> call. |
| 36 | * |
| 37 | * @author Rosanna Lee |
| 38 | * @author Scott Seligman |
| 39 | * |
| 40 | * @see NamingListener#namingExceptionThrown |
| 41 | * @see EventContext |
| 42 | * @since 1.3 |
| 43 | */ |
| 44 | |
| 45 | public class NamingExceptionEvent extends java.util.EventObject { |
| 46 | /** |
| 47 | * Contains the exception that was thrown |
| 48 | * @serial |
| 49 | */ |
| 50 | private NamingException exception; |
| 51 | |
| 52 | /** |
| 53 | * Constructs an instance of <tt>NamingExceptionEvent</tt> using |
| 54 | * the context in which the <tt>NamingException</tt> was thrown and the exception |
| 55 | * that was thrown. |
| 56 | * |
| 57 | * @param source The non-null context in which the exception was thrown. |
| 58 | * @param exc The non-null <tt>NamingException</tt> that was thrown. |
| 59 | * |
| 60 | */ |
| 61 | public NamingExceptionEvent(EventContext source, NamingException exc) { |
| 62 | super(source); |
| 63 | exception = exc; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Retrieves the exception that was thrown. |
| 68 | * @return The exception that was thrown. |
| 69 | */ |
| 70 | public NamingException getException() { |
| 71 | return exception; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Retrieves the <tt>EventContext</tt> that fired this event. |
| 76 | * This returns the same object as <tt>EventObject.getSource()</tt>. |
| 77 | * @return The non-null <tt>EventContext</tt> that fired this event. |
| 78 | */ |
| 79 | public EventContext getEventContext() { |
| 80 | return (EventContext)getSource(); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Invokes the <tt>namingExceptionThrown()</tt> method on |
| 85 | * a listener using this event. |
| 86 | * @param listener The non-null naming listener on which to invoke |
| 87 | * the method. |
| 88 | */ |
| 89 | public void dispatch(NamingListener listener) { |
| 90 | listener.namingExceptionThrown(this); |
| 91 | } |
| 92 | |
| 93 | private static final long serialVersionUID = -4877678086134736336L; |
| 94 | } |