Jndi of the Java series

Source: Internet
Author: User

Introduction

Jndi (Java naming and directory Interface,java naming and directory interface) is a standard Java naming system interface provided by Sun, and Jndi provides a unified client API, Through the implementation of a different access provider Interface Jndi Service Provisioning Interface (SPI), the manager maps the Jndi API to a specific naming service and directory system, allowing Java applications to interact with these naming services and directory services. The directory service is a natural extension of the naming service. The key difference between the two is that an object in a directory service can have a name and attributes (for example, a user has an email address), whereas an object in a naming service has no attributes.

naming Service

A naming service is a service that provides the ability to create a standard name for a given set of data. It allows you to associate a name with a Java object or resource without having to indicate the physical ID of the object or resource. This is similar to the dictionary structure (or the map structure of Java), where keys are mapped to values. For example, domain naming service,dns on the internet is a naming service that maps a domain name to an IP address, typically entering a name in the browser when the site is opened, finding the appropriate IP address through DNS, and then opening it.

All Internet traffic uses TCP, UDP, or IP protocols. The IP address is made up of 4 bytes of 32-bit binary digits, and the numbers and names are easier to remember than numbers for a person, but for a computer it is more adept at handling numbers.

In fact, all naming services provide the basic functionality of DNS, a system that registers with the naming service, and the naming service provides a mapping of values to another value. Then another system accesses the naming service to get the mapping information. This interaction is important for distributed enterprise-class applications, where basic name operations are included in the context interface.

Directory Service

The directory service is a special type of database that, contrary to relational database management systems such as SQL Server, Access, and Oracle, constructs a directory service to handle behavior-based transactions and uses a relational information model. The directory service further extends the concept of naming services to provide a hierarchical repository of information, in addition to a one-to-two relationship, as well as a hierarchical structure of messages. For directory services, this hierarchy is typically used to optimize search operations, and can also be distributed on a case-by-situation basis or across network replication.

A directory service typically has a name service (but a name service does not have to have a directory service). If the phone book is a typical directory service, usually first find the relevant name in the phone book, and then find the person's telephone number.

Each directory service can store information about user names, user passwords, user groups (such as information about access control), Ethernet addresses, IP addresses, and so on. The information and operations it supports vary depending on the directory service being used. Unfortunately, the protocols that access different directory services are different, so readers need to know a variety of APIs.

This is the origin of Jndi, like JDBC, where jndi acts as a generic API for different names and directory services, or as a front-end, and then uses different backend adapters to connect to the actual service.

Jndi is a complete component of the EE technology. It supports methods to access different, new, and existing services in a single way. This support allows any service provider to perform the insertion of a JNDI framework through a standard service provider Interface (SPI) contract.

function

The function of Jndi is simply to find some kind of resource in a simple way. Jndi is an application-designed API that provides developers with a common, unified interface for locating and accessing various naming and directory services, similar to JDBC, which is built at the abstraction level. For example, in Tomcat configured a JNDI data source, then in the program need to use Java Standard API can find this data source, the data source configuration changes, and so on, the program does not need to change, it needs to change the configuration of Jndi to the line. The flexibility of the program is increased and the system is decoupled.

Summary

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.

Jndi of the Java series

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.