1. /*
  2. * @(#)NamingExceptionEvent.java 1.7 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.naming.event;
  8. import javax.naming.NamingException;
  9. /**
  10. * This class represents an event fired when the procedures/processes
  11. * used to collect information for notifying listeners of
  12. * <tt>NamingEvent</tt>s threw a <tt>NamingException</tt>.
  13. * This can happen, for example, if the server which the listener is using
  14. * aborts subsequent to the <tt>addNamingListener()</tt> call.
  15. *
  16. * @author Rosanna Lee
  17. * @author Scott Seligman
  18. * @version 1.7 03/12/19
  19. *
  20. * @see NamingListener#namingExceptionThrown
  21. * @see EventContext
  22. * @since 1.3
  23. */
  24. public class NamingExceptionEvent extends java.util.EventObject {
  25. /**
  26. * Contains the exception that was thrown
  27. * @serial
  28. */
  29. private NamingException exception;
  30. /**
  31. * Constructs an instance of <tt>NamingExceptionEvent</tt> using
  32. * the context in which the <tt>NamingException</tt> was thrown and the exception
  33. * that was thrown.
  34. *
  35. * @param source The non-null context in which the exception was thrown.
  36. * @param exc The non-null <tt>NamingException</tt> that was thrown.
  37. *
  38. */
  39. public NamingExceptionEvent(EventContext source, NamingException exc) {
  40. super(source);
  41. exception = exc;
  42. }
  43. /**
  44. * Retrieves the exception that was thrown.
  45. * @return The exception that was thrown.
  46. */
  47. public NamingException getException() {
  48. return exception;
  49. }
  50. /**
  51. * Retrieves the <tt>EventContext</tt> that fired this event.
  52. * This returns the same object as <tt>EventObject.getSource()</tt>.
  53. * @return The non-null <tt>EventContext</tt> that fired this event.
  54. */
  55. public EventContext getEventContext() {
  56. return (EventContext)getSource();
  57. }
  58. /**
  59. * Invokes the <tt>namingExceptionThrown()</tt> method on
  60. * a listener using this event.
  61. * @param listener The non-null naming listener on which to invoke
  62. * the method.
  63. */
  64. public void dispatch(NamingListener listener) {
  65. listener.namingExceptionThrown(this);
  66. }
  67. private static final long serialVersionUID = -4877678086134736336L;
  68. }