- java.lang.Object
-
- java.beans.beancontext.BeanContextChildSupport
-
- All Implemented Interfaces:
- BeanContextChild, BeanContextServiceRevokedListener, BeanContextServicesListener, Serializable, EventListener
- Direct Known Subclasses:
- BeanContextSupport
public class BeanContextChildSupport extends Object implements BeanContextChild, BeanContextServicesListener, Serializable
This is a general support class to provide support for implementing the BeanContextChild protocol. This class may either be directly subclassed, or encapsulated and delegated to in order to implement this interface for a given component.
- Since:
- 1.2
- See Also:
BeanContext
,BeanContextServices
,BeanContextChild
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description protected BeanContext
beanContext
BeanContextChild
beanContextChildPeer
TheBeanContext
in which thisBeanContextChild
is nested.protected PropertyChangeSupport
pcSupport
The PropertyChangeSupport associated with this BeanContextChildSupport.protected boolean
rejectedSetBCOnce
A flag indicating that there has been at least onePropertyChangeVetoException
thrown for the attempted setBeanContext operation.protected VetoableChangeSupport
vcSupport
The VetoableChangeSupport associated with this BeanContextChildSupport.
-
Constructor Summary
Constructors Constructor and Description BeanContextChildSupport()
construct a BeanContextChildSupport where this class has been subclassed in order to implement the JavaBean component itself.BeanContextChildSupport(BeanContextChild bcc)
construct a BeanContextChildSupport where the JavaBean component itself implements BeanContextChild, and encapsulates this, delegating that interface to this implementation
-
Method Summary
Methods Modifier and Type Method and Description void
addPropertyChangeListener(String name, PropertyChangeListener pcl)
Add a PropertyChangeListener for a specific property.void
addVetoableChangeListener(String name, VetoableChangeListener vcl)
Add a VetoableChangeListener for a specific property.void
firePropertyChange(String name, Object oldValue, Object newValue)
Report a bound property update to any registered listeners.void
fireVetoableChange(String name, Object oldValue, Object newValue)
Report a vetoable property update to any registered listeners.BeanContext
getBeanContext()
Gets the nestingBeanContext
for thisBeanContextChildSupport
.BeanContextChild
getBeanContextChildPeer()
Gets the BeanContextChild associated with this BeanContextChildSupport.protected void
initializeBeanContextResources()
This method may be overridden by subclasses to provide their own initialization behaviors.boolean
isDelegated()
Reports whether or not this class is a delegate of another.protected void
releaseBeanContextResources()
This method may be overridden by subclasses to provide their own release behaviors.void
removePropertyChangeListener(String name, PropertyChangeListener pcl)
Remove a PropertyChangeListener for a specific property.void
removeVetoableChangeListener(String name, VetoableChangeListener vcl)
Removes aVetoableChangeListener
.void
serviceAvailable(BeanContextServiceAvailableEvent bcsae)
A new service is available from the nesting BeanContext.void
serviceRevoked(BeanContextServiceRevokedEvent bcsre)
A service provided by the nesting BeanContext has been revoked.void
setBeanContext(BeanContext bc)
Sets theBeanContext
for thisBeanContextChildSupport
.boolean
validatePendingSetBeanContext(BeanContext newValue)
Called from setBeanContext to validate (or otherwise) the pending change in the nesting BeanContext property value.
-
-
-
Field Detail
-
beanContextChildPeer
public BeanContextChild beanContextChildPeer
TheBeanContext
in which thisBeanContextChild
is nested.
-
pcSupport
protected PropertyChangeSupport pcSupport
The PropertyChangeSupport associated with this BeanContextChildSupport.
-
vcSupport
protected VetoableChangeSupport vcSupport
The VetoableChangeSupport associated with this BeanContextChildSupport.
-
beanContext
protected transient BeanContext beanContext
-
rejectedSetBCOnce
protected transient boolean rejectedSetBCOnce
A flag indicating that there has been at least onePropertyChangeVetoException
thrown for the attempted setBeanContext operation.
-
-
Constructor Detail
-
BeanContextChildSupport
public BeanContextChildSupport()
construct a BeanContextChildSupport where this class has been subclassed in order to implement the JavaBean component itself.
-
BeanContextChildSupport
public BeanContextChildSupport(BeanContextChild bcc)
construct a BeanContextChildSupport where the JavaBean component itself implements BeanContextChild, and encapsulates this, delegating that interface to this implementation
-
-
Method Detail
-
setBeanContext
public void setBeanContext(BeanContext bc) throws PropertyVetoException
Sets theBeanContext
for thisBeanContextChildSupport
.- Specified by:
setBeanContext
in interfaceBeanContextChild
- Parameters:
bc
- the new value to be assigned to theBeanContext
property- Throws:
- if the change is rejectedPropertyVetoException
PropertyVetoException
-
getBeanContext
public BeanContext getBeanContext()
Gets the nestingBeanContext
for thisBeanContextChildSupport
.- Specified by:
getBeanContext
in interfaceBeanContextChild
- Returns:
- the nesting
BeanContext
for thisBeanContextChildSupport
.
-
addPropertyChangeListener
public void addPropertyChangeListener(String name, PropertyChangeListener pcl)
Add a PropertyChangeListener for a specific property. The same listener object may be added more than once. For each property, the listener will be invoked the number of times it was added for that property. Ifname
orpcl
is null, no exception is thrown and no action is taken.- Specified by:
addPropertyChangeListener
in interfaceBeanContextChild
- Parameters:
name
- The name of the property to listen onpcl
- ThePropertyChangeListener
to be added
-
removePropertyChangeListener
public void removePropertyChangeListener(String name, PropertyChangeListener pcl)
Remove a PropertyChangeListener for a specific property. Ifpcl
was added more than once to the same event source for the specified property, it will be notified one less time after being removed. Ifname
is null, no exception is thrown and no action is taken. Ifpcl
is null, or was never added for the specified property, no exception is thrown and no action is taken.- Specified by:
removePropertyChangeListener
in interfaceBeanContextChild
- Parameters:
name
- The name of the property that was listened onpcl
- The PropertyChangeListener to be removed
-
addVetoableChangeListener
public void addVetoableChangeListener(String name, VetoableChangeListener vcl)
Add a VetoableChangeListener for a specific property. The same listener object may be added more than once. For each property, the listener will be invoked the number of times it was added for that property. Ifname
orvcl
is null, no exception is thrown and no action is taken.- Specified by:
addVetoableChangeListener
in interfaceBeanContextChild
- Parameters:
name
- The name of the property to listen onvcl
- TheVetoableChangeListener
to be added
-
removeVetoableChangeListener
public void removeVetoableChangeListener(String name, VetoableChangeListener vcl)
Removes aVetoableChangeListener
. Ifpcl
was added more than once to the same event source for the specified property, it will be notified one less time after being removed. Ifname
is null, no exception is thrown and no action is taken. Ifvcl
is null, or was never added for the specified property, no exception is thrown and no action is taken.- Specified by:
removeVetoableChangeListener
in interfaceBeanContextChild
- Parameters:
name
- The name of the property that was listened onvcl
- TheVetoableChangeListener
to be removed
-
serviceRevoked
public void serviceRevoked(BeanContextServiceRevokedEvent bcsre)
A service provided by the nesting BeanContext has been revoked. Subclasses may override this method in order to implement their own behaviors.- Specified by:
serviceRevoked
in interfaceBeanContextServiceRevokedListener
- Parameters:
bcsre
- TheBeanContextServiceRevokedEvent
fired as a result of a service being revoked
-
serviceAvailable
public void serviceAvailable(BeanContextServiceAvailableEvent bcsae)
A new service is available from the nesting BeanContext. Subclasses may override this method in order to implement their own behaviors- Specified by:
serviceAvailable
in interfaceBeanContextServicesListener
- Parameters:
bcsae
- The BeanContextServiceAvailableEvent fired as a result of a service becoming available
-
getBeanContextChildPeer
public BeanContextChild getBeanContextChildPeer()
Gets the BeanContextChild associated with this BeanContextChildSupport.- Returns:
- the BeanContextChild peer of this class
-
isDelegated
public boolean isDelegated()
Reports whether or not this class is a delegate of another.- Returns:
- true if this class is a delegate of another
-
firePropertyChange
public void firePropertyChange(String name, Object oldValue, Object newValue)
Report a bound property update to any registered listeners. No event is fired if old and new are equal and non-null.- Parameters:
name
- The programmatic name of the property that was changedoldValue
- The old value of the propertynewValue
- The new value of the property
-
fireVetoableChange
public void fireVetoableChange(String name, Object oldValue, Object newValue) throws PropertyVetoException
Report a vetoable property update to any registered listeners. If anyone vetos the change, then fire a new event reverting everyone to the old value and then rethrow the PropertyVetoException.No event is fired if old and new are equal and non-null.
- Parameters:
name
- The programmatic name of the property that is about to changeoldValue
- The old value of the propertynewValue
- - The new value of the property- Throws:
PropertyVetoException
- if the recipient wishes the property change to be rolled back.
-
validatePendingSetBeanContext
public boolean validatePendingSetBeanContext(BeanContext newValue)
Called from setBeanContext to validate (or otherwise) the pending change in the nesting BeanContext property value. Returning false will cause setBeanContext to throw PropertyVetoException.- Parameters:
newValue
- the new value that has been requested for the BeanContext property- Returns:
true
if the change operation is to be vetoed
-
releaseBeanContextResources
protected void releaseBeanContextResources()
This method may be overridden by subclasses to provide their own release behaviors. When invoked any resources held by this instance obtained from its current BeanContext property should be released since the object is no longer nested within that BeanContext.
-
initializeBeanContextResources
protected void initializeBeanContextResources()
This method may be overridden by subclasses to provide their own initialization behaviors. When invoked any resources requried by the BeanContextChild should be obtained from the current BeanContext.
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/beans/beancontext/beancontextchildsupport.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.