org.apache.beehive.controls.runtime.webcontext
Class ControlBeanContextSupport

Object
  extended by ControlBeanContextChildSupport
      extended by ControlBeanContextSupport
All Implemented Interfaces:
BeanContext, BeanContextChild, BeanContextServiceRevokedListener, BeanContextServicesListener, DesignMode, PropertyChangeListener, VetoableChangeListener, Visibility, Serializable, Iterable, Collection, EventListener
Direct Known Subclasses:
ControlBeanContextServicesSupport

public class ControlBeanContextSupport
extends ControlBeanContextChildSupport
implements BeanContext, Serializable, PropertyChangeListener, VetoableChangeListener

BeanContext implementation for Beehive Controls.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface BeanContext
globalHierarchyLock
 
Fields inherited from interface DesignMode
PROPERTYNAME
 
Constructor Summary
ControlBeanContextSupport()
          Constructor.
ControlBeanContextSupport(BeanContext peer)
          Constructor.
 
Method Summary
 boolean add(Object o)
          Add a child to this BeanContext.
 boolean addAll(Collection c)
          Not supported.
 void addBeanContextMembershipListener(BeanContextMembershipListener bcml)
          Adds the specified BeanContextMembershipListener to receive BeanContextMembershipEvents from this BeanContext whenever it adds or removes a child Component(s).
 boolean avoidingGui()
          Determines whether this bean is avoiding using a GUI.
 void clear()
          Not supported.
 boolean contains(Object o)
          Returns true if this BeanContext contains the specified child.
 boolean containsAll(Collection c)
          Returns true if this BeanContext contains all of the children in the specified collection.
 void dontUseGui()
          This method instructs the bean that it should not use the Gui.
 URL getResource(String name, BeanContextChild bcc)
          Analagous 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)
          Analagous to java.lang.ClassLoader.getResourceAsStream(), this method allows a BeanContext implementation to interpose behavior between the child Component and underlying ClassLoader.
protected  void initialize()
          Init this classes data structures.
 Object instantiateChild(String beanName)
          Instantiate the javaBean named as a child of this BeanContext.
 boolean isDesignTime()
          A value of true denotes that JavaBeans should behave in design time mode, a value of false denotes runtime behavior.
 boolean isEmpty()
          Returns true if this BeanContext has no children.
 Iterator iterator()
          Returns an iterator over the elements in this collection.
 boolean needsGui()
          Determines whether this bean needs a GUI.
 void okToUseGui()
          This method instructs the bean that it is OK to use the Gui.
 void propertyChange(PropertyChangeEvent evt)
          This method gets called when a bound property is changed.
 void readChildren(ObjectInputStream in)
          This public api is necessary to allow a bean context with a peer to deserialize its children.
 boolean remove(Object o)
          Remove the specified child from this BeanContext.
 boolean removeAll(Collection c)
          Not supported.
 void removeBeanContextMembershipListener(BeanContextMembershipListener bcml)
          Removes the specified BeanContextMembershipListener so that it no longer receives BeanContextMembershipEvents when the child Component(s) are added or removed.
 boolean retainAll(Collection c)
          Not supported.
 void setDesignTime(boolean designTime)
          Sets the "value" of the "designTime" property.
 int size()
          Returns the number of children in this BeanContext.
 Object[] toArray()
          Returns an array containing all of the children in this BeanContext.
 Object[] toArray(Object[] a)
          Returns an array containing all of the children of this BeanContext; the runtime type of the returned array is that of the specified array.
 void vetoableChange(PropertyChangeEvent evt)
          This method gets called when a constrained property is changed.
 void writeChildren(ObjectOutputStream oos)
          Necessary for the case of this bean context having a peer.
 
Methods inherited from class ControlBeanContextChildSupport
addPropertyChangeListener, addVetoableChangeListener, firePropertyChange, getBeanContext, getPeer, releaseBeanContextResources, removePropertyChangeListener, removeVetoableChangeListener, serviceAvailable, serviceRevoked, setBeanContext
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface BeanContextChild
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
 
Methods inherited from interface Collection
equals, hashCode
 

Constructor Detail

ControlBeanContextSupport

public ControlBeanContextSupport()
Constructor.


ControlBeanContextSupport

public ControlBeanContextSupport(BeanContext peer)
Constructor.

Parameters:
peer -
Method Detail

instantiateChild

