This package defines the naming operations of the Java Naming and Directory Interface™ (JNDI). JNDI provides naming and directory functionality to applications written in the Java programming language. It is designed to be independent of any specific naming or directory service implementation. Thus a variety of services--new, emerging, and already deployed ones--can be accessed in a common way.
This package defines the notion of a context, represented
A context consists of a set of name-to-object bindings.
Context is the core interface for looking up, binding, unbinding,
and renaming objects, and for creating and destroying subcontexts.
lookup() is the most commonly used operation.
the name of the object you want
to look up, and it returns the object bound to that name.
For example, the following code fragment looks up
a printer and sends a document to the printer object
to be printed:
Printer printer = (Printer)ctx.lookup("treekiller"); printer.print(report);
Every naming method in the
interface has two
overloads: one that accepts a
Name argument and one that accepts a string name.
Name is an interface that represents a generic
name--an ordered sequence of zero of more components.
For these methods,
Name can be used to represent a
composite name (
so that you can name an object using a name which spans multiple namespaces.
The overloads that accept
are useful for applications that need to manipulate names: composing
them, comparing components, and so on.
The overloads that accept string names are likely to be more useful
for simple applications, such as those that simply read in a name
and look up the corresponding object.
Bindingclass represents a name-to-object binding. It is a tuple containing the name of the bound object, the name of the object's class, and the object itself.
Binding class is actually a subclass of
NameClassPair, which consists
simply of the object's name and the object's class name.
NameClassPair is useful when you only want
information about the object's class and do not want to
pay the extra cost of getting the object.
Referenceclass, which contains information on how to construct a copy of the object. JNDI will attempt to turn references looked up from the directory into the Java objects they represent, so that JNDI clients have the illusion that what is stored in the directory are Java objects.
InitialContext, which provides a starting point for naming and directory operations. Once you have an initial context, you can use it to look up other contexts and objects.
NamingException. Programs interested in dealing with a particular exception can catch the corresponding subclass of the exception. Otherwise, programs should catch