FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/Java_Naming_and_Directory_Interface

Java Naming and Directory Interface

Contents
Searching
See also
References

The Java Naming and Directory Interface (JNDI) is a Java API for a directory service that allows Java software clients to discover and look up data and resources (in the form of Java objects) via a name. Like all Java APIs that interface with host systems, JNDI is independent of the underlying implementation. Additionally, it specifies a service provider interface (SPI) that allows directory service implementations to be plugged into the framework. The information looked up via JNDI may be supplied by a server, a flat file, or a database; the choice is up to the implementation used.

Typical uses of JNDI include:

importjava.util.Hashtable; importjava.util.Map; importjavax.naming.Context; importjavax.naming.InitialContext; Map<String,String>contextArgs=newHashtable<>(); // First you must specify the context factory. // This is how you choose between jboss implementation // vs. an implementation from Sun or other vendors. contextArgs.put(Context.INITIAL_CONTEXT_FACTORY,"com.jndiprovider.TheirContextFactory"); // The next argument is the URL specifying where the data store is: contextArgs.put(Context.PROVIDER_URL,"jndiprovider-database"); // (You may also have to provide security credentials) // Next you create the initial context ContextmyCurrentContext=newInitialContext(contextArgs);

A context is then used to look up previously bound names in that context. For example:

MyBeanmyBean=(MyBean)myCurrentContext.lookup("com.mydomain.MyBean");

Searching

edit

Attributes may be attached to special entries called directories. Directories enable searching for objects by their associated attributes. Directories are a type of context; they restrict the name space much like a directory structure on a file system does.

See also

edit

References

edit
"JNDI/RMI Registry Service Provider". docs.oracle.com. Retrieved 2016-12-17.
  • ↑ Category

  • View original on Wikipedia | Back | FazBrowse Home