[ Team LiB ] |
Java Naming and Directory InterfaceSun 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 ArchitectureJNDI 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. Figure 8.1. JNDI architecture.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 SpecificationWebLogic Server 8.1 fully supports JNDI version 1.2.1. Some of the features of this version of JNDI are
The following sections discuss the highlights of the packages that the JNDI 1.2.1 specification provides for. javax.namingThe javax.naming package consists of classes and interfaces that enable the user to communicate with the different naming services. It provides the ability to perform several operations such as
The following are some of the key components of this package:
javax.naming.directoryA 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. javax.naming.eventThe classes and interfaces in the javax.naming.event package allow the application to be notified of several changes to the naming service as well as to the objects bound inside. For example, events (called NamingEvents) are generated when adding a new object, changing the name (binding) of an object, and so on. 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. javax.naming.ldapThe javax.naming.ldap package allows the application to use LDAP v3–specific features including extensions and controls, which cannot be achieved using the javax.naming.directory package. 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. javax.naming.spiThe 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 ] |