Вы находитесь на странице: 1из 3

Internet and Web Programming

Slot – E1
DA-1

Aditya Firoda
-16BCE2184

JNDI (Java Naming and Directory Interface)

JNDI is a Java API for an index benefit that permits Java programming customers to find and
look into information and assets (as Java objects) through a name. Like all Java APIs that
interface with host frameworks, JNDI is autonomous of the basic usage. Moreover, it
determines a specialist co-op interface (SPI) that permits registry benefit executions to be
connected to the structure. The data looked into through JNDI might be provided by a
server, a level document, or a database; the decision is up to the execution utilized.
Ordinary employments of JNDI include:

 Connecting a Java application to an outer catalogue benefit, (for example, a location


database or a LDAP server)
 Allowing a Java Servlet to look into arrangement data given by the facilitating web
compartment.
JNDI is additionally characterized free of a particular naming or catalogue benefit execution.
It empowers applications to get to various, perhaps different, naming and catalogue
administrations utilizing a typical API. Distinctive naming and registry specialist co-ops can
be connected to flawlessly behind this normal API. This empowers Java innovation based
applications to exploit data in an assortment of existing naming and index administrations,
for example, LDAP, NDS, DNS, and NIS(YP), and in addition empowering the applications to
coincide with inheritance programming and frameworks.

WHEN IS IT USED?
The most widely recognized utilize case is to set up a database association pool on a Java EE
application server. Any application that is conveyed on that server can access the
associations they require utilizing the JNDI name java:comp/env/FooBarPool without
knowing the insights about the association.
This has a few points of interest:
• If you have a sending arrangement where applications move from devl->int->test-
>prod conditions, you can utilize the equivalent JNDI name in every condition and shroud
the real database being utilized. Applications don't need to change as they relocate between
situations.
• You can limit the quantity of people who need to know the certifications for getting
to a creation database. Just the Java EE application server has to know whether you utilize
JNDI.

ARCHITECTURE –
JNDI has three layers and uncovered two interfaces:
• An API for Java customers and servers to utilize
• A Service Providers Interface (SPI) for merchants who give JNDI administrations.
• The Naming Manager layer maps each JNDI call to a specialist organization
JNDI comprises of several packages:

 javax.naming

 java.naming.directory

 javax.naming.event

 javax.naming.ldap

 javax.naming.spi

For most EJB applications, the naming administration highlights are utilized more than the
catalogue benefit highlights.
This is like the Java Database Connectivity (JDBC) API where you should have a JDBC driver
to utilize the JDBC APIs to interface with a database. With JNDI, the merchant gave usage is
known as a Service Provider Interface (SPI), and it enables the JNDI techniques to be
approached a specific naming administration.
The SPI enables JNDI to connect to a particular naming service implementation and it wraps
the exclusive naming administration APIs with the ones characterized by JNDI. The SPI maps
the JNDI calls to ones that a specific naming administration can get it. This enables the
customer to utilize the JNDI APIs just and to switch between various naming administrations
without adversely influencing the customer application. Truth be told, a customer can
explore starting with one kind of naming administration then onto the next utilizing JNDI
without knowing it. For instance, an official from a LDAP server may have a reference to a
question that exists in a RMI Registry naming administration. For whatever length of time
that the customer utilizes the JNDI API, the progress starting with one naming
administration then onto the next will be straightforward. All the exclusive code for the
specific naming administration is typified inside the SPI.

Overview of Naming Service –

 Names: To do the look into, one must know the name of protest. The punctuation of
naming is controlled by the naming service. It is known as the naming tradition.
 Bindings: The relationship between a name and a question is alluded as binding. If an
application need to get to a protest utilizing a name, then the question should bound
to the name previously.
 Context: A setting is an arrangement of name to question ties. The setting gives the
query. It additionally gives alternatives to tie, unbind and rebind objects.
 InitilalContext:It is the beginning stage of all naming and index tasks.
 Exceptions:JNDI characterizes a chain of command of Exceptions . The super class is
NameException

Вам также может понравиться