Previous | Next | Trail Map | Beyond the Basics | Federation

The Next Naming System

Once a service provider has determined the next naming system (nns) pointer by using the techniques described in the previous section, the next step is to turn the nns pointer into a context, called the continuation context, and continue the operation in that context. To do this, the JNDI provides the following utility methods:

The argument to these methods is a CannotProceedException(in the API reference documentation) . The purpose of these methods is to get a context in the next naming system in which to continue the operation by using the nns pointer and other information in the CannotProceedException.

The Continuation Context

The JNDI obtains the continuation context based on information supplied in the CannotProceedException. The service provider must "fill out" the information in the CannotProceedException. Below is a table that describes the fields of this exception. The JNDI uses the information in the exception to find an object factory, described in the Storing Objects in the Directory (in the Java Objects and the Directory trail), that returns an instance of Context(in the API reference documentation) . If the JNDI cannot find an appropriate context in which to continue the operation, it throws the CannotProceedException that the service provider gave it.

Field Description
resolved name The name of the resolved object, relative to the starting context for this operation.
resolved object The nns pointer. This is used as the object argument to the object factory.
remaining name The part of the composite name that has yet to be processed.
"alt" name The name of the resolved object, relative to "alt" name context. This is used as the name argument to the object factory.
"alt" name context The context in which to resolve "alt" name. This is used as the context argument to the object factory.
environment The environment of the current context. This is used as the environment argument to the object factory.
remaining new name The remaining name to be used as the "new name" argument for Context.rename()(in the API reference documentation).

Resolving Through Subinterfaces

You'll notice from the above description that the object factory that produces the continuation context is only required to return an instance of Context. This is because it does not make sense to require intermediate naming systems to implement all of the subinterfaces of the terminal naming system. For resolution to be successful, the JNDI has the following two requirements: The purpose of the Resolver interface is to allow resolution to proceed through a provider that does not support the interface to one that does. The DirectoryManager.getContinuationDirContext() method automatically uses the Resolver interface when necessary.

Completing the Operation

After the provider gets a continuation context, it invokes the originally intended context operation on the continuation context, by using as the name argument the remaining components of the composite name. Here is an example that does this for the DirContext.search()(in the API reference documentation) method:
DirContext cctx = DirectoryManager.getContinuationDirContext(cpe);
answer = cctx.search(cpe.getRemainingName(), matchingAttrs);

At this point, the processing continues to the next naming system, where the three-step procedure of (1) determining the composite name components to process, (2) processing its components, and (3) continuing to the next naming system repeats until the terminal naming system is reached, at which point the actual operation is carried out.

Federation: End of Lesson

What's next? Now you can:


Previous | Next | Trail Map | Beyond the Basics | Federation