In the previous sections of this chapter, much was said about the various interfaces used by naming, Nucleus services, etc. Very little has been said about Nucleus itself. This is because Nucleus itself does not have much functionality to offer. Its sole purpose is to find components in the hierarchy and create them if they don’t exist. This function is offered in the following method:

public Object resolveName (String name,
                           NameContext nameContext,
                           boolean create)

The name is the name of the component to find. If the name is a relative name, then the specified nameContext is the NameContext that will be used as a starting point of the name resolution. The create flag determines if Nucleus should attempt to create the component if it can’t be found.

Nucleus also determines the policies for describing the namespace. For example, the fact that “/” is used to separate the elements of a name is a policy issue implemented by Nucleus, not a general characteristic of NameContext. These policies are exposed in the following methods:

public String getAbsoluteName (NameContextElement element);

This returns the absolute name of a component in the Nucleus namespace. The component must implement NameContextElement in order to be examined by this method.

public String getAbsoluteElementName (NameContextElement element,
                                      String name)

This returns the absolute name of a hypothetical child of the specified element. For example, if the element is /services/servers, and the name is HttpServer, then this will return /services/servers/HttpServer.

In order for a component to use these functions, the component must have a pointer to Nucleus. If the component implements ServiceListener, then the component will be passed a pointer to Nucleus when the component is initialized. Nucleus also acts as the root of the name hierarchy.

For more information, see the description of the atg.nucleus.Nucleus class in the ATG API Reference.

 
loading table of contents...