2017년 6월 17일 토요일

JAVA Naming and Directory Interface

JAVA Naming and Directory Interface

JAVA Naming and Directory Interface (JNDI) performs discovery (discover) of data and the object which a directory service provides by the name and is reference (lookup) するのための API. JNDI is an interface for other systems and, like all other JAVA API, becomes independent from concrete implementation. In addition, a service provider interface (SPI) is prescribed in JNDI, and plug in can do the implementation of the directory service in a framework. The implementation of the directory service is good with the server and the flat file and the database and can choose the offer side of the service optionally.

Table of contents

Background

JAVA RMI and JAVA EE use JNDI API to refer to the object on the network. Jini has original lookup service and does not use JNDI.

The following is included in JNDI API.

  • System to tie the name and an object to
  • Reference interface of the hierarchical structure corresponding to a variety of inquiry methods
  • Event interface to notify a client of when an element was updated
  • LDAP expansion corresponding to additional requirements of the LDAP

By SPI, I cope with every following ネーミグ services and directory services.

Sun Microsystems released the specifications of JNDI on March 10, 1997 [1]. The current most recent versions are unified in 1.2 by JAVA SE after J2SE 1.3.

Basic of the lookup

JNDI manages the name with hierarchical structure. Any character string is enough for the name (e.g., :"com.mydomain.ejb.MyBean"). I can make the object which implemented Name interface the name, but one using the character string is common. An object is connected with the name by performing storage (bind) of the reference to the object corresponding to a certain name or an object for a directory service with the name.

JNDI API prescribes the designated method of the place (it is said with a context in this) in search of an object.

At first, by the typical lookup processing, I acquire an initial context. I appoint the parameter that specific implementation and the implementation require when I say with the simplest case and generate an initial context. The initial context performs the lookup of the name for an initial context in something like root directory in a directory tree and the file system. It is an example of the initial context generation as follows.

 Hashtable args = new Hashtable(); I appoint a context factory in // beginning. I am equivalent to movement whether chooses the // anything from implementation of // JBoss and implementation of the sun or the implementation of the totally different vendor. args.put (Context.INITIAL_CONTEXT_FACTORY, "com.jndiprovider.TheirContextFactory"), In // next, I appoint the URL of the data preservation place. args.put (Context.PROVIDER_URL, "http://jndiprovider-database"), Some kind of certification may be necessary // here. In // next, I generate an initial context. Context myCurrentContext = new InitialContext (args), 

Lookup is possible in an object related to the name for it when I can acquire an initial context once.

 Object reference = myCurrentContext.lookup ("com.mydomain.MyBean"), In the case of // EJB, narrow Inge is necessary for the next procedure. MyBean myBean = (MyBean) PortableRemoteObject.narrow (reference, MyBean.class), 

Search

I can give an attribute to a special entry called "a directory". With the directory, I appoint an attribute and can search an object. The directory is a kind of the contexts, but the namespace is limited like directory structure in the file system to some extent.

Outside link

This article is taken from the Japanese Wikipedia JAVA Naming and Directory Interface

This article is distributed by cc-by-sa or GFDL license in accordance with the provisions of Wikipedia.

Wikipedia and Tranpedia does not guarantee the accuracy of this document. See our disclaimer for more information.

In addition, Tranpedia is simply not responsible for any show is only by translating the writings of foreign licenses that are compatible with CC-BY-SA license information.

0 개의 댓글:

댓글 쓰기