It is often useful for a NameContext
to fire an event whenever an element is bound or unbound from that NameContext
. For example, a pricing component might wish to be notified whenever an element is bound into a shopping cart component.
A NameContext
declares that it fires such events by implementing NameContextBindingEventSource
. This declares that NameContextBindingListeners
can be added to the NameContext
. These listeners receive notifications whenever elements are bound or unbound from the NameContext
.
If a component declares that it implements NameContextBindingEventSource
, that component is also expected to perform the following behavior: whenever an element is bound or unbound from the NameContext
, the NameContext
should check to see if that element implements NameContextBindingListener
. If it does, the NameContext
should send a bound or unbound event to that element. This behavior must be performed in addition to notifying the registered listeners.
A sample implementation of this behavior can be found in the source code for atg.naming.NameContextImpl
, found in the <ATG11dir>/DAS/src/Java/atg/naming
directory. This class implements all of the following interfaces:
atg.naming.NameContextBindingEventSource
, which extendsatg.naming.NameContext
, which extendsatg.naming.NameContextElement
, which extendsatg.naming.NameContextBindingListener
If your component implements NameContext
, you might consider implementing NameContextBindingEventSource
as well. This is usually only required if arbitrary elements are going to be bound and unbound from your NameContext
, which is usually not the case for an application-specific component. For example, the last example of the previous section implements a read-only NameContext
, and implementing NameContextBindingEventSource
on that object is not very useful.