java.lang.Object | +--java.beans.DesignMode | +--java.beans.beancontext.BeanContextAll Implemented Interfaces:
static java.lang.Object | globalHierarchyLockThe global lock on changing any BeanContext hierarchy. |
void | addBeanContextMembershipListener(java.beans.beancontext.BeanContextMembershipListener listener) Add a listener on changes to the membership of this
|
java.net.URL | getResource(java.lang.String resourceName, java.beans.beancontext.BeanContextChild requestor)Get a resource. |
java.io.InputStream | getResourceAsStream(java.lang.String resourceName, java.beans.beancontext.BeanContextChild requestor)Get a resource as a stream. |
java.lang.Object | instantiateChild(java.lang.String beanName)Instantiate a Bean using this Bean's |
void | removeBeanContextMembershipListener(java.beans.beancontext.BeanContextMembershipListener listener) Remove a listener on changes to the membership of this
|
public static final Object globalHierarchyLock
Methods that must (or do) synchronize on the global lock:
BeanContext.add() and addAll()
public void addBeanContextMembershipListener(java.beans.beancontext.BeanContextMembershipListener listener)BeanContext object.
listener - the listener to add.public URL getResource(java.lang.String resourceName, java.beans.beancontext.BeanContextChild requestor)BeanContext will typically
call ClassLoader.getResource(), but may do it any
way it wants to. This allows a BeanContext to
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 ClassLoader method.
I am assuming, but am not entirely sure, that if a
BeanContext cannot find a resource, its
responsibility is to call the getResource method
of its parent BeanContext.
resourceName - the name of the resource requested.requestor - a reference to the child requesting the resource.public InputStream getResourceAsStream(java.lang.String resourceName, java.beans.beancontext.BeanContextChild requestor)BeanContext will
typically call ClassLoader.getResourceAsStream(),
but may do it any way it wants to. This allows a
BeanContext'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 ClassLoader method.
I am assuming, but am not entirely sure, that if a
BeanContext cannot find a resource, its
responsibility is to call the getResourceAsStream
method of its parent BeanContext.
resourceName - the name of the resource requested.requestor - a reference to the child requesting the resource.public Object instantiateChild(java.lang.String beanName)ClassLoader
and this BeanContext as the parent.
This method exists mainly so that BeanContext
implementations can perform extra actions on Beans that are
created within them.
beanName - the name of the bean to instantiateIOException - if there is an I/O problem during
instantiation.ClassNotFoundException - if a serialized Bean's class
is not found.java.beans.Beans.instantiate(java.lang.ClassLoader,java.lang.String)java.beans.Beans.instantiate(java.lang.ClassLoader,java.lang.String,java.lang.BeanContext)public void removeBeanContextMembershipListener(java.beans.beancontext.BeanContextMembershipListener listener)BeanContext object.
listener - the listener to remove.
BeanContexts.Since I can't sprinkle the
Collectionsinterface documentation with special information forBeanContextimplementors, I'll have to document special requirements for implementors of those functions here.add()oraddAll():Objectinto the hierarchy as well as aBeanContextChild,BeanContextorBeanContextProxyobject. This way, any Bean can be in the hierarchy.BeanContext.globalHierarchyLock.Objectif it's already there (only once perBeanContext).BeanContextChildimplementor, callsetBeanContext()on it. If it's aBeanContextProxyimplementor, callgetBeanContextProxy().setBeanContext()on it. IfsetBeanContext()vetoes the change, back out all changes so far and throwIllegalStateException.Visibility, calldontUseGui()orokToUseGui()on it, depending on whether you (theBeanContext) feel like allowing it to use the GUI or not.BeanContextChildorBeanContextProxy, register yourself (theBeanContext) as both aPropertyChangeListenerandVetoableChangeListeneron the "beanContext" property (it may also add itself on any other properties it wishes to).BeanContext) are interested in, you may register yourself to it or register it to you.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()orremoveAll():BeanContext.globalHierarchyLock.Objectis not a child of thisBeanContext, just exit without performing any actions.Objectfrom your collection of children.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.Objectto listen to you or registered yourself as a listener on theObjectduringadd()oraddAll(), undo the registration bycalling the appropriateremoveListener()method.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()andclear()do not need to be implemented, but may be if so desired.Similarly,
VisibilityandDesignModemethods 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.