Lesson 29Introducing JNDI

Instead of having distributed Java programs that 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. Lesson 24 introduces a registry concept, in which a Java object can be published under some name so the client can look it up.  

Java Naming and Directory Interface (JNDI) is also about registering and finding objects in distributed applications. JNDI is an application programming interface (API) that can be used for binding and accessing objects located in Java EE or specialized naming servers that play roles  similar to that of a company telephone directory assistance service. But instead of looking for people’s information, you look for objects. Various software vendors offer specialized directory assistance software, and JNDI provides a standard API to read from and write to such directories. 

Every Java EE application server comes with an administrator’s console that allows you to manage objects in a JNDI tree. This lesson introduces you to the JNDI concepts, and you see how to use JNDI for publishing (and looking up) administered objects (that is, configured by the server administrator).  Some examples of administered objects are database connection pools and message queues (explained in Lesson 30). 

Naming and Directory Services

A naming service enables you to add, change, or delete names of objects that exist in some ...

Get Java Programming 24-Hour Trainer, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.