1. What is JNDI?
Answer: The Java Naming and Directory Interface (JNDI) is part of the Java platform, providing applications based on Java technology with a unified interface to multiple naming and directory services.
-----------------------------------------------------------------
2.What protocols does JNDI provide an interface to?
Answer: JNDI itself is independent of any specific directory access protocol. Individual service providers determine the protocols to support. JNDI supports popular protocols, such as LDAP (Light weight Directory Access Protocol) , NDS(Netscape Directory Service), DNS(Domain Naming Service), and NIS(Network Information Service), supplied by different vendors.
-----------------------------------------------------------------
3. What is Context and InitialContext?
Answer: A context represents a set of bindings within a naming service. A context object provides the methods for binding names to objects and unbinding names from objects, for renaming objects, and for listing the bindings. JNDI performs all naming operations relative to a context.
The JNDI specification defines an InitialContext class. This class is instantiated with properties that define the type of naming service in use (such as provider URL, security, ID and password to use when connecting).
-----------------------------------------------------------------
4. What's the difference between JNDI lookup(), list(), listBindings(), and search()?
Answer:
-lookup() attempts to find the specified object in the given context.
i.e., it looks for a single, specific object and either finds it in the current context or it fails.
-list() attempts to return an enumeration of all of the Name-ClassPair's of all of the objects in the current context. i.e., it's a listing of all of the objects in the current context but only returns the object's name and the
name of the class to which the object belongs.
-listBindings() attempts to return an enumeration of the Binding's of all of the objects in the current context. i.e., it's a listing of all of the objects in the current context with the object's name, its class name, and a reference to the object itself.
-search() attempts to return an enumeration of all of the objects matching a given set of search criteria. It can search across multiple contexts (or not). It can return whatever attributes of the objects that you desire. It's by far the most complex and powerful of these options but is also the most expensive.
-----------------------------------------------------------------
5. Name the components of JNDI.
Answer:
Naming Interface- The naming interface organizes information hierarchically and maps human-friendly names to addresses or objects that are machine-friendly. It allows access to named objects through multiple namespaces.
Directory Interface- JNDI includes a directory service interface that provides access to directory objects,which can contain attributes, thereby providing attribute-based searching and schema support.
Service Provider Interface- JNDI comes with the SPI, which supports the protocols provided by third parties.
-----------------------------------------------------------------
6. Is JNDI a protocol? Where is it used?
Answer: Yes. JNDI is a protocol.
-HotJava Views 1.1 is using JNDI to access LDAP.
-Enterprise APIs such as Enterprise JavaBeans, Java Message Service, JDBC 2.0 make use of JNDI to for their naming and directory needs.
-RMI over IIOP applications can use JNDI to access the CORBA (COS) naming service.