1. /*
  2. * @(#)BeanContext.java 1.19 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.DesignMode;
  12. import java.beans.Visibility;
  13. import java.io.InputStream;
  14. import java.io.IOException;
  15. import java.net.URL;
  16. import java.util.Collection;
  17. import java.util.Locale;
  18. /**
  19. * <p>
  20. * The BeanContext acts a logical hierarchical container for JavaBeans.
  21. * </p>
  22. *
  23. * @author Laurence P. G. Cable
  24. * @version 1.19, 02/02/00
  25. * @since 1.2
  26. *
  27. * @seealso java.beans.Beans
  28. * @seealso java.beans.beancontext.BeanContextChild
  29. * @seealso java.beans.beancontext.BeanContextMembershipListener
  30. * @seealso java.beans.PropertyChangeEvent
  31. * @seealso java.beans.VetoableChangeEvent
  32. * @seealso java.beans.DesignMode
  33. * @seealso java.beans.Visibility
  34. * @seealso java.util.Collection
  35. */
  36. public interface BeanContext extends BeanContextChild, Collection, DesignMode, Visibility {
  37. /**
  38. * Instantiate the javaBean named as a
  39. * child of this <code>BeanContext</code>.
  40. * The implementation of the JavaBean is
  41. * derived from the value of the beanName parameter,
  42. * and is defined by the
  43. * <code>java.beans.Beans.instantiate()</code> method.
  44. *
  45. * @param beanName The name of the JavaBean to instantiate
  46. * as a child of this <code>BeanContext</code>
  47. * @throws <code>IOException</code>
  48. * @throws <code>ClassNotFoundException</code> if the class identified
  49. * by the beanName parameter is not found
  50. */
  51. Object instantiateChild(String beanName) throws IOException, ClassNotFoundException;
  52. /**
  53. * Analagous to <code>java.lang.ClassLoader.getResourceAsStream()</code>,
  54. * this method allows a <code>BeanContext</code> implementation
  55. * to interpose behavior between the child <code>Component</code>
  56. * and underlying <code>ClassLoader</code>.
  57. *
  58. * @param name the resource name
  59. * @param bcc the specified child
  60. * @return an <code>InputStream</code> for reading the resource,
  61. * or <code>null</code> if the resource could not
  62. * be found.
  63. * @throws <code>IllegalArgumentException</code> if
  64. * the resource is not valid
  65. */
  66. InputStream getResourceAsStream(String name, BeanContextChild bcc) throws IllegalArgumentException;
  67. /**
  68. * Analagous to <code>java.lang.ClassLoader.getResource()</code>, this
  69. * method allows a <code>BeanContext</code> implementation to interpose
  70. * behavior between the child <code>Component</code>
  71. * and underlying <code>ClassLoader</code>.
  72. *
  73. * @param name the resource name
  74. * @param bcc the specified child
  75. * @return a <code>URL</code> for the named
  76. * resource for the specified child
  77. * @throws <code>IllegalArgumentException</code>
  78. * if the resource is not valid
  79. */
  80. URL getResource(String name, BeanContextChild bcc) throws IllegalArgumentException;
  81. /**
  82. * Adds the specified <code>BeanContextMembershipListener</code>
  83. * to receive <code>BeanContextMembershipEvents</code> from
  84. * this <code>BeanContext</code> whenever it adds
  85. * or removes a child <code>Component</code>(s).
  86. *
  87. * @param bcml the <code>BeanContextMembershipListener</code> to be added
  88. */
  89. void addBeanContextMembershipListener(BeanContextMembershipListener bcml);
  90. /**
  91. * Removes the specified <code>BeanContextMembershipListener</code>
  92. * so that it no longer receives <code>BeanContextMembershipEvent</code>s
  93. * when the child <code>Component</code>(s) are added or removed.
  94. *
  95. * @param bcml the <code>BeanContextMembershipListener</code>
  96. * to be removed
  97. */
  98. void removeBeanContextMembershipListener(BeanContextMembershipListener bcml);
  99. /**
  100. * This global lock is used by both <code>BeanContext</code>
  101. * and <code>BeanContextServices</code> implementors
  102. * to serialize changes in a <code>BeanContext</code>
  103. * hierarchy and any service requests etc.
  104. */
  105. public static final Object globalHierarchyLock = new Object();
  106. }