1. /*
  2. * @(#)BeanContextChild.java 1.12 01/11/29
  3. *
  4. * Copyright 2002 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.beans.PropertyChangeListener;
  9. import java.beans.VetoableChangeListener;
  10. import java.beans.PropertyVetoException;
  11. import java.beans.beancontext.BeanContext;
  12. /**
  13. * <p>
  14. * JavaBeans wishing to be nested within, and obtain a reference to their
  15. * execution environment, or context, as defined by the BeanContext
  16. * sub-interface shall implement this interface.
  17. * </p>
  18. * <p>
  19. * Conformant BeanContexts shall as a side effect of adding a BeanContextChild
  20. * object shall pass a reference to itself via the setBeanContext() method of
  21. * this interface.
  22. * </p>
  23. * <p>
  24. * Note that a BeanContextChild may refuse a change in state by throwing
  25. * PropertyVetoedException in response.
  26. * </p>
  27. * <p>
  28. * In order for persistence mechanisms to function properly on BeanContextChild
  29. * instances across a broad variety of scenarios, implementing classes of this
  30. * interface are required to define as transient, any or all fields, or
  31. * instance variables, that may contain, or represent, references to the
  32. * nesting BeanContext instance or other resources obtained
  33. * from the BeanContext via any unspecified mechanisms.
  34. * </p>
  35. *
  36. * @author Laurence P. G. Cable
  37. * @version 1.12
  38. * @since JDK1.2
  39. *
  40. * @seealso java.beans.beancontext.BeanContext
  41. * @seealso java.beans.PropertyChangeEvent
  42. * @seealso java.beans.PropertyChangeListener
  43. * @seealso java.beans.PropertyVetoEvent
  44. * @seealso java.beans.PropertyVetoListener
  45. * @seealso java.beans.PropertyVetoException
  46. */
  47. public interface BeanContextChild {
  48. /**
  49. * <p>
  50. * Objects that implement this interface,
  51. * shall fire a java.beans.PropertyChangeEvent, with parameters:
  52. *
  53. * @param propertyName "beanContext"
  54. * @param oldValue the previous nesting BeanContext instance, or null
  55. * @param newValue the current nesting BeanContext instance, or null
  56. * </p>
  57. * <p>
  58. * A change in the value of the nesting BeanContext property of this
  59. * BeanContextChild may be vetoed by throwing the appropriate exception.
  60. * </p>
  61. */
  62. void setBeanContext(BeanContext bc) throws PropertyVetoException;
  63. /**
  64. * @returns the current BeanContext associated with the JavaBean
  65. */
  66. BeanContext getBeanContext();
  67. /**
  68. * add a property change listener to this bean child
  69. */
  70. void addPropertyChangeListener(String name, PropertyChangeListener pcl);
  71. /**
  72. * remove a property change listener to this bean child
  73. */
  74. void removePropertyChangeListener(String name, PropertyChangeListener pcl);
  75. /**
  76. * add a vetoable change listener to this child
  77. */
  78. void addVetoableChangeListener(String name, VetoableChangeListener vcl);
  79. /**
  80. * remove a vetoable change listener to this child
  81. */
  82. void removeVetoableChangeListener(String name, VetoableChangeListener vcl);
  83. }