Naming and Directory Services
A Naming Service provides a mechanism for giving names to objects so that you can
retrieve and use those objects without knowing the location of the object. Objects can be
located on any machine accessible from your network, not necessarily the local workstation.
A real-world example is a phone directory. It stores telephone numbers against names
and addresses. To find someone’s phone number is simply a matter of using his or her
name (and possibly address) to identify the entry in the phone book and obtain the stored
phone number. There are a few complications, such as finding the right phone book to
look in, but it is essentially fairly simple.
Incidentally, naming services have a similar problem to that of finding the right phone
book. This is known as obtaining a context. A name can only be found if you examine
the right context (phone book).
A Directory Service also associates names with objects but provides additional information
by associating attributes with the objects.
The yellow pages phone directory is a simple form of a directory service. Here, businesses
often include advertisements with additional information such as a list of products
sold, professional qualifications, affiliated organizations, and even location maps for their
premises. These attributes add value to the name entry. A directory service will normally
provide the ability to find entries that have particular attributes or values for attributes.
This is similar to searching the yellow pages phone book for all plumbers running a 24-
hour emergency service within a certain area.
Yellow page style phone books also store names under different categories—for example,
plumbers or lawyers. Categorizing entries can simplify searching for a particular type of
entry. These categorized entries are a form of sub-context within the directory context of
the local phone book.
Why Use a Naming Service?
Naming Services provide an indispensable mechanism for de-coupling the provider of a
service from the consumer of the service. Naming services allow a supplier of a service
to register their service against a name. Users, or clients, of the service need only know
the name of the service to use it.
Think of the phone book once more, and how difficult it would be to find someone’s
phone number without the phone book. Obtaining your friend’s phone number means
going to their home and asking, or waiting until you meet up with them again—which
may be difficult to organize because you can’t phone them to arrange the meeting
The phone book is a directory service. In fact, a phone book is often referred to as a
phone directory. The phone directory service lets you look up a person or company’s
phone book using their name as a key.
At the end of the day, it is very difficult to imagine a world without naming services.
What is JNDI?
JNDI is a Java API that defines an interface to Naming and Directory Services for Java
programs. JNDI is just an API and not, in itself, a Naming and Directory Service. To use
JNDI, an implementation of a Naming and Directory service must be available. JNDI
provides a service-independent interface to the underlying Service Provider implementation.
Figure 3.1 shows how the JNDI layer interfaces between the Java program and the underlying
naming services. Additional naming services can be plugged into the JNDI layer by
implementing the Service Provider Interface (SPI) for JNDI.
Common Naming Services
Figure 3.1 shows that JNDI supports several well-known naming services, including the
following:
• Domain Name System (DNS) is the Internet naming service for identifying
machines on a network.
• Novell Directory Services (NDS) from Novell provides information about network
services, such as files and printers. NDS is found primarily in environments where
the main networking software is Novell.
• Network Information Service (NIS) from Sun Microsystems provides system-wide
information about machines, files, users, printers, and networks. NIS is primarily
found on Solaris systems, but Linux and some other Unix platforms support it.
• Lightweight Directory Access Protocol (LDAP) is the approved standard for an
Internet naming service. LDAP is a true directory service and supports attributes as
well as names for objects. LDAP is fast becoming the de-facto directory service for
the enterprise.
JNDI also supports some more specialized naming systems. For example, CORBA for
distributed component programming and RMI for distributed Java programming.
Although there is no named service provider for Windows Active Directory, it is supported.
Windows Active Directory supports an LDAP interface, and you can access it via the
JNDI LDAP Service Provider Interface.
沒有留言:
張貼留言