1. /*
  2. * @(#)BeanContextEvent.java 1.9 00/02/02
  3. *
  4. * Copyright 1997-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 java.beans.beancontext;
  11. import java.util.EventObject;
  12. import java.beans.beancontext.BeanContext;
  13. /**
  14. * <p>
  15. * <code>BeanContextEvent</code> is the abstract root event class
  16. * for all events emitted
  17. * from, and pertaining to the semantics of, a <code>BeanContext</code>.
  18. * This class introduces a mechanism to allow the propagation of
  19. * <code>BeanContextEvent</code> subclasses through a heirarchy of
  20. * <code>BeanContext</code>s. The <code>setPropagatedFrom()</code>
  21. * and <code>getPropagatedFrom()</code> methods allow a
  22. * <code>BeanContext</code> to identify itself as the source
  23. * of a propagated event.
  24. * </p>
  25. *
  26. * @author Laurence P. G. Cable
  27. * @version 1.9, 02/02/00
  28. * @since 1.2
  29. * @see java.beans.beancontext.BeanContext
  30. */
  31. public abstract class BeanContextEvent extends EventObject {
  32. /**
  33. * Contruct a BeanContextEvent
  34. *
  35. * @param bc The BeanContext source
  36. */
  37. protected BeanContextEvent(BeanContext bc) {
  38. super(bc);
  39. }
  40. /**
  41. * Gets the <code>BeanContext</code> associated with this event.
  42. * @return the <code>BeanContext</code> associated with this event.
  43. */
  44. public BeanContext getBeanContext() { return (BeanContext)getSource(); }
  45. /**
  46. * Sets the <code>BeanContext</code> from which this event was propagated.
  47. * @param bc the <code>BeanContext</code> from which this event
  48. * was propagated
  49. */
  50. public synchronized void setPropagatedFrom(BeanContext bc) {
  51. propagatedFrom = bc;
  52. }
  53. /**
  54. * Gets the <code>BeanContext</code> from which this event was propagated.
  55. * @param bc The <code>BeanContext</code> that last
  56. * propagated this <code>BeanContextEvent</code>
  57. * @return the <code>BeanContext</code> from which this
  58. * event was propagated
  59. */
  60. public synchronized BeanContext getPropagatedFrom() {
  61. return propagatedFrom;
  62. }
  63. /**
  64. * Reports whether or not this event is
  65. * propagated from some other <code>BeanContext</code>.
  66. * @return <code>true</code> if propagated, <code>false</code>
  67. * if not
  68. */
  69. public synchronized boolean isPropagated() {
  70. return propagatedFrom != null;
  71. }
  72. /*
  73. * fields
  74. */
  75. /**
  76. * The <code>BeanContext</code> from which this event was propagated
  77. */
  78. protected BeanContext propagatedFrom;
  79. }