What is JNDI in java- Naming, Names, Binding & Context ?

JNDI stands for Java Naming and Directory Interface

The most popular directory service LDAP is used to demonstrate the use of JNDI to access the directory services.

Naming and Directory Concepts:

Naming Concepts:

A Naming service allows you to look up an object given its name.
Name - Object

A Naming service's primary function is to map people friendly names to objects, such as address
objects
identifiers
objects

Example : Internet Domain Name System(DNA) maps machine names to IP Addresses.
www.example.com => 192.168.0.1

A file system maps a filename to a file reference that a program can use

C:\test\test.xml=>File Reference

Names:
To look up an object in a naming system, you supply it the name of the object.
The naming system determines the syntax that the name must follow.

A name is made of components as in :

Naming
.
Naming System Component Separator Names
UNIX file system "/" /usr/hello
DNS "." sales.example.COM
LDAP "," and "=" cn=Moni Ajith, o=Example, c=US

Bindings:

The associatino of a name with an object is called a binding.
A filename is bound to a file.

The DNS contains bindins that map machine names to IP addresses.
An LDAP name is bound to an LDAP Directory.

Context

A Context is a set of name-to-object binding.
Every context has an associated naming convention .

Example

DNS - COM(context)->Example(SubContext)
LDAP - c=us(context)->o=Example(SubContext)

Summary
An LDAP Entry such as c=us, represents a context.
An LDAP entry named relative to another LDAP entry represents a subcontext.
For DNS domain Example.com, the DNS domain name Example is a subcontext of COM.

Source:http://docs.oracle.com/javase/tutorial/jndi/overview/index.html

Analytics