Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.beans.beancontext

Class BeanContextChildSupport

java.lang.Object
|
+--java.beans.beancontext.BeanContextChildSupport

All Implemented Interfaces:

BeanContextChild, BeanContextServicesListener, Serializable


public class BeanContextChildSupport

extends Object

implements BeanContextChild, BeanContextServicesListener, Serializable

Support for creating a BeanContextChild. This class contains the most common implementations of the methods in the BeanContextChild

Since:Author:See Also:

Field Summary

transient java.beans.beancontext.BeanContextbeanContext

The parent BeanContext.
java.beans.beancontext.BeanContextChildbeanContextChildPeer

The peer on which to perform set actions.
java.beans.PropertyChangeSupportpcSupport

Listeners are registered here and events are fired through here.
transient booleanrejectedSetBCOnce

If setBeanContext() was vetoed once before, this is set to true so that the next time, vetoes will be ignored.
java.beans.VetoableChangeSupportvcSupport

Listeners are registered here and events are fired through here.

Constructor Summary

BeanContextChildSupport()

Create a new BeanContextChildSupport with itself as the peer.
BeanContextChildSupport(java.beans.beancontext.BeanContextChild peer)

Create a new BeanContextChildSupport with the specified peer.

Method Summary

voidaddPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)

Add a listener that will be notified when a specific property changes.
voidaddVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)

Add a listener that will be notified when a specific property change is requested (a PropertyVetoException may be thrown) as well as after the change is successfully made.
voidfirePropertyChange(java.lang.String propertyName, java.lang.Object oldVal, java.lang.Object newVal)

Fire a property change.
voidfireVetoableChange(java.lang.String propertyName, java.lang.Object oldVal, java.lang.Object newVal)

Fire a vetoable property change.
java.beans.beancontext.BeanContextgetBeanContext()

Get the parent BeanContext.
java.beans.beancontext.BeanContextChildgetBeanContextChildPeer()

Get the peer (or this if there is no peer).
voidinitializeBeanContextResources()

Called by setBeanContext() to grab resources when the parent has been set.
booleanisDelegated()

Determine whether there is a peer.
voidreleaseBeanContextResources()

Called by setBeanContext() to release resources of a what will soon no longer be the parent.
voidremovePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)

Remove a listener to a certain property.
voidremoveVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)

Remove a listener to a certain property.
voidserviceAvailable(java.beans.beancontext.BeanContextServiceAvailableEvent event)

Called by BeanContextServices whenever a service is made available.
voidserviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent event)

Called by BeanContextServices.revokeService() to indicate that a service has been revoked.
voidsetBeanContext(java.beans.beancontext.BeanContext newBeanContext)

Set the parent BeanContext.
booleanvalidatePendingSetBeanContext(java.beans.beancontext.BeanContext newBeanContext)

Called by setBeanContext() to determine whether the set should be rejected.

Field Details

beanContext

protected transient BeanContext beanContext

The parent BeanContext.


beanContextChildPeer

public BeanContextChild beanContextChildPeer

The peer on which to perform set actions. This is here so that this class can be used as a peer.

When extending this class, this variable will be set to this.


pcSupport

protected PropertyChangeSupport pcSupport

Listeners are registered here and events are fired through here.


rejectedSetBCOnce

protected transient boolean rejectedSetBCOnce

If setBeanContext() was vetoed once before, this is set to true so that the next time, vetoes will be ignored.


vcSupport

protected VetoableChangeSupport vcSupport

Listeners are registered here and events are fired through here.


Constructor Details

BeanContextChildSupport

public BeanContextChildSupport()

Create a new BeanContextChildSupport with itself as the peer. This is meant to be used when you subclass BeanContextChildSupport to create your child.


BeanContextChildSupport

public BeanContextChildSupport(java.beans.beancontext.BeanContextChild peer)

Create a new BeanContextChildSupport with the specified peer.

Parameters:


Method Details

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)

Add a listener that will be notified when a specific property changes.

Parameters:


addVetoableChangeListener

public void addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)

Add a listener that will be notified when a specific property change is requested (a PropertyVetoException may be thrown) as well as after the change is successfully made.

Parameters:


firePropertyChange

public void firePropertyChange(java.lang.String propertyName, java.lang.Object oldVal, java.lang.Object newVal)

Fire a property change.

Parameters:


fireVetoableChange

public void fireVetoableChange(java.lang.String propertyName, java.lang.Object oldVal, java.lang.Object newVal)

Fire a vetoable property change.

Parameters:

Throws:


getBeanContext

public BeanContext getBeanContext()

Get the parent BeanContext.

Returns:


getBeanContextChildPeer

public BeanContextChild getBeanContextChildPeer()

Get the peer (or this if there is no peer).

Returns:


initializeBeanContextResources

protected void initializeBeanContextResources()

Called by setBeanContext() to grab resources when the parent has been set.

This method is meant to be overriden. BeanContextChildSupport's implementation does nothing.


isDelegated

public boolean isDelegated()

Determine whether there is a peer. This is true iff getBeanContextChildPeer() == this.

Returns:


releaseBeanContextResources

protected void releaseBeanContextResources()

Called by setBeanContext() to release resources of a what will soon no longer be the parent.

This method is meant to be overriden. BeanContextChildSupport's implementation does nothing.


removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)

Remove a listener to a certain property.

Parameters:


removeVetoableChangeListener

public void removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)

Remove a listener to a certain property.

Parameters:


serviceAvailable

public void serviceAvailable(java.beans.beancontext.BeanContextServiceAvailableEvent event)

Called by BeanContextServices whenever a service is made available.

This method is meant to be overriden. BeanContextChildSupport's implementation does nothing.

Parameters:


serviceRevoked

public void serviceRevoked(java.beans.beancontext.BeanContextServiceRevokedEvent event)

Called by BeanContextServices.revokeService() to indicate that a service has been revoked. If you have a reference to such a service, it should be discarded and may no longer function properly. getService() will no longer work on the specified service class after this event has been fired.

This method is meant to be overriden. BeanContextChildSupport's implementation does nothing.

Parameters:

See Also:


setBeanContext

public void setBeanContext(java.beans.beancontext.BeanContext newBeanContext)

Set the parent BeanContext.

When this Object is being added to a new BeanContext or moved from an old one, a non-null value will be passed in.

When this Object is being removed from the current BeanContext, setBeanContext() will receive the parameter null.

Order of events:

  1. If the new BeanContext is the same as the old one, nothing happens.
  2. If the change has not been rejected or vetoed before, call validatePendingSetBeanContext(). If this call returns false, the change is rejected and a PropertyVetoException is thrown.
  3. If the change has not been rejected or vetoed before, VetoableChangeEvents are fired with the name "beanContext", using the fireVetoableChange() method. If a veto occurs, reversion events are fired using the same method, the change is rejected, and the veto is rethrown.
  4. releaseBeanContextResources() is called.
  5. The change is made.
  6. PropertyChangeEvents are fired using the firePropertyChange() method.
  7. initializeBeanContextResources() is called.

Parameters:

Throws:


validatePendingSetBeanContext

public boolean validatePendingSetBeanContext(java.beans.beancontext.BeanContext newBeanContext)

Called by setBeanContext() to determine whether the set should be rejected.

This method is meant to be overriden. BeanContextChildSupport's implementation simply returns true.

Parameters:

Returns: