1. /*
  2. * @(#)BeanContextChild.java 1.16 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.beans.PropertyChangeListener;
  12. import java.beans.VetoableChangeListener;
  13. import java.beans.PropertyVetoException;
  14. import java.beans.beancontext.BeanContext;
  15. /**
  16. * <p>
  17. * JavaBeans wishing to be nested within, and obtain a reference to their
  18. * execution environment, or context, as defined by the BeanContext
  19. * sub-interface shall implement this interface.
  20. * </p>
  21. * <p>
  22. * Conformant BeanContexts shall as a side effect of adding a BeanContextChild
  23. * object shall pass a reference to itself via the setBeanContext() method of
  24. * this interface.
  25. * </p>
  26. * <p>
  27. * Note that a BeanContextChild may refuse a change in state by throwing
  28. * PropertyVetoedException in response.
  29. * </p>
  30. * <p>
  31. * In order for persistence mechanisms to function properly on BeanContextChild
  32. * instances across a broad variety of scenarios, implementing classes of this
  33. * interface are required to define as transient, any or all fields, or
  34. * instance variables, that may contain, or represent, references to the
  35. * nesting BeanContext instance or other resources obtained
  36. * from the BeanContext via any unspecified mechanisms.
  37. * </p>
  38. *
  39. * @author Laurence P. G. Cable
  40. * @version 1.16, 02/02/00
  41. * @since 1.2
  42. *
  43. * @seealso java.beans.beancontext.BeanContext
  44. * @seealso java.beans.PropertyChangeEvent
  45. * @seealso java.beans.PropertyChangeListener
  46. * @seealso java.beans.PropertyVetoEvent
  47. * @seealso java.beans.PropertyVetoListener
  48. * @seealso java.beans.PropertyVetoException
  49. */
  50. public interface BeanContextChild {
  51. /**
  52. * <p>
  53. * Objects that implement this interface,
  54. * shall fire a java.beans.PropertyChangeEvent, with parameters:
  55. *
  56. * propertyName "beanContext", oldValue (the previous nesting
  57. * <code>BeanContext</code> instance, or <code>null</code>),
  58. * newValue (the current nesting
  59. * <code>BeanContext</code> instance, or <code>null</code>).
  60. * <p>
  61. * A change in the value of the nesting BeanContext property of this
  62. * BeanContextChild may be vetoed by throwing the appropriate exception.
  63. * </p>
  64. * @param bc The <code>BeanContext</code> with which
  65. * to associate this <code>BeanContextChild</code>.
  66. * @throws <code>PropertyVetoException</code> if the
  67. * addition of the specified <code>BeanContext</code> is refused.
  68. */
  69. void setBeanContext(BeanContext bc) throws PropertyVetoException;
  70. /**
  71. * Gets the <code>BeanContext</code> associated
  72. * with this <code>BeanContextChild</code>.
  73. * @return the <code>BeanContext</code> associated
  74. * with this <code>BeanContextChild</code>.
  75. */
  76. BeanContext getBeanContext();
  77. /**
  78. * Adds a <code>PropertyChangeListener</code>
  79. * to this <code>BeanContextChild</code>
  80. * in order to receive a <code>PropertyChangeEvent</code>
  81. * whenever the specified property has changed.
  82. * @param name the name of the property to listen on
  83. * @param pcl the <code>PropertyChangeListener</code> to add
  84. */
  85. void addPropertyChangeListener(String name, PropertyChangeListener pcl);
  86. /**
  87. * Removes a <code>PropertyChangeListener</code> from this
  88. * <code>BeanContextChild</code> so that it no longer
  89. * receives <code>PropertyChangeEvents</code> when the
  90. * specified property is changed.
  91. *
  92. * @param name the name of the property that was listened on
  93. * @param pcl the <code>PropertyChangeListener</code> to remove
  94. */
  95. void removePropertyChangeListener(String name, PropertyChangeListener pcl);
  96. /**
  97. * Adds a <code>VetoableChangeListener</code> to
  98. * this <code>BeanContextChild</code>
  99. * to receive events whenever the specified property changes.
  100. * @param name the name of the property to listen on
  101. * @param vcl the <code>VetoableChangeListener</code> to add
  102. */
  103. void addVetoableChangeListener(String name, VetoableChangeListener vcl);
  104. /**
  105. * Removes a <code>VetoableChangeListener</code> from this
  106. * <code>BeanContextChild</code> so that it no longer receives
  107. * events when the specified property changes.
  108. * @param name the name of the property that was listened on.
  109. * @param vcl the <code>VetoableChangeListener</code> to remove.
  110. */
  111. void removeVetoableChangeListener(String name, VetoableChangeListener vcl);
  112. }