O'Reilly - Java Message Service
O'Reilly - Java Message Service
O'Reilly - Java Message Service
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Understanding JNDI<br />
<strong>Java</strong> <strong>Message</strong> <strong>Service</strong><br />
JNDI is a standard <strong>Java</strong> extension that provides a uniform API for accessing a<br />
variety of directory and naming services. In this respect, it is somewhat similar to<br />
JDBC. JDBC lets you write code that can access different relational databases such<br />
as Oracle, SQLServer, or Sybase; JNDI lets you write code that can access different<br />
directory and naming services, such as LDAP, Novell Netware NDS, CORBA<br />
Naming <strong>Service</strong>, and proprietary naming services provided by JMS servers.<br />
In JMS, JNDI is used mostly as a naming service to locate administered objects.<br />
Administered objects are JMS objects that are created and configured by the system<br />
administrator. Administered objects include JMS ConnectionFactory and<br />
Destination objects like topics and queues.<br />
Administered objects are bound to a name in a naming service. A naming service<br />
associates names with distributed objects, files, and devices so that they can be<br />
located on the network using simple names instead of cryptic network addresses. An<br />
example of a naming service is the DNS, which converts an Internet hostname like<br />
www.oreilly.com into a network address that browsers use to connect to web<br />
servers. There are many other naming services, such as COSNaming in CORBA<br />
and the <strong>Java</strong> RMI registry. Naming services allow printers, distributed objects, and<br />
JMS administered objects to be bound to names and organized in a hierarchy similar<br />
to a filesystem. A directory service is a more sophisticated kind of naming service.<br />
JNDI provides an abstraction that hides the specifics of the naming service, making<br />
client applications more portable. Using JNDI, JMS clients can browse a naming<br />
service and obtain references to administered objects without knowing the details of<br />
the naming service or how it is implemented. JMS servers are usually be used in<br />
combination with a standard JNDI driver (a.k.a. service provider) and directory<br />
service like LDAP, or provide a proprietary JNDI service provider and directory<br />
service.<br />
JNDI is both virtual and dynamic. It is virtual because it allows one naming service<br />
to be linked to another. Using JNDI, you can drill down through directories to files,<br />
printers, JMS administered objects, and other resources following virtual links<br />
between naming services. The user doesn't know or care where the directories are<br />
actually located. As an administrator, you can create virtual directories that span a<br />
variety of different services over many different physical locations.<br />
JNDI is dynamic because it allows the JNDI drivers for specific types of naming<br />
and directory services to be loaded dynamically at runtime. A driver maps a specific<br />
kind of naming or directory service into the standard JNDI class interfaces. Drivers<br />
have been created for LDAP, Novell NetWare NDS, Sun Solaris NIS+, CORBA<br />
COSNaming, and many other types of naming and directroy services, including<br />
proprietary ones. Dynamically loading JNDI drivers (service providers) makes it<br />
possible for a client to navigate across arbitrary directory services without knowing<br />
in advance what kinds of services it is likely to find.<br />
24