|
|||||||||
| Home >> All >> java >> beans >> [ beancontext overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.beans.beancontext
Interface BeanContext

- All Superinterfaces:
- BeanContextChild, java.util.Collection, java.beans.DesignMode, java.lang.Iterable, java.beans.Visibility
- All Known Subinterfaces:
- BeanContextServices
- All Known Implementing Classes:
- BeanContextServicesSupport, BeanContextSupport
- public interface BeanContext
- extends java.util.Collection, BeanContextChild, java.beans.Visibility, java.beans.DesignMode
Acts as a container for sub-beans and as a sub-bean,
so that an entire hierarchy of beans can be made up of
BeanContexts.
Since I can't sprinkle the Collections interface
documentation with special information for BeanContext
implementors, I'll have to document special requirements for
implementors of those functions here.
add() or addAll():
-
May add any
Objectinto the hierarchy as well as aBeanContextChild,BeanContextorBeanContextProxyobject. This way, any Bean can be in the hierarchy. -
Must synchronize on
BeanContext.globalHierarchyLock. -
Don't add the
Objectif it's already there (only once perBeanContext). -
If it is a
BeanContextChildimplementor, callsetBeanContext()on it. If it's aBeanContextProxyimplementor, callgetBeanContextProxy().setBeanContext()on it. IfsetBeanContext()vetoes the change, back out all changes so far and throwIllegalStateException. -
If it (or its proxy) implements
Visibility, calldontUseGui()orokToUseGui()on it, depending on whether you (theBeanContext) feel like allowing it to use the GUI or not. -
If it implements
BeanContextChildorBeanContextProxy, register yourself (theBeanContext) as both aPropertyChangeListenerandVetoableChangeListeneron the "beanContext" property (it may also add itself on any other properties it wishes to). -
If it is a listener or event source that you (the
BeanContext) are interested in, you may register yourself to it or register it to you. -
Fire a
java.beans.beancontext.BeanContextMembershipEventbefore exiting.addAll()should wait until everything is done changing before firing the event (or events) so that if a failure occurs, the backing-out process can proceed without any events being fired at all.
remove() or removeAll():
-
Must synchronize on
BeanContext.globalHierarchyLock. -
If the specified
Objectis not a child of thisBeanContext, just exit without performing any actions. -
Remove the
Objectfrom your collection of children. -
If it is a
BeanContextChildimplementor, callsetBeanContext(null)on it. If it's aBeanContextProxyimplementor, callgetBeanContextProxy().setBeanContext(null)on it. IfsetBeanContext()vetoes the change, back out all changes so far and throwIllegalStateException. -
If you registered the
Objectto listen to you or registered yourself as a listener on theObjectduringadd()oraddAll(), undo the registration bycalling the appropriateremoveListener()method. -
Fire a
java.beans.beancontext.BeanContextMembershipEventbefore exiting.removeAll()should wait until everything is done changing before firing the event (or events) so that if a failure occurs, the backing-out process can proceed without any events being fired at all.
addAll(), removeAll(),
retainAll() and clear() do not need to be
implemented, but may be if so desired.
Similarly, Visibility and DesignMode methods
should propagate changed values to children that implement interfaces
of the same name.
A hierarchy of beans is mainly useful so that different sets of beans can be established, each with their own set of resources.
- Since:
- JDK1.2
| Field Summary | |
static java.lang.Object |
globalHierarchyLock
The global lock on changing any BeanContext hierarchy. |
| Fields inherited from interface java.beans.DesignMode |
PROPERTYNAME |
| Method Summary | |
void |
addBeanContextMembershipListener(BeanContextMembershipListener listener)
Add a listener on changes to the membership of this BeanContext object. |
java.net.URL |
getResource(java.lang.String resourceName,
BeanContextChild requestor)
Get a resource. |
java.io.InputStream |
getResourceAsStream(java.lang.String resourceName,
BeanContextChild requestor)
Get a resource as a stream. |
java.lang.Object |
instantiateChild(java.lang.String beanName)
Instantiate a Bean using this Bean's ClassLoader
and this BeanContext as the parent. |
void |
removeBeanContextMembershipListener(BeanContextMembershipListener listener)
Remove a listener on changes to the membership of this BeanContext object. |
| Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Methods inherited from interface java.beans.beancontext.BeanContextChild |
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext |
| Methods inherited from interface java.beans.Visibility |
avoidingGui, dontUseGui, needsGui, okToUseGui |
| Methods inherited from interface java.beans.DesignMode |
isDesignTime, setDesignTime |
| Field Detail |
globalHierarchyLock
public static final java.lang.Object globalHierarchyLock
- The global lock on changing any BeanContext hierarchy.
It kinda sucks that there is only one lock, since there can be
multiple hierarchies. Oh well, I didn't design, I just code.
Methods that must (or do) synchronize on the global lock:
-
Implementors of
BeanContext.add()andaddAll()
-
Implementors of
| Method Detail |
instantiateChild
public java.lang.Object instantiateChild(java.lang.String beanName) throws java.io.IOException, java.lang.ClassNotFoundException
- Instantiate a Bean using this Bean's
ClassLoaderand thisBeanContextas the parent.This method exists mainly so that
BeanContextimplementations can perform extra actions on Beans that are created within them.
getResource
public java.net.URL getResource(java.lang.String resourceName, BeanContextChild requestor)
- Get a resource. The
BeanContextwill typically callClassLoader.getResource(), but may do it any way it wants to. This allows aBeanContextto have its own set of resources separate from the rest of the system.Beans should call this method on their parent rather than the associated
ClassLoadermethod.I am assuming, but am not entirely sure, that if a
BeanContextcannot find a resource, its responsibility is to call thegetResourcemethod of its parentBeanContext.
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String resourceName, BeanContextChild requestor)
- Get a resource as a stream. The
BeanContextwill typically callClassLoader.getResourceAsStream(), but may do it any way it wants to. This allows aBeanContext's children to have their own set of resources separate from the rest of the system.Beans should call this method on their parent rather than the associated
ClassLoadermethod.I am assuming, but am not entirely sure, that if a
BeanContextcannot find a resource, its responsibility is to call thegetResourceAsStreammethod of its parentBeanContext.
addBeanContextMembershipListener
public void addBeanContextMembershipListener(BeanContextMembershipListener listener)
- Add a listener on changes to the membership of this
BeanContextobject.
removeBeanContextMembershipListener
public void removeBeanContextMembershipListener(BeanContextMembershipListener listener)
- Remove a listener on changes to the membership of this
BeanContextobject.
|
|||||||||
| Home >> All >> java >> beans >> [ beancontext overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC