01 /*
02 * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
03 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04 *
05 * This code is free software; you can redistribute it and/or modify it
06 * under the terms of the GNU General Public License version 2 only, as
07 * published by the Free Software Foundation. Sun designates this
08 * particular file as subject to the "Classpath" exception as provided
09 * 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 * @version 1.14 07/05/05
40 *
41 * @see NamingListener#namingExceptionThrown
42 * @see EventContext
43 * @since 1.3
44 */
45
46 public class NamingExceptionEvent extends java.util.EventObject {
47 /**
48 * Contains the exception that was thrown
49 * @serial
50 */
51 private NamingException exception;
52
53 /**
54 * Constructs an instance of <tt>NamingExceptionEvent</tt> using
55 * the context in which the <tt>NamingException</tt> was thrown and the exception
56 * that was thrown.
57 *
58 * @param source The non-null context in which the exception was thrown.
59 * @param exc The non-null <tt>NamingException</tt> that was thrown.
60 *
61 */
62 public NamingExceptionEvent(EventContext source, NamingException exc) {
63 super (source);
64 exception = exc;
65 }
66
67 /**
68 * Retrieves the exception that was thrown.
69 * @return The exception that was thrown.
70 */
71 public NamingException getException() {
72 return exception;
73 }
74
75 /**
76 * Retrieves the <tt>EventContext</tt> that fired this event.
77 * This returns the same object as <tt>EventObject.getSource()</tt>.
78 * @return The non-null <tt>EventContext</tt> that fired this event.
79 */
80 public EventContext getEventContext() {
81 return (EventContext) getSource();
82 }
83
84 /**
85 * Invokes the <tt>namingExceptionThrown()</tt> method on
86 * a listener using this event.
87 * @param listener The non-null naming listener on which to invoke
88 * the method.
89 */
90 public void dispatch(NamingListener listener) {
91 listener.namingExceptionThrown(this );
92 }
93
94 private static final long serialVersionUID = -4877678086134736336L;
95 }
|