Java Reference
In-Depth Information
25.12. javax.naming Directory and Naming Services
This package defines the naming operations of the Java Naming and Dir-
ectory Interface ( JNDI ), with the subpackage javax.naming.directory , de-
fining the directory operations. These are designed to be independent of
any specific naming or directory service implementation. Thus a variety
of servicesnew, emerging, and already deployed onescan be accessed in
a common way.
A context, represented by the Context interface, 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 sub-
contexts. lookup is the most commonly used operation. You supply lookup
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("Duplex");
printer.print(report);
Every naming method in the Context 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 namean ordered sequence of zero
or more components. For these methods, you can use Name to represent
a composite name ( CompositeName ) so that you can use a name that spans
multiple namespaces.
The overloads that accept Name arguments 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.
The Binding class represents a name-to-object binding. It is a tuple con-
taining the name of the bound object, the name of the object's class, and
 
Search WWH ::




Custom Search