Transcript JNDI

JNDI
Java
Naming
Directory
Interface
• JNDI is an API specified in Java that provides
naming and directory functionality to
applications written in Java.
• JNDI was developed by Sun as a regular or
standard extension to Java programming
Language
• JNDI is designed especially for Java by using
Java’s object model.
• JNDI is used by Java applications can store and
retrieve named Java objects of any type.
• JNDI provides methods for performing
standard directory operations.
• Examples: Associating attributes with objects
and searching for objects using their attributes.
•JNDI is defined independent of any specific
naming or directory service implementation.
•JNDI enables Java applications to access different,
naming and directory services using a common
API.
• Different naming and directory service proider
can be plugged in seamlessly behind the common
API.
• The common API allows Java applications
to take advantage of information in a variety
of existing naming and directory services,
and allows Java applications to coexist with
legacy applications and systems.
• Examples: such as LDAP, NDS, DNS, and
NIS(YP).
JNDI Architecture
JNDI has three layers and exposes two interfaces: an
API for Java clients and servers to use and a
Service Providers Interface (SPI) for vendors who
provide JNDI services. The Naming Manager
layer maps each JNDI call to a service provider.
•The standardization of these two interfaces makes the
service provider almost transparent to the Java
application code.
•Clients can use the JNDI API to bind and
lookup over a wide range of naming services.
How Does JNDI Services Work
• Each JNDI service vendor is free to implement the
set of naming and directory services.
• They choose to support in their own way.
• All of the names in a naming system comprise the
system’s namespace.
• The naming systems use their own naming
conventions.
• A naming convention defines atomic names,
which can’t be divided, and compound
names, conglomerates of atomic names that
organize similar names in the same
namespace.
• Using JNDI as a tool, the Java application
developer can build new powerful and portable
applications that not only take advantage of Java’s
object model but are also well integrated with the
environment in which they are deployed.
• Example of where JNDI is used:
– JMS -Java Messaging Service
– JDBC -Java Database Connectivity package
– EJB - Enterprise Java Beans