# Interface BeanContext

All Superinterfaces:
  `BeanContextChild, Collection, DesignMode, Iterable, Visibility`

All Known Subinterfaces:
  `BeanContextServices`

All Known Implementing Classes:
  `BeanContextServicesSupport, BeanContextSupport`

@Deprecated(since="23", forRemoval=true) public interface BeanContext extends BeanContextChild, Collection, DesignMode, Visibility
Deprecated, for removal: This API element is subject to removal in a future version.

The BeanContext acts a logical hierarchical container for JavaBeans.

Since:
  1.2
See Also:
  - `Beans`
  - `BeanContextChild`
  - `BeanContextMembershipListener`
  - `PropertyChangeEvent`
  - `DesignMode`
  - `Visibility`
  - `Collection`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final Object`
  `globalHierarchyLock`
  Deprecated, for removal: This API element is subject to removal in a future version.
  This global lock is used by both `BeanContext` and `BeanContextServices` implementors to serialize changes in a `BeanContext` hierarchy and any service requests etc.

  ### Fields declared in interface DesignMode

  `PROPERTYNAME`
  Modifier and Type
  Field
  Description
  `static final String`
  `PROPERTYNAME`
  The standard value of the propertyName as fired from a BeanContext or other source of PropertyChangeEvents.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addBeanContextMembershipListener(BeanContextMembershipListener bcml)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Adds the specified `BeanContextMembershipListener` to receive `BeanContextMembershipEvents` from this `BeanContext` whenever it adds or removes a child `Component`(s).
  `URL`
  `getResource(String name, BeanContextChild bcc)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Analogous to `java.lang.ClassLoader.getResource()`, this method allows a `BeanContext` implementation to interpose behavior between the child `Component` and underlying `ClassLoader`.
  `InputStream`
  `getResourceAsStream(String name, BeanContextChild bcc)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Analogous to `java.lang.ClassLoader.getResourceAsStream()`, this method allows a `BeanContext` implementation to interpose behavior between the child `Component` and underlying `ClassLoader`.
  `Object`
  `instantiateChild(String beanName)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Instantiate the javaBean named as a child of this `BeanContext`.
  `void`
  `removeBeanContextMembershipListener(BeanContextMembershipListener bcml)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Removes the specified `BeanContextMembershipListener` so that it no longer receives `BeanContextMembershipEvent`s when the child `Component`(s) are added or removed.

  ### Methods declared in interface BeanContextChild

  `addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext`
  Modifier and Type
  Method
  Description
  `void`
  `addPropertyChangeListener(String name, PropertyChangeListener pcl)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Adds a `PropertyChangeListener` to this `BeanContextChild` in order to receive a `PropertyChangeEvent` whenever the specified property has changed.
  `void`
  `addVetoableChangeListener(String name, VetoableChangeListener vcl)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Adds a `VetoableChangeListener` to this `BeanContextChild` to receive events whenever the specified property changes.
  `BeanContext`
  `getBeanContext()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Gets the `BeanContext` associated with this `BeanContextChild`.
  `void`
  `removePropertyChangeListener(String name, PropertyChangeListener pcl)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Removes a `PropertyChangeListener` from this `BeanContextChild` so that it no longer receives `PropertyChangeEvents` when the specified property is changed.
  `void`
  `removeVetoableChangeListener(String name, VetoableChangeListener vcl)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Removes a `VetoableChangeListener` from this `BeanContextChild` so that it no longer receives events when the specified property changes.
  `void`
  `setBeanContext(BeanContext bc)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Objects that implement this interface, shall fire a java.beans.PropertyChangeEvent, with parameters: propertyName "beanContext", oldValue (the previous nesting `BeanContext` instance, or `null`), newValue (the current nesting `BeanContext` instance, or `null`).

  ### Methods declared in interface Collection

  `add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, remove, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray, toArray`
  Modifier and Type
  Method
  Description
  `boolean`
  `add(Object e)`
  Ensures that this collection contains the specified element (optional operation).
  `boolean`
  `addAll(Collection c)`
  Adds all of the elements in the specified collection to this collection (optional operation).
  `void`
  `clear()`
  Removes all of the elements from this collection (optional operation).
  `boolean`
  `contains(Object o)`
  Returns `true` if this collection contains the specified element.
  `boolean`
  `containsAll(Collection c)`
  Returns `true` if this collection contains all of the elements in the specified collection.
  `boolean`
  `equals(Object o)`
  Compares the specified object with this collection for equality.
  `int`
  `hashCode()`
  Returns the hash code value for this collection.
  `boolean`
  `isEmpty()`
  Returns `true` if this collection contains no elements.
  `Iterator`
  `iterator()`
  Returns an iterator over the elements in this collection.
  `default Stream`
  `parallelStream()`
  Returns a possibly parallel `Stream` with this collection as its source.
  `boolean`
  `remove(Object o)`
  Removes a single instance of the specified element from this collection, if it is present (optional operation).
  `boolean`
  `removeAll(Collection c)`
  Removes all of this collection's elements that are also contained in the specified collection (optional operation).
  `default boolean`
  `removeIf(Predicate filter)`
  Removes all of the elements of this collection that satisfy the given predicate (optional operation).
  `boolean`
  `retainAll(Collection c)`
  Retains only the elements in this collection that are contained in the specified collection (optional operation).
  `int`
  `size()`
  Returns the number of elements in this collection.
  `default Spliterator`
  `spliterator()`
  Creates a `Spliterator` over the elements in this collection.
  `default Stream`
  `stream()`
  Returns a sequential `Stream` with this collection as its source.
  `Object[]`
  `toArray()`
  Returns an array containing all of the elements in this collection.
  `default <T> Object[]`
  `toArray(IntFunction generator)`
  Returns an array containing all of the elements in this collection, using the provided `generator` function to allocate the returned array.
  `<T> Object[]`
  `toArray(Object[] a)`
  Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.

  ### Methods declared in interface DesignMode

  `isDesignTime, setDesignTime`
  Modifier and Type
  Method
  Description
  `boolean`
  `isDesignTime()`
  A value of true denotes that JavaBeans should behave in design time mode, a value of false denotes runtime behavior.
  `void`
  `setDesignTime(boolean designTime)`
  Sets the "value" of the "designTime" property.

  ### Methods declared in interface Iterable

  `forEach`
  Modifier and Type
  Method
  Description
  `default void`
  `forEach(Consumer action)`
  Performs the given action for each element of the `Iterable` until all elements have been processed or the action throws an exception.

  ### Methods declared in interface Visibility

  `avoidingGui, dontUseGui, needsGui, okToUseGui`
  Modifier and Type
  Method
  Description
  `boolean`
  `avoidingGui()`
  Determines whether this bean is avoiding using a GUI.
  `void`
  `dontUseGui()`
  This method instructs the bean that it should not use the Gui.
  `boolean`
  `needsGui()`
  Determines whether this bean needs a GUI.
  `void`
  `okToUseGui()`
  This method instructs the bean that it is OK to use the Gui.

- ## Field Details

  - ### globalHierarchyLock

    static final Object globalHierarchyLock
    Deprecated, for removal: This API element is subject to removal in a future version.
    This global lock is used by both `BeanContext` and `BeanContextServices` implementors to serialize changes in a `BeanContext` hierarchy and any service requests etc.

- ## Method Details

  - ### instantiateChild

    Object instantiateChild(String beanName) throws IOException, ClassNotFoundException
    Deprecated, for removal: This API element is subject to removal in a future version.
    Instantiate the javaBean named as a child of this `BeanContext`. The implementation of the JavaBean is derived from the value of the beanName parameter, and is defined by the `java.beans.Beans.instantiate()` method.
    Parameters:
      `beanName` - The name of the JavaBean to instantiate as a child of this `BeanContext`
    Returns:
      a javaBean named as a child of this `BeanContext`
    Throws:
      `IOException` - if an IO problem occurs
      `ClassNotFoundException` - if the class identified by the beanName parameter is not found

  - ### getResourceAsStream

    InputStream getResourceAsStream(String name, BeanContextChild bcc) throws IllegalArgumentException
    Deprecated, for removal: This API element is subject to removal in a future version.
    Analogous to `java.lang.ClassLoader.getResourceAsStream()`, this method allows a `BeanContext` implementation to interpose behavior between the child `Component` and underlying `ClassLoader`.
    Parameters:
      `name` - the resource name
      `bcc` - the specified child
    Returns:
      an `InputStream` for reading the resource, or `null` if the resource could not be found.
    Throws:
      `IllegalArgumentException` - if the resource is not valid

  - ### getResource

    URL getResource(String name, BeanContextChild bcc) throws IllegalArgumentException
    Deprecated, for removal: This API element is subject to removal in a future version.
    Analogous to `java.lang.ClassLoader.getResource()`, this method allows a `BeanContext` implementation to interpose behavior between the child `Component` and underlying `ClassLoader`.
    Parameters:
      `name` - the resource name
      `bcc` - the specified child
    Returns:
      a `URL` for the named resource for the specified child
    Throws:
      `IllegalArgumentException` - if the resource is not valid

  - ### addBeanContextMembershipListener

    void addBeanContextMembershipListener(BeanContextMembershipListener bcml)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Adds the specified `BeanContextMembershipListener` to receive `BeanContextMembershipEvents` from this `BeanContext` whenever it adds or removes a child `Component`(s).
    Parameters:
      `bcml` - the BeanContextMembershipListener to be added

  - ### removeBeanContextMembershipListener

    void removeBeanContextMembershipListener(BeanContextMembershipListener bcml)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Removes the specified `BeanContextMembershipListener` so that it no longer receives `BeanContextMembershipEvent`s when the child `Component`(s) are added or removed.
    Parameters:
      `bcml` - the `BeanContextMembershipListener` to be removed