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