JNDI stands for Java Naming and directory interface is a Application programming interface (API).It provides naming and directory functionality to application written using the Java. It is independent of any specific directory service implementation so it can be accessed in a common way. It is mainly used to set up a database connection pool on a Java EE application server. Any application that’s deployed on that server can gain access to the connections they need using the JNDI name java:comp/env/FooBarPool without having to know the details about the connection.
Who should use JNDI?
Any Java application that needs to access information about users, machines, networks, and services. User information includes security credentials, phone numbers, electronic and postal mail addresses, and application preferences. Machine information includes network addresses, machine configurations, etc. In addition, any Java application that needs to either export objects or access objects exported by other applications and services. Examples include printers, calendars, and networked file systems.
Can you explain Naming service?
A naming service maintains a set of bindings. Bindings relate names to objects. All objects in a naming system are named in the same way (that is, they subscribe to the same naming convention). Clients use the naming service to locate objects by name.
There are different existing naming services, few of which are detailed below.
Common Object Services Naming (COS): The naming service for CORBA applications; allows applications to store and access references to CORBA objects.
Domain Name System (DNS): The Internet’s naming service; maps people-friendly names (such as www.xxx.com) into computer-friendly IP (Internet Protocol) addresses in dotted-quad notation (207.69.175.36)Interestingly, DNS is a distributed naming service, meaning that the service and its underlying database is spread across many hosts on the Internet.
Lightweight Directory Access Protocol (LDAP): LDAP developed by the University of Michigan; as its name implies, it is a lightweight version of DAP (Directory Access Protocol), which in turn is part of X.500, a standard for network directory services. Currently, over 40 companies endorse LDAP.
Network Information System (NIS) and NIS+: NIS developed by Sun Microsystems. Both allow users to access files and applications on any host with a single ID and password.
Can I use JNDI now?
Yes, Sun Microsystems has released JNDI as a Java Standard Extension. Sun Microsystems has also released service providers that plug in seamlessly behind JNDI for a number of naming and directory services: LDAP, NIS, CORBA (COS) Naming, and files. These and service providers produced by other vendors are available for download.
Where is JNDI being used in the Java platform?
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.
Who will provide implementations of JNDI?
At the time of this writing, IBM, Novell, Sun, and WebLogic have produced service providers for JNDI. We maintain a listing of publicly available service providers.
What protocols does JNDI provide an interface to?
JNDI itself is independent of any specific directory access protocol. Individual service providers determine the protocols to support. There will be provider implementations for popular protocols, such as LDAP, NDS, DNS, and NIS(YP), supplied by different vendors.
How does JNDI relate to LDAP?
JNDI provides an excellent object-oriented abstraction of directory and naming. Developers using JNDI can produce queries that use LDAP or other access protocols to retrieve results; however, they are not limited to LDAP nor do they have to develop their applications wired to LDAP. JNDI supports the key capabilities in LDAP v3.
How does JNDI relate to Netscape's Java LDAP API?
JNDI is a generic directory API for Java programs. It is analogous to the java.io.File class for accessing files. There might be some administrative programs that need to manipulate a file at the protocol level (such as NFS), but typically all Java applications use the File class to access to file system. Similarly, most Java programs should use JNDI to access directories. Applications that need to manipulate directory content at the protocol level may choose to use Netscape’s API.
How does JNDI relate to OMG's CORBA standards for naming?
A Java CORBA application can use JNDI to access to the CORBA (COS) name service, as well as other naming and directory services. It offers the application one interface for accessing all these naming and directory services.
Using JNDI also paves the way for Java CORBA applications to use a distributed enterprise-level service like LDAP to store object references.
How does JNDI relate to Microsoft's ADSI?
The Java ADSI package allows Java programs to access Active Directory based on the COM model. Although it can be used to access other directories, it is a Windows-centric solution.
JNDI offers Java applications, regardless of whether they’re running on Windows or accessing Active Directory, to access directories using the Java object model. For example, you can manipulate objects such as AWT and JavaBeans components, bind them into the directory, and look them back up without having to do any translation or deal with data representation issues.
What is XFN and how does this relate to JNDI?
XFN is X/Open Federated Naming, a C-based standard for accessing multiple, possibly federated naming and directory services. A programmer familiar with XFN will find it easy to use JNDI.
What about security?
Different directories have different ways of dealing with security. JNDI allows for applications to work in conjunction with directory-specific security systems. In the future, JNDI-based applications will be able to take advantage of any single sign-on mechanism developed for the Java platform.
Explain what is a naming service in JNDI?
A naming service maintains a set of bindings that relate names to objects.
A naming service follows naming convention due to which all objects in a naming system are named in the same way.
Clients use the naming service to locate objects by name.
What is a naming service?
Naming services map objects with names. It maps a reference to an object by a user friendly name. For example a machine maps its ip address. The association of an object with a name is called ‘binding’. Examples : Domain Naming Service, File systems.
• A naming service maintains a set of bindings that relate names to objects.
• A naming service follows naming convention due to which all objects in a naming system are named in the same way.
• Clients use the naming service to locate objects by name.
What is a directory service?
Searching for files and directories done by providing Directory services. A directory service is a set of names. The user and resource information and machine addresses are summarized by directory service. For example, for a given user name, the service returns the attributes of the user such as telephone no, email address etc. A directory service use the databases that specialized and hierarchical in design.
A directory service enables the look up of a name and information associated with that name. It is a service which stores and manages descriptions of metadata and provides an interface by which descriptions can be looked for and retrieved.
How does JNDI relate to LDAP?
JNDI provides an excellent object-oriented abstraction of directory and naming. Developers using JNDI can produce queries that use LDAP or other access protocols to retrieve results.
Explain the importance of JNDI?
To centralize the information storage, the enterprises uses LDAP. The information is of user names, passwords, email addresses, printers, and determination of database access. Multiple database management is reduced by centralizing the information.
JNDI is a standard Java API
JNDI provides a common interface to naming services like DNS, LDAP, Active Directory, RMI registry, COS registry, NIS, and file systems.
The JNDI API has:
A client API that is used to access naming services.
A service provider interface (SPI) that allows the user to create JNDI implementations for naming services.
Explain why we need JNDI if communication to systems via LDAP is possible?
Most of the operations are with databases and servers in LDAP. Using JNDI multiple dbms can be reduced by centralizing the information. The centralization of information storage is done by LDAP.
JNDI is also used to lookup resources like a database or a message queue. With JNDI you get a uniform way to access directory services.
What is an applet? How does applet differ from applications?
• A program that a Java enabled browser can download and run is an Applet.
• An applet is embedded in a web-page and runs in the browser context.
• The java.applet.Applet class provides a standard interface between the applet and the browser environment.
• Applets cannot perform actions such as reading/writing to the file system. Java applications run standalone, outside the browser.
Can you explain core interface of JNDI?
In JNDI, Context interface is the core interface for looking up, binding/unbinding, renaming objects and creating and destroying subcontexts.