![]() |
|
Contents |
Inherited by BeanContextServicesSupport.
BeanContext interface.
This class can be used directly, or be a super class of your class, or be a delegate of your implementation that needs to support BeanContext interface.
Public Member Functions | |
| BeanContextSupport () | |
Constructs a standload BeanContextSupport. | |
| BeanContextSupport (BeanContext peer) | |
Constructs a BeanContextSupport which is a delegate of the given peer. | |
| BeanContextSupport (BeanContext peer, Locale locale) | |
Constructs a BeanContextSupport which is a delegate of the given peer. | |
| BeanContextSupport (BeanContext peer, Locale locale, boolean designTime) | |
Constructs a BeanContextSupport which is a delegate of the given peer. | |
| BeanContextSupport (BeanContext peer, Locale locale, boolean designTime, boolean okToUseGui) | |
Constructs a BeanContextSupport which is a delegate of the given peer. | |
| boolean | add (Object child) |
| Add a child to this context. | |
| boolean | addAll (Collection collection) |
This method is unsupported, throws UnsupportedOperationException. | |
| void | addBeanContextMembershipListener (BeanContextMembershipListener listener) |
| boolean | avoidingGui () |
| void | clear () |
This method is unsupported, throws UnsupportedOperationException. | |
| boolean | contains (Object child) |
| Returns true if the given object is a child of this context. | |
| boolean | containsAll (Collection collection) |
| Returns true if given objects are children of this context. | |
| boolean | containsKey (Object child) |
| Returns true if the given object is a child of this context. | |
| void | dontUseGui () |
| BeanContext | getBeanContextPeer () |
Returns the peer of this context casted as BeanContext. | |
| Locale | getLocale () |
| Returns the locale of this context. | |
| URL | getResource (String resourceName, BeanContextChild child) |
| InputStream | getResourceAsStream (String resourceName, BeanContextChild child) throws IllegalArgumentException |
| Object | instantiateChild (String beanName) throws IOException, ClassNotFoundException |
| boolean | isDesignTime () |
| boolean | isEmpty () |
| boolean | isSerializing () |
| Returns true if this context is currently being serialized (by another thread). | |
| Iterator | iterator () |
Returns an iterator of children of this context, with remove() disabled. | |
| boolean | needsGui () |
| Returns true if this context or its children needs GUI to work properly. | |
| void | okToUseGui () |
| void | propertyChange (PropertyChangeEvent event) |
| final void | readChildren (ObjectInputStream ois) throws IOException, ClassNotFoundException |
| Deserializes children from the given object input stream. | |
| boolean | remove (Object child) |
| Removes the given child from this context. | |
| boolean | removeAll (Collection collection) |
This method is unsupported, throws UnsupportedOperationException. | |
| void | removeBeanContextMembershipListener (BeanContextMembershipListener listener) |
| boolean | retainAll (Collection collection) |
This method is unsupported, throws UnsupportedOperationException. | |
| void | setDesignTime (boolean designTime) |
| void | setLocale (Locale newLocale) throws PropertyVetoException |
| Sets the locale of this context. | |
| int | size () |
| Returns the number children of this context. | |
| Object[] | toArray () |
| Returns an array of children of this context. | |
| Object[] | toArray (Object[] array) |
| Returns an array of children of this context. | |
| void | vetoableChange (PropertyChangeEvent pce) throws PropertyVetoException |
| final void | writeChildren (ObjectOutputStream oos) throws IOException |
| Serializes children to the given object input stream. | |
Protected Member Functions | |
| Iterator | bcsChildren () |
Returns an iterator of all BCSChild instances, with remove() disabled. | |
| void | bcsPreDeserializationHook (ObjectInputStream ois) throws IOException, ClassNotFoundException |
This method is called by readObject() after defaultReadObject() and before deserializing any children or listeners. | |
| void | bcsPreSerializationHook (ObjectOutputStream oos) throws IOException |
This method is called by writeObject() after defaultWriteObject() and before serializing any children or listeners. | |
| void | childDeserializedHook (Object child, BCSChild bcsChild) |
| This method is called during deserialization everytime a child is read. | |
| void | childJustAddedHook (Object child, BCSChild bcsChild) |
| This method is called everytime a child is added to this context. | |
| void | childJustRemovedHook (Object child, BCSChild bcsChild) |
| This method is called everytime a child is removed from this context. | |
| final Object[] | copyChildren () |
| Returns an array containing all children of this context. | |
| BCSChild | createBCSChild (Object child, Object proxyPeer) |
Creates a BCSChild object to company the given child. | |
| final void | deserialize (ObjectInputStream ois, Collection collection) throws IOException, ClassNotFoundException |
| Deserialize a collection. | |
| final void | fireChildrenAdded (BeanContextMembershipEvent event) |
Notifies registered BeanContextMembershipListeners that a new child has been added. | |
| final void | fireChildrenRemoved (BeanContextMembershipEvent event) |
Notifies registered BeanContextMembershipListeners that a child has been removed. | |
| void | initialize () |
Initializes all transient fields of this instance, called by constructors and readObject(). | |
| boolean | remove (Object child, boolean setChildBC) |
| Removes the given child from this context. | |
| final void | serialize (ObjectOutputStream oos, Collection collection) throws IOException |
| Serializes the given collection. | |
| boolean | validatePendingAdd (Object child) |
| Validates the pending add of child. | |
| boolean | validatePendingRemove (Object child) |
| Validates the pending removal of child. | |
Static Protected Member Functions | |
| static final boolean | classEquals (Class clz1, Class clz2) |
| Compares if two classes are equal or their class names are equal. | |
| static final BeanContextChild | getChildBeanContextChild (Object child) |
Returns the BeanContextChild related with the given child. | |
| static final BeanContextMembershipListener | getChildBeanContextMembershipListener (Object child) |
Returns the given child casted to BeanContextMembershipListener, or null if it does not implements the interface. | |
| static final PropertyChangeListener | getChildPropertyChangeListener (Object child) |
Returns the given child casted to PropertyChangeListener, or null if it does not implements the interface. | |
| static final Serializable | getChildSerializable (Object child) |
Returns the given child casted to Serializable, or null if it does not implements the interface. | |
| static final VetoableChangeListener | getChildVetoableChangeListener (Object child) |
Returns the given child casted to VetoableChangeListener, or null if it does not implements the interface. | |
| static final Visibility | getChildVisibility (Object child) |
Returns the given child casted to Visibility, or null if it does not implements the interface. | |
Protected Attributes | |
| transient ArrayList | bcmListeners |
| A list of registered membership listeners. | |
| transient HashMap | children |
A map of children - key is child instance, value is BCSChild instance. | |
| Locale | locale |
| The locale of this context. | |
| boolean | okToUseGui |
| A flag indicating whether this context is allowed to use GUI. | |
| boolean | designTime |
| A flag indicating whether this context is in design mode. | |
Static Package Attributes | |
| static final long | serialVersionUID = -4879613978649577204L |
Private Member Functions | |
| void | writeObject (ObjectOutputStream oos) throws IOException |
| The implementation goes through following steps:. | |
| void | readObject (ObjectInputStream ois) throws IOException, ClassNotFoundException |
| The implementation goes through following steps:. | |
Private Attributes | |
| transient boolean | serializing |
| transient boolean | inNeedsGui |
| transient PropertyChangeListener | nonSerPCL |
| int | serializable |
Classes | |
| class | BCSChild |
Every child of context is companied with a BCSChild instance. More... | |
| class | BCSIterator |
This implementation wraps an iterator and override remove() with a noop method. More... | |
Constructs a standload BeanContextSupport.
| BeanContextSupport | ( | BeanContext | peer | ) |
Constructs a BeanContextSupport which is a delegate of the given peer.
| peer | the peer of this context |
| BeanContextSupport | ( | BeanContext | peer, | |
| Locale | locale | |||
| ) |
Constructs a BeanContextSupport which is a delegate of the given peer.
| peer | the peer of this context | |
| locale | the locale of this context |
| BeanContextSupport | ( | BeanContext | peer, | |
| Locale | locale, | |||
| boolean | designTime | |||
| ) |
Constructs a BeanContextSupport which is a delegate of the given peer.
| peer | the peer of this context | |
| locale | the locale of this context | |
| designTime | whether in design mode or not |
| BeanContextSupport | ( | BeanContext | peer, | |
| Locale | locale, | |||
| boolean | designTime, | |||
| boolean | okToUseGui | |||
| ) |
Constructs a BeanContextSupport which is a delegate of the given peer.
| peer | the peer of this context | |
| locale | the locale of this context | |
| designTime | whether in design mode or not | |
| okToUseGui | whether GUI is usable or not |
| boolean add | ( | Object | child | ) |
Add a child to this context.
If the child already exists in this context, simply returns false. Otherwise, it is validated by calling validatePendingAdd(). If the add is valid, the child and its proxy (if the child implements BeanContextProxy) is then added, and setBeanContext() is called on it (if the child implements BeanContextChild or it has a proxy). Last, the childJustAddedHook() is called and all registered BeanContextMembershipListeners are notified.
| child | the child to add |
| IllegalStateException | if the child is not valid to add |
| boolean addAll | ( | Collection | collection | ) |
This method is unsupported, throws UnsupportedOperationException.
| void addBeanContextMembershipListener | ( | BeanContextMembershipListener | listener | ) |
Implements BeanContext.
| boolean avoidingGui | ( | ) |
Implements Visibility.
| Iterator bcsChildren | ( | ) | [protected] |
| void bcsPreDeserializationHook | ( | ObjectInputStream | ois | ) | throws IOException, ClassNotFoundException [protected] |
This method is called by readObject() after defaultReadObject() and before deserializing any children or listeners.
Subclass can insert its specific deserialization behavior by overrideing this method.
The default implementation does nothing.
| ois | the object input stream |
| IOException | ||
| ClassNotFoundException |
Reimplemented in BeanContextServicesSupport.
| void bcsPreSerializationHook | ( | ObjectOutputStream | oos | ) | throws IOException [protected] |
This method is called by writeObject() after defaultWriteObject() and before serializing any children or listeners.
Subclass can insert its specific serialization behavior by overrideing this method.
The default implementation does nothing.
| oos | the object output stream |
| IOException |
Reimplemented in BeanContextServicesSupport.
| void childDeserializedHook | ( | Object | child, | |
| BCSChild | bcsChild | |||
| ) | [protected] |
This method is called during deserialization everytime a child is read.
The default implementation does nothing.
| child | the child just deserialized | |
| bcsChild | the BCSChild just deserialized |
| void childJustAddedHook | ( | Object | child, | |
| BCSChild | bcsChild | |||
| ) | [protected] |
This method is called everytime a child is added to this context.
This method is called with child synchronized.
The default implementation does nothing.
| child | the child just added | |
| bcsChild | the BCSChild just added |
| void childJustRemovedHook | ( | Object | child, | |
| BCSChild | bcsChild | |||
| ) | [protected] |
This method is called everytime a child is removed from this context.
This method is called with child synchronized.
The default implementation does nothing.
| child | the child just removed | |
| bcsChild | the BCSChild just removed |
Reimplemented in BeanContextServicesSupport.
| static final boolean classEquals | ( | Class | clz1, | |
| Class | clz2 | |||
| ) | [static, protected] |
Compares if two classes are equal or their class names are equal.
| clz1 | a class | |
| clz2 | another class |
| void clear | ( | ) |
This method is unsupported, throws UnsupportedOperationException.
| boolean contains | ( | Object | child | ) |
Returns true if the given object is a child of this context.
| child | the object to test |
| boolean containsAll | ( | Collection | collection | ) |
Returns true if given objects are children of this context.
| collection | a collection of objects |
| boolean containsKey | ( | Object | child | ) |
Returns true if the given object is a child of this context.
| child | the object to test |
| final Object [] copyChildren | ( | ) | [protected] |
Returns an array containing all children of this context.
| BCSChild createBCSChild | ( | Object | child, | |
| Object | proxyPeer | |||
| ) | [protected] |
Creates a BCSChild object to company the given child.
| child | the child | |
| proxyPeer | the proxy peer of the child if there is one |
BCSChild object to company the given child Reimplemented in BeanContextServicesSupport.
| final void deserialize | ( | ObjectInputStream | ois, | |
| Collection | collection | |||
| ) | throws IOException, ClassNotFoundException [protected] |
Deserialize a collection.
First read a int indicating of number of rest objects, then read the objects one by one.
| ois | the stream where the collection is read from | |
| collection | the collection to hold read objects |
| IOException | if I/O exception occurs | |
| ClassNotFoundException | if class of any read object is not found |
| void dontUseGui | ( | ) |
Implements Visibility.
| final void fireChildrenAdded | ( | BeanContextMembershipEvent | event | ) | [protected] |
Notifies registered BeanContextMembershipListeners that a new child has been added.
| event | the BeanContextMembershipEvent |
| final void fireChildrenRemoved | ( | BeanContextMembershipEvent | event | ) | [protected] |
Notifies registered BeanContextMembershipListeners that a child has been removed.
| event | the BeanContextMembershipEvent |
| BeanContext getBeanContextPeer | ( | ) |
Returns the peer of this context casted as BeanContext.
BeanContext | static final BeanContextChild getChildBeanContextChild | ( | Object | child | ) | [static, protected] |
Returns the BeanContextChild related with the given child.
If the child implements BeanContextChild, it is returned. If the child implements BeanContextProxy, the proxy is returned. Otherwise, null is returned.
| child | a child |
BeanContextChild related with the given child | IllegalStateException | if the child implements both BeanContextChild and BeanContextProxy |
| static final BeanContextMembershipListener getChildBeanContextMembershipListener | ( | Object | child | ) | [static, protected] |
Returns the given child casted to BeanContextMembershipListener, or null if it does not implements the interface.
| child | a child |
BeanContextMembershipListener, or null if it does not implements the interface | static final PropertyChangeListener getChildPropertyChangeListener | ( | Object | child | ) | [static, protected] |
Returns the given child casted to PropertyChangeListener, or null if it does not implements the interface.
| child | a child |
PropertyChangeListener, or null if it does not implements the interface | static final Serializable getChildSerializable | ( | Object | child | ) | [static, protected] |
Returns the given child casted to Serializable, or null if it does not implements the interface.
| child | a child |
Serializable, or null if it does not implements the interface | static final VetoableChangeListener getChildVetoableChangeListener | ( | Object | child | ) | [static, protected] |
Returns the given child casted to VetoableChangeListener, or null if it does not implements the interface.
| child | a child |
VetoableChangeListener, or null if it does not implements the interface | static final Visibility getChildVisibility | ( | Object | child | ) | [static, protected] |
Returns the given child casted to Visibility, or null if it does not implements the interface.
| child | a child |
Visibility, or null if it does not implements the interface | Locale getLocale | ( | ) |
Returns the locale of this context.
| URL getResource | ( | String | resourceName, | |
| BeanContextChild | child | |||
| ) |
Implements BeanContext.
| InputStream getResourceAsStream | ( | String | resourceName, | |
| BeanContextChild | child | |||
| ) | throws IllegalArgumentException |
Implements BeanContext.
| void initialize | ( | ) | [protected] |
Initializes all transient fields of this instance, called by constructors and readObject().
Reimplemented in BeanContextServicesSupport.
| Object instantiateChild | ( | String | beanName | ) | throws IOException, ClassNotFoundException |
Implements BeanContext.
| boolean isDesignTime | ( | ) |
Implements DesignMode.
| boolean isEmpty | ( | ) |
| boolean isSerializing | ( | ) |
Returns true if this context is currently being serialized (by another thread).
| Iterator iterator | ( | ) |
Returns an iterator of children of this context, with remove() disabled.
| boolean needsGui | ( | ) |
Returns true if this context or its children needs GUI to work properly.
The implementation checks the peer and all the children that implement Visibility to see if any of their needsGui() returns true, and if any of the children extends java.awt.Component.
Implements Visibility.
| void okToUseGui | ( | ) |
Implements Visibility.
| void propertyChange | ( | PropertyChangeEvent | event | ) |
Implements PropertyChangeListener.
| final void readChildren | ( | ObjectInputStream | ois | ) | throws IOException, ClassNotFoundException |
Deserializes children from the given object input stream.
The implementation reads pairs of child object and BCSChild object according to serializable property. For each pair, it is added to the children map and the childDeserializedHook() is called. If the child implements BeanContextChild, its setBeanContext() is also called.
This method is called by readObject() if the context works standalone. Or if this support object is a delegate of another BeanContext implementation, then this method should be called by the peer. Doing this means that derialization can proceed without any circular dependency problems.
| ois | the object input stream |
| IOException | if I/O exception occurs | |
| ClassNotFoundException | if class of read object is not found |
| boolean remove | ( | Object | child | ) |
Removes the given child from this context.
Delegates to remove(child, true).
| child | a child of this context |
| IllegalArgumentException | if the child is null | |
| IllegalStateException | if the child is not valid to remove |
| boolean remove | ( | Object | child, | |
| boolean | setChildBC | |||
| ) | [protected] |
Removes the given child from this context.
If the given child is not a child of this context, simply returns false. Otherwise, validatePendingRemove() is called. If the removal is valid, the child's beanContext property is updated (if required) and the child and its proxy peer (if there is one) is removed. Last, childJustRemovedHook() is called and listeners are notified.
| child | a child of this context | |
| setChildBC | whether to call setBeanContext() on the child or not |
| IllegalArgumentException | if the child is null | |
| IllegalStateException | if the child is not valid to remove |
| boolean removeAll | ( | Collection | collection | ) |
This method is unsupported, throws UnsupportedOperationException.
| void removeBeanContextMembershipListener | ( | BeanContextMembershipListener | listener | ) |
Implements BeanContext.
| boolean retainAll | ( | Collection | collection | ) |
This method is unsupported, throws UnsupportedOperationException.
| final void serialize | ( | ObjectOutputStream | oos, | |
| Collection | collection | |||
| ) | throws IOException [protected] |
Serializes the given collection.
First writes a int indicating the number of all serializable elements (implements Serializable, then objects are writtern one by one.
| oos | the stream where the collection is writtern to | |
| collection | the collection to serialize |
| IOException | if I/O exception occurs |
| void setDesignTime | ( | boolean | designTime | ) |
Implements DesignMode.
| void setLocale | ( | Locale | newLocale | ) | throws PropertyVetoException |
Sets the locale of this context.
VetoableChangeListeners and PropertyChangeListeners are notified.
| newLocale | the new locale to set |
| PropertyVetoException | if any VetoableChangeListener vetos this change |
| int size | ( | ) |
Returns the number children of this context.
| Object [] toArray | ( | ) |
Returns an array of children of this context.
| Object [] toArray | ( | Object[] | array | ) |
Returns an array of children of this context.
| boolean validatePendingAdd | ( | Object | child | ) | [protected] |
Validates the pending add of child.
Default implementation always returns true.
| child | the child to be added |
| boolean validatePendingRemove | ( | Object | child | ) | [protected] |
Validates the pending removal of child.
Default implementation always returns true.
| child | the child to be removed |
| void vetoableChange | ( | PropertyChangeEvent | pce | ) | throws PropertyVetoException |
Implements VetoableChangeListener.
| final void writeChildren | ( | ObjectOutputStream | oos | ) | throws IOException |
Serializes children to the given object input stream.
The implementation iterates through all children and writes out pairs of child object and BCSChild object if the child is serializable (implements Serialization.
This method is called by writeObject() if the context works standalone. Or if this support object is a delegate of another BeanContext implementation, then this method should be called by the peer to avoid the 'chicken and egg' problem during deserialization.
| oos | the stream to write |
| IOException | if I/O exception occurs |
| void writeObject | ( | ObjectOutputStream | oos | ) | throws IOException [private] |
The implementation goes through following steps:.
defaultWriteObject(), especially the serializable indicating the number of serializable children. bcsPreSerializationHook(). writeChildren() if this context works standalone. Otherwise it is the peer's responsibility to call writeChildren() after this object is serialized.
| oos | the object output stream |
| IOException | if I/O exception occurs |
Reimplemented from BeanContextChildSupport.
Reimplemented in BeanContextServicesSupport.
| void readObject | ( | ObjectInputStream | ois | ) | throws IOException, ClassNotFoundException [private] |
The implementation goes through following steps:.
defaultReadObject(). bcsPreDeserializationHook(). readChildren() if this context works standalone. Otherwise it is the peer's responsibility to call readChildren() after this object is deserialized.
| ois | the object input stream |
| IOException | if I/O error occurs | |
| ClassNotFoundException | if class of read object is not found |
Reimplemented from BeanContextChildSupport.
Reimplemented in BeanContextServicesSupport.
final long serialVersionUID = -4879613978649577204L [static, package] |
transient ArrayList bcmListeners [protected] |
A list of registered membership listeners.
All access to this object should be synchronized on itself.
transient HashMap children [protected] |
A map of children - key is child instance, value is BCSChild instance.
All access to this object should be synchronized on itself.
transient boolean serializing [private] |
transient boolean inNeedsGui [private] |
transient PropertyChangeListener nonSerPCL [private] |
int serializable [private] |
Reimplemented in BeanContextServicesSupport.
boolean okToUseGui [protected] |
A flag indicating whether this context is allowed to use GUI.
boolean designTime [protected] |
A flag indicating whether this context is in design mode.