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