When Nucleus creates your component from a properties file, it first calls your class constructor with no arguments. It then binds the component into the namespace of the NameContext that will contain the component. For example, if your component was created with the name /services/servers/LatteServer, then the component will be bound into the NameContext at /services/servers, using the name LatteServer.

If your class implements the atg.naming.NameContextBindingListener interface, then the component will be notified when it is bound into a NameContext, and will also receive notification when it is unbound from that NameContext.

A typical implementation of NameContextBindingListener looks like this:

import atg.naming.*;

public YourClass implements NameContextBindingListener {
  String name;
  NameContext nameContext;

  public void nameContextElementBound (NameContextBindingEvent ev) {
    if (ev.getElement () == this) {
      nameContext = ev.getNameContext ();
      name = ev.getName ();
    }
  }
  public void nameContextElementUnbound (NameContextBindingEvent ev) {
    if (ev.getElement () == this) {
      nameContext = null;
      name = null;
    }
  }
}

Notice how the methods check to make sure that the element in the event really is the object. This is because the same methods are called if the object is registered as a listener for binding events on other NameContexts. For the time being, just remember to include this check before setting the member variables.

Although you can generally assume that these notifications will happen all the time, the notifications usually happen only if the NameContext also implements NameContextBindingEventSource. This is because the NameContext is responsible for sending the events, so if a NameContext has a less responsible implementation, it might not send the notifications.

 
loading table of contents...