Java Learning-What is Jndi

Source: Internet
Author: User

I remember in the computer room charge system when it came into contact with the API, because it is very powerful function, but it is not very understanding of it, so at that time is also love and afraid. Now, all the way to understand, in fact, it is a set of interfaces. As long as we get to know it, we'll find that it's not as scary as it really is. Today, let's look at the interface--jndi in Java.

Concept

The Java Naming and directory interface (Java naming and directory Interface,jndi) is a set of APIs for accessing name and directory services from Java applications. The naming service is about to have names associated with objects so that they can be accessed by the appropriate name. The directory service is a naming service whose objects have properties and names.

The naming or directory service allows you to centrally manage the storage of shared information, which is important in network applications because it makes such applications more consistent and manageable. For example, you can store the printer configuration in a directory service so that all printer-related applications can use it.

Role

The Java EE specification requires that all Java EE containers provide the implementation of the JNDI specification. The role of JNDI in the Java EE is a common mechanism for "switch"--J2EE components to find other components, resources, or services at run time grounding.
In most cases, the container that provides the Jndi provider can act as a limited data store so that the administrator can set the execution properties of the application and have other applications reference those properties (Java Management Extensions, JMX) can also be used for this purpose. The primary role of JNDI in the Java EE application is to provide an indirection layer so that the components can discover the resources they need without knowing the indirection.

In Java EE, Jndi is the glue that puts the Java EE application together, and Jndi provides indirect addressing that allows scalable, powerful, and flexible applications to be delivered across the enterprise. This is the commitment of the Java EE, and after some planning and pre-consideration, this commitment is fully achievable.

Ps:jndi avoids the tight coupling between the program and the database, making the application easier to configure and easy to deploy.

Architecture

The JNDI schema provides a standard, non-named system-agnostic API that is built on top of a named system-specific driver. This layer helps isolate the application from the actual data source, so it doesn't matter whether the application accesses LDAP, RMI, DNS, or other directory services. In other words, Jndi is not related to any particular directory service implementation, and you can use any directory, as long as you have the appropriate service provider interface (or driver), as shown.

Note that it is important to have a point about jndi that it provides both an application programming interface (application Programming Interface, API) and a service provider Interface (Services Provider Interface, SPI). The practical implication of this is that for your application to interact with the naming or directory service, there must be a Jndi service provider for that service, which is the stage where the Jndi SPI works. A service provider is basically a set of classes that implement various JNDI interfaces for a particular naming and directory service-much like the JDBC driver implements various JDBC interfaces for a particular data system. As an application developer, you do not need to worry about the Jndi SPI. Just make sure that you provide a service provider for each naming or directory service that you want to use.

Summarize

1, the purpose of JNDI is to understand Lotus root, is to develop easier to maintain, easy to expand, easy to deploy applications.
2, JNDI is a Sun proposed specification (similar to JDBC), the specific implementation is the various Java EE container provider, Sun just requires that the Java EE container must have JNDI such functions.
3. The role of JNDI in the Java EE system is "switch", which is a common mechanism for the Java EE component to find other components, resources or services in the run time grounding.
4. JNDI is found by the name of the resource, and the name of the resource is unique throughout the Java EE application (the Java EE container).

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java Learning-What is Jndi

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.