public Object instantiateChild(String beanName)
                        throws IOException,
                               ClassNotFoundException
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.

Specified by:
instantiateChild in interface BeanContext
Parameters:
beanName - The name of the JavaBean to instantiate as a child of this BeanContext
Throws:
IOException
ClassNotFoundException - if the class identified by the beanName parameter is not found

getResourceAsStream

public InputStream getResourceAsStream(String name,
                                       BeanContextChild bcc)
                                throws IllegalArgumentException
Analagous to java.lang.ClassLoader.getResourceAsStream(), this method allows a BeanContext implementation to interpose behavior between the child Component and underlying ClassLoader.

Specified by:
getResourceAsStream in interface BeanContext
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

public URL getResource(String name,
                       BeanContextChild bcc)
                throws IllegalArgumentException
Analagous to java.lang.ClassLoader.getResource(), this method allows a BeanContext implementation to interpose behavior between the child Component and underlying ClassLoader.

Specified by:
getResource in interface BeanContext
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

public void addBeanContextMembershipListener(BeanContextMembershipListener bcml)
Adds the specified BeanContextMembershipListener to receive BeanContextMembershipEvents from this BeanContext whenever it adds or removes a child Component(s).

Specified by:
addBeanContextMembershipListener in interface BeanContext
Parameters:
bcml - the BeanContextMembershipListener to be added

removeBeanContextMembershipListener

public void removeBeanContextMembershipListener(BeanContextMembershipListener bcml)
Removes the specified BeanContextMembershipListener so that it no longer receives BeanContextMembershipEvents when the child Component(s) are added or removed.

Specified by:
removeBeanContextMembershipListener in interface BeanContext
Parameters:
bcml - the BeanContextMembershipListener to be removed

size

public int size()
Returns the number of children in this BeanContext. If this BeanContext contains more than Integer.MAX_VALUE children, returns Integer.MAX_VALUE.

Specified by:
size in interface Collection
Returns:
the number of elements in this collection

isEmpty

public boolean isEmpty()
Returns true if this BeanContext has no children.

Specified by:
isEmpty in interface Collection

contains

public boolean contains(Object o)
Returns true if this BeanContext contains the specified child.

Specified by:
contains in interface Collection
Parameters:
o - element whose presence in this BeanContext is to be tested.
Returns:
true if this BeanContext contains the specified child
Throws:
ClassCastException - if the type of the specified element is incompatible with this collection (optional).
NullPointerException - if the specified element is null and this collection does not support null elements (optional).

iterator

public Iterator iterator()
Returns an iterator over the elements in this collection. The iterator's collection is non-modifiable and element does not correspond to the order that children are added.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface Collection
Returns:
an Iterator over the children of this BeanContext

toArray

public Object[] toArray()
Returns an array containing all of the children in this BeanContext.

The returned array will be "safe" in that no references to it are maintained by this collection. (In other words, this method must allocate a new array even if this collection is backed by an array). The caller is thus free to modify the returned array.

This method acts as bridge between array-based and collection-based APIs.

Specified by:
toArray in interface Collection
Returns:
an array containing all of the elements in this collection

add

public boolean add(Object o)
Add a child to this BeanContext. If the child is already a child of this bean context this method returns immediately with a return value of false.

If the child implements the BeanContextProxy interface, the child AND the BeanContextChild referenced by the proxy are added to this BeanContext.

Specified by:
add in interface Collection
Parameters:
o - element whose presence in this collection is to be ensured.
Returns:
true if this collection changed as a result of the call
Throws:
UnsupportedOperationException - add is not supported by this collection.
ClassCastException - class of the specified element prevents it from being added to this collection.
NullPointerException - if the specified element is null and this collection does not support null elements.
IllegalArgumentException - some aspect of this element prevents it from being added to this collection.

remove

public boolean remove(Object o)
Remove the specified child from this BeanContext. If the child to be removed implements the BeanContextProxy interface or is referenced from an existing BeanContextProxy child both children will be removed.

Specified by:
remove in interface Collection
Parameters:
o - element to be removed from this collection, if present.
Returns:
true if this collection changed as a result of the call
Throws:
ClassCastException - if the type of the specified element is incompatible with this collection (optional).
NullPointerException - if the specified element is null and this collection does not support null elements (optional).
UnsupportedOperationException - remove is not supported by this collection.

addAll

public boolean addAll(Collection c)
Not supported.

Specified by:
addAll in interface Collection
Throws:
UnsupportedOperationException

clear

public void clear()
Not supported.

Specified by:
clear in interface Collection
Throws:
UnsupportedOperationException

retainAll

public boolean retainAll(Collection c)
Not supported.

Specified by:
retainAll in interface Collection
Throws:
UnsupportedOperationException

removeAll

public boolean removeAll(Collection c)
Not supported.

Specified by:
removeAll in interface Collection
Throws:
UnsupportedOperationException

containsAll

public boolean containsAll(Collection c)
Returns true if this BeanContext contains all of the children in the specified collection.

Specified by:
containsAll in interface Collection
Parameters:
c - collection to be checked for containment in this collection.
Returns:
true if this collection contains all of the elements in the specified collection
Throws:
ClassCastException - if the types of one or more elements in the specified collection are incompatible with this collection (optional).
NullPointerException - if the specified collection contains one or more null elements and this collection does not support null elements (optional).
NullPointerException - if the specified collection is null.
See Also:
contains(Object)

toArray

public Object[] toArray(Object[] a)
Returns an array containing all of the children of this BeanContext; the runtime type of the returned array is that of the specified array.

Specified by:
toArray in interface Collection
Parameters:
a - the array into which the elements of this collection are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
Returns:
an array containing the elements of this collection
Throws:
ArrayStoreException - the runtime type of the specified array is not a supertype of the runtime type of every element in this collection.
NullPointerException - if the specified array is null.

setDesignTime

public void setDesignTime(boolean designTime)
Sets the "value" of the "designTime" property.

If the implementing object is an instance of java.beans.beancontext.BeanContext, or a subinterface thereof, then that BeanContext should fire a PropertyChangeEvent, to its registered BeanContextMembershipListeners, with parameters:

Note it is illegal for a BeanContextChild to invoke this method associated with a BeanContext that it is nested within.

Specified by:
setDesignTime in interface DesignMode
Parameters:
designTime - the current "value" of the "designTime" property
See Also:
BeanContext, BeanContextMembershipListener, PropertyChangeEvent

isDesignTime

public boolean isDesignTime()
A value of true denotes that JavaBeans should behave in design time mode, a value of false denotes runtime behavior.

Specified by:
isDesignTime in interface DesignMode
Returns:
the current "value" of the "designTime" property.

needsGui

public boolean needsGui()
Determines whether this bean needs a GUI.

Specified by:
needsGui in interface Visibility
Returns:
True if the bean absolutely needs a GUI available in order to get its work done.

dontUseGui

public void dontUseGui()
This method instructs the bean that it should not use the Gui.

Specified by:
dontUseGui in interface Visibility

okToUseGui

public void okToUseGui()
This method instructs the bean that it is OK to use the Gui.

Specified by:
okToUseGui in interface Visibility

avoidingGui

public boolean avoidingGui()
Determines whether this bean is avoiding using a GUI.

Specified by:
avoidingGui in interface Visibility
Returns:
true if the bean is currently avoiding use of the Gui. e.g. due to a call on dontUseGui().

propertyChange

public void propertyChange(PropertyChangeEvent evt)
This method gets called when a bound property is changed.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
evt - A PropertyChangeEvent object describing the event source and the property that has changed.

vetoableChange

public void vetoableChange(PropertyChangeEvent evt)
                    throws PropertyVetoException
This method gets called when a constrained property is changed.

Specified by:
vetoableChange in interface VetoableChangeListener
Parameters:
evt - a PropertyChangeEvent object describing the event source and the property that has changed.
Throws:
PropertyVetoException - if the recipient wishes the property change to be rolled back.

initialize

protected void initialize()
Init this classes data structures.


writeChildren

public final void writeChildren(ObjectOutputStream oos)
                         throws IOException
Necessary for the case of this bean context having a peer. The specification states that a bean context which has a peer should not serialize its children, this hook is necessary to allow the peer to serialize children.

Parameters:
oos - ObjectOutputStream
Throws:
IOException

readChildren

public final void readChildren(ObjectInputStream in)
                        throws IOException,
                               ClassNotFoundException
This public api is necessary to allow a bean context with a peer to deserialize its children. This api is not part any standard api.

Parameters:
in - ObjectInputStream
Throws:
IOException
ClassNotFoundException