|[ Team LiB ]|
Java Naming and Directory Interface
Sun Microsystems defines JNDI as “a standard extension to the Java platform, which provides Java technology-enabled applications with a unified interface to multiple naming and directory services in the enterprise. As part of the Java Enterprise API set, JNDI enables seamless connectivity to heterogeneous enterprise naming and directory services.” JNDI has been designed especially for Java. A Java application can use JNDI to retrieve Java objects. JNDI also provides for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes.
JNDI is an interface, not an implementation. It can be used to seamlessly integrate with different, possibly multiple, implementations (such as LDAP, DNS, and so on). You must still understand certain basics of the underlying implementations (such as their naming convention) to enable JNDI to connect to them, although you aren't required to understand their implementation artifacts.
Overview of the JNDI Architecture
JNDI is comprised of the JNDI SPI (service provider interface), which is used by service providers to JNDI-enable their products and the JNDI API (application programming interface), which is used by clients to connect to these service providers. Figure 8.1 describes the architecture and how clients can use the different service providers using JNDI.
In this chapter, you'll see how to use the JNDI API to access WebLogic's implementation of JNDI. Because this chapter discusses the usage of JNDI from your J2EE application, rather than writing a JNDI service provider, a discussion of the JNDI SPI is beyond the scope of this book.
Overview of the JNDI 1.2.1 Specification
The following sections discuss the highlights of the packages that the JNDI 1.2.1 specification provides for.
The following are some of the key components of this package:
A directory object is a particular type of object that holds several attributes of a computing environment, thus describing it at an atomic level. The classes and interfaces in the javax.naming.directory package allow the application to access attributes associated with directory objects. This package also provides the application with the capability to search through directory objects by passing in their attributes using the DirContext interface.
The NamingEvent's type attribute identifies the type of the event. The NamingEvent class defines four types of events, indicating different operations performed on objects (add, remove, rename, or change). Applications may register to receive one or both types of events (that is, namespace changes and object changes) by using either the EventContext or the EventDirContext interface.
You can learn more about JNDI events in the tutorial posted by Sun Microsystems at the URL http://java.sun.com/products/jndi/tutorial/index.html.
You can learn more about JNDI LDAP support in the tutorial posted by Sun Microsystems at the URL http://java.sun.com/products/jndi/tutorial/index.html.
The javax.naming.spi package allows different naming/directory service providers to provide implementation hooks to their facilities so that applications using the JNDI API can have access to those facilities. This package also provides support for the case in which one service provider implementation must access other implementations to complete a client's JNDI operations, thus providing support for composite namespaces.
You can learn more about the JNDI SPI in the tutorial posted by Sun Microsystems at the URL http://java.sun.com/products/jndi/tutorial/index.html.
|[ Team LiB ]|