GNU Classpath (0.95) | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
public interface BeanContext
extends Collection<E>, BeanContextChild, Visibility, DesignMode
BeanContext
s.
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()
:
Object
into the hierarchy as well as a
BeanContextChild
, BeanContext
or
BeanContextProxy
object.
This way, any Bean can be in the hierarchy.
BeanContext.globalHierarchyLock
.
Object
if it's already there (only once
per BeanContext
).
BeanContextChild
implementor, call
setBeanContext()
on it. If it's a
BeanContextProxy
implementor, call
getBeanContextProxy().setBeanContext()
on it.
If setBeanContext()
vetoes the change, back out
all changes so far and throw IllegalStateException
.
Visibility
, call
dontUseGui()
or okToUseGui()
on it,
depending on whether you (the BeanContext
) feel like
allowing it to use the GUI or not.
BeanContextChild
or
BeanContextProxy
, register yourself (the
BeanContext
) as both a
PropertyChangeListener
and
VetoableChangeListener
on 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.BeanContextMembershipEvent
before 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()
:
BeanContext.globalHierarchyLock
.
Object
is not a child of this
BeanContext
, just exit without performing any actions.
Object
from your collection of children.
BeanContextChild
implementor, call
setBeanContext(null)
on it. If it's a
BeanContextProxy
implementor, call
getBeanContextProxy().setBeanContext(null)
on it.
If setBeanContext()
vetoes the change, back out
all changes so far and throw IllegalStateException
.
Object
to listen to you or
registered yourself as a listener on the Object
during
add()
or addAll()
, undo the registration
bycalling the appropriate removeListener()
method.
java.beans.beancontext.BeanContextMembershipEvent
before 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.
Field Summary | |
static Object |
|
Fields inherited from interface java.beans.DesignMode | |
PROPERTYNAME |
Method Summary | |
void |
|
URL |
|
InputStream |
|
Object |
|
void |
|
Methods inherited from interface java.beans.beancontext.BeanContextChild | |
addPropertyChangeListener , addVetoableChangeListener , getBeanContext , removePropertyChangeListener , removeVetoableChangeListener , setBeanContext |
Methods inherited from interface java.util.Collection<E> | |
T[] toArray , add , addAll , clear , contains , containsAll , equals , hashCode , isEmpty , iterator , remove , removeAll , retainAll , size , toArray |
Methods inherited from interface java.beans.DesignMode | |
isDesignTime , setDesignTime |
Methods inherited from interface java.lang.Iterable<E> | |
iterator |
Methods inherited from interface java.beans.Visibility | |
avoidingGui , dontUseGui , needsGui , okToUseGui |
public static final 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()
public void addBeanContextMembershipListener(BeanContextMembershipListener listener)
Add a listener on changes to the membership of thisBeanContext
object.
- Parameters:
listener
- the listener to add.
public URL getResource(String resourceName, BeanContextChild requestor)
Get a resource. TheBeanContext
will typically callClassLoader.getResource()
, but may do it any way it wants to. This allows aBeanContext
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 thegetResource
method of its parentBeanContext
.
- Parameters:
resourceName
- the name of the resource requested.requestor
- a reference to the child requesting the resource.
- Returns:
- a URL to the requested resource.
- See Also:
ClassLoader.getResource(String)
public InputStream getResourceAsStream(String resourceName, BeanContextChild requestor)
Get a resource as a stream. TheBeanContext
will 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
ClassLoader
method.I am assuming, but am not entirely sure, that if a
BeanContext
cannot find a resource, its responsibility is to call thegetResourceAsStream
method of its parentBeanContext
.
- Parameters:
resourceName
- the name of the resource requested.requestor
- a reference to the child requesting the resource.
- Returns:
- the requested resource as a stream.
public Object instantiateChild(String beanName) throws IOException, ClassNotFoundException
Instantiate a Bean using this Bean'sClassLoader
and thisBeanContext
as the parent.This method exists mainly so that
BeanContext
implementations can perform extra actions on Beans that are created within them.
- Parameters:
beanName
- the name of the bean to instantiate
- Returns:
- the created Bean
- Throws:
IOException
- if there is an I/O problem during instantiation.ClassNotFoundException
- if a serialized Bean's class is not found.
public void removeBeanContextMembershipListener(BeanContextMembershipListener listener)
Remove a listener on changes to the membership of thisBeanContext
object.
- Parameters:
listener
- the listener to remove.
GNU Classpath (0.95) |