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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BeanContextThe bean context.TheBeanContextin which thisBeanContextChildis nested.protected PropertyChangeSupportThePropertyChangeSupportassociated with thisBeanContextChildSupport.protected booleanA flag indicating that there has been at least onePropertyChangeVetoExceptionthrown for the attempted setBeanContext operation.protected VetoableChangeSupportTheVetoableChangeSupportassociated with thisBeanContextChildSupport. -
Constructor Summary
ConstructorsConstructorDescriptionconstruct a BeanContextChildSupport where this class has been subclassed in order to implement the JavaBean component itself.construct a BeanContextChildSupport where the JavaBean component itself implements BeanContextChild, and encapsulates this, delegating that interface to this implementation -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a PropertyChangeListener for a specific property.voidAdd a VetoableChangeListener for a specific property.voidfirePropertyChange(String name, Object oldValue, Object newValue) Report a bound property update to any registered listeners.voidfireVetoableChange(String name, Object oldValue, Object newValue) Report a vetoable property update to any registered listeners.Gets the nestingBeanContextfor thisBeanContextChildSupport.Gets theBeanContextChildassociated with thisBeanContextChildSupport.protected voidThis method may be overridden by subclasses to provide their own initialization behaviors.booleanReports whether or not this class is a delegate of another.protected voidThis method may be overridden by subclasses to provide their own release behaviors.voidRemove a PropertyChangeListener for a specific property.voidRemoves aVetoableChangeListener.voidA new service is available from the nesting BeanContext.voidA service provided by the nesting BeanContext has been revoked.voidSets theBeanContextfor thisBeanContextChildSupport.booleanvalidatePendingSetBeanContext(BeanContext newValue) Called from setBeanContext to validate (or otherwise) the pending change in the nesting BeanContext property value.
-
Field Details
-
beanContextChildPeer
TheBeanContextin which thisBeanContextChildis nested. -
pcSupport
ThePropertyChangeSupportassociated with thisBeanContextChildSupport. -
vcSupport
TheVetoableChangeSupportassociated with thisBeanContextChildSupport. -
beanContext
The bean context. -
rejectedSetBCOnce
protected transient boolean rejectedSetBCOnceA flag indicating that there has been at least onePropertyChangeVetoExceptionthrown for the attempted setBeanContext operation.
-
-
Constructor Details
-
BeanContextChildSupport
public BeanContextChildSupport()construct a BeanContextChildSupport where this class has been subclassed in order to implement the JavaBean component itself. -
BeanContextChildSupport
construct a BeanContextChildSupport where the JavaBean component itself implements BeanContextChild, and encapsulates this, delegating that interface to this implementation- Parameters:
bcc- the underlying bean context child
-
-
Method Details
-
setBeanContext
Sets theBeanContextfor thisBeanContextChildSupport.- Specified by:
setBeanContextin interfaceBeanContextChild- Parameters:
bc- the new value to be assigned to theBeanContextproperty- Throws:
PropertyVetoException- if the change is rejected
-
getBeanContext
Gets the nestingBeanContextfor thisBeanContextChildSupport.- Specified by:
getBeanContextin interfaceBeanContextChild- Returns:
- the nesting
BeanContextfor thisBeanContextChildSupport.
-
addPropertyChangeListener
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. Ifnameorpclis null, no exception is thrown and no action is taken.- Specified by:
addPropertyChangeListenerin interfaceBeanContextChild- Parameters:
name- The name of the property to listen onpcl- ThePropertyChangeListenerto be added
-
removePropertyChangeListener
Remove a PropertyChangeListener for a specific property. Ifpclwas added more than once to the same event source for the specified property, it will be notified one less time after being removed. Ifnameis null, no exception is thrown and no action is taken. Ifpclis null, or was never added for the specified property, no exception is thrown and no action is taken.- Specified by:
removePropertyChangeListenerin interfaceBeanContextChild- Parameters:
name- The name of the property that was listened onpcl- The PropertyChangeListener to be removed
-
addVetoableChangeListener
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. Ifnameorvclis null, no exception is thrown and no action is taken.- Specified by:
addVetoableChangeListenerin interfaceBeanContextChild- Parameters:
name- The name of the property to listen onvcl- TheVetoableChangeListenerto be added
-
removeVetoableChangeListener
Removes aVetoableChangeListener. Ifpclwas added more than once to the same event source for the specified property, it will be notified one less time after being removed. Ifnameis null, no exception is thrown and no action is taken. Ifvclis null, or was never added for the specified property, no exception is thrown and no action is taken.- Specified by:
removeVetoableChangeListenerin interfaceBeanContextChild- Parameters:
name- The name of the property that was listened onvcl- TheVetoableChangeListenerto be removed
-
serviceRevoked
A service provided by the nesting BeanContext has been revoked. Subclasses may override this method in order to implement their own behaviors.- Specified by:
serviceRevokedin interfaceBeanContextServiceRevokedListener- Parameters:
bcsre- TheBeanContextServiceRevokedEventfired as a result of a service being revoked
-
serviceAvailable
A new service is available from the nesting BeanContext. Subclasses may override this method in order to implement their own behaviors- Specified by:
serviceAvailablein interfaceBeanContextServicesListener- Parameters:
bcsae- The BeanContextServiceAvailableEvent fired as a result of a service becoming available
-
getBeanContextChildPeer
Gets theBeanContextChildassociated with thisBeanContextChildSupport.- Returns:
- the
BeanContextChildpeer 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
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
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:
trueif 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 required by the BeanContextChild should be obtained from the current BeanContext.
-