public class MapHandlerChild extends java.lang.Object implements java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, LightMapHandlerChild
When you design a MapHandlerChild, you should make it comfortable running without references to objects it depends on. It should wait patiently for the other objects to be added to the MapHandler, and then do the work itself to hook up. It should also listen for those objects to be removed from the MapHandler, disengage gracefully, and wait patiently until it finds something else to hook up to.
An object does not have to be a MapHandlerChild to be added to the MapHandler, but it does need to be one to be able to use it. If you override and use the findAndInit(Iterator) method to look for objects, you'll find it is called on two different conditions. It's called when this MapHandlerChild is added to the MapHandler, and it then receives a list of all the objects currently contained in the MapHandler. It is also called when other objects are added to the MapHandler. The list then contains objects that have just been added. The findAndInit(Object) method has been added to allow subclassed objects to call super.findAndInit(Object) to let the super classes handles the objects they care about. You don't call the findAndInit(Object) method. You override it and implement the method so that you can look for the objects you need.
When objects are removed from the BeanContext, the childrenRemoved() method is called with a list of objects being removed. Likewise, the findAndUndo(Object) method has been added for the benefit of subclasses.
MapHandlerChild objects expect to be added to only one BeanContext. The BeanContextChildSupport object detects when it has a different BeanContext added to it, and it will fire property change notifications to get itself removed from the first BeanContext.
Modifier and Type | Field and Description |
---|---|
protected java.beans.beancontext.BeanContextChildSupport |
beanContextChildSupport
BeanContextChildSupport object provides helper functions for
BeanContextChild interface.
|
protected boolean |
isolated
A boolean that prevents the BeanContextChild from looking at events from
BeanContext other than the one it was originally added to.
|
Constructor and Description |
---|
MapHandlerChild() |
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener in_pcl)
Method for BeanContextChild interface.
|
void |
addVetoableChangeListener(java.lang.String propertyName,
java.beans.VetoableChangeListener in_vcl)
Method for BeanContextChild interface.
|
void |
childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)
BeanContextMembershipListener method.
|
void |
childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)
BeanContextMembershipListener method.
|
void |
findAndInit(java.util.Iterator<?> it)
This is the method that your object can use to find other objects within
the MapHandler (BeanContext).
|
void |
findAndInit(java.lang.Object obj)
The findAndInit method has been made non-abstract, because it now calls
this method for every object that is in the iterator it receives.
|
void |
findAndUndo(java.lang.Object obj)
The childrenRemoved has been changed to go through its iterator to call
this method with every object.
|
void |
firePropertyChange(java.lang.String name,
java.lang.Object oldValue,
java.lang.Object newValue)
Method for BeanContextChild interface.
|
void |
fireVetoableChange(java.lang.String name,
java.lang.Object oldValue,
java.lang.Object newValue)
Report a vetoable property update to any registered listeners.
|
java.beans.beancontext.BeanContext |
getBeanContext()
Method for BeanContextChild interface.
|
boolean |
isIsolated() |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener in_pcl)
Method for BeanContextChild interface.
|
void |
removeVetoableChangeListener(java.lang.String propertyName,
java.beans.VetoableChangeListener in_vcl)
Method for BeanContextChild interface.
|
void |
setBeanContext(java.beans.beancontext.BeanContext in_bc)
Method for BeanContextChild interface.
|
void |
setIsolated(boolean isolated) |
protected boolean isolated
protected java.beans.beancontext.BeanContextChildSupport beanContextChildSupport
public void findAndInit(java.util.Iterator<?> it)
it
- Iterator to use to go through a list of objects. Find the ones
you need, and hook yourself up.public void findAndInit(java.lang.Object obj)
findAndInit
in interface LightMapHandlerChild
public void childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)
childrenAdded
in interface java.beans.beancontext.BeanContextMembershipListener
public void childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)
childrenRemoved
in interface java.beans.beancontext.BeanContextMembershipListener
public void findAndUndo(java.lang.Object obj)
findAndUndo
in interface LightMapHandlerChild
public java.beans.beancontext.BeanContext getBeanContext()
getBeanContext
in interface java.beans.beancontext.BeanContextChild
public void setBeanContext(java.beans.beancontext.BeanContext in_bc) throws java.beans.PropertyVetoException
setBeanContext
in interface java.beans.beancontext.BeanContextChild
java.beans.PropertyVetoException
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener in_pcl)
addPropertyChangeListener
in interface java.beans.beancontext.BeanContextChild
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener in_pcl)
removePropertyChangeListener
in interface java.beans.beancontext.BeanContextChild
public void addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener in_vcl)
addVetoableChangeListener
in interface java.beans.beancontext.BeanContextChild
public void removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener in_vcl)
removeVetoableChangeListener
in interface java.beans.beancontext.BeanContextChild
public void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
public void fireVetoableChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue) throws java.beans.PropertyVetoException
No event is fired if old and new are equal and non-null.
name
- The programmatic name of the property that is about to changeoldValue
- The old value of the propertynewValue
- - The new value of the propertyjava.beans.PropertyVetoException
- if the recipient wishes the property change
to be rolled back.public boolean isIsolated()
public void setIsolated(boolean isolated)
Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details