O'Reilly logo

Java® Programming 24-Hour Trainer by Yakov Fain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 31

Introducing JNDI

Instead of having distributed Java programs instantiate lots of reusable objects over and over again, it’s better if these objects are pre-created and published at a known server, where they can be easily and quickly found. The role of the Java Naming and Directory Interface (JNDI) is to make it easier to find objects in distributed applications. It plays a role similar to that of a company telephone directory assistance service. Various software vendors offer specialized directory assistance software, and JNDI provides a standard API to read from and write to such directories.

In this lesson you’ll be introduced to the JNDI concepts and will see how to use JNDI for publishing (and looking up) administered JMS objects.

Java Naming and Directory Interface

A naming service enables you to add, change, or delete names of objects that exist in some naming hierarchy so other Java classes can look them up to find their location. One more analogy: In a library, you find the name of the physical location of the book in a directory, and then go to the shelf to pick up the book. A naming service provides a unique name for every entry that is registered (bound to) with the service. Every naming service will have one or more contexts — think of directories and subdirectories in a file system, where any directory tree with children is a context. The naming tree originates from a root node, which is also known as an initial context (like a root directory on the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required