| |||||||||
The Java Naming and Directory Interface (JNDI) is an API for directory services. It allows clients to discover and lookup data and objects via a name and, like all Java APIs, is independent of the actual implementation. Additionally, it specifies an service provider interface or SPI that allows directory service implementations to be plugged into the framework. The implementations may make use of a server, use a flat file or a database, the choice is up to the vendor.
The JNDI API is used by the Java RMI and J2EE APIs to lookup objects in a network. JINI has its own lookup service and does not use the JNDI API.
The API provides:
The SPI portion allows support for practically any kind of naming or directory service including:
JNDI organizes its names into a hierarchy. A name can be any String such as "com.mydomain.ejb.MyBean". A name can also be an object that supports the Name interface, however Strings are the most commonly used way of naming an object. A name is bound to an object in the directory. This is done by storing either the object or a