What is JNDI?
by, 07-07-2012 at 03:53 PM (1084 Views)
To access various naming or directory services, JNDI or Java Naming and directory interface is used that is basically an application programming interface (API). Java Naming and directory interfacen is not considered specified to some specific naming/directory service. Various system could be accessed by it which include file systems; Java RMI, EJB, distributed object system & directory services for example NIS+, Novell NetWare and LDAP.
JNDI and JDBC are same because both of them are object oriented Java API which gives one common abstraction to access the services, from varying vendors. Various relational databases could be accessed by JDBC and various naming or directory services could be accessed by JNDI. It is also possible to access different service’s brands by the help of one single API as both JNDI and JDBC are subscribed to the similar architectural tenet. This means one common abstraction which could be implemented by many vendors. API is the common abstraction. This way service’s objectified view is provided by it which keeps the details of brand of service hidden. Vendor provides implementation by plugging into APIs and implementing the codes which are specific so that to access the product of vendor.
One SPI and two APIs are provided by the JNDI. A naming API is present in JNDI which permits the java application for doing access of the naming systems, for example Cobra’s naming services. Also directory API is present in it which does the extension of the naming services so that access could be provided to the directory services, for example LDAP. JNDI consists of Service provider interface that is basically a programming model which is used by vendors so that to write down the plug-ins of JNDI or for the specified product’s implementation. Plug-in of every vendor is known as service provider.
JNDI APIs are implemented by a service provider so that the product of vendor could be accessed by the Java application. Service provider’s mplementation details are kept hidden by the JNDI therefore JNDI that is used by a Java developer could be using the similar objects/methods, without bothering about the naming or directory service brand that is being accessed. This is what we call the real power present for APIs, for example JNDI and JDBC. One programming model is provided by them to access various products; different kind of programming model is not required to be learnt whenever some new product is being used.