Ascendant
Ascendant

Reputation: 827

Confused over the JNDI

I've been reading one articles on the JNDI but I'm pretty much confused.

So, to put it simply:

  1. the JNDI is like an object container that each entry is a string name - object pair?
  2. are those pairs stored in the JVM? For example, on the same local machine, App #1 registers a datasource object with the name "testDS", after some time, App #2 can get that datasource object with the key "testDS"? But from where? In JVM?

Upvotes: 1

Views: 560

Answers (3)

matt freake
matt freake

Reputation: 5090

You need to take a step back. Outside and separate from Java and JNDI, there are "Directory and Naming Services". These things are like LDAP, DNS or your computers filesystem (think of paths and file names) which allow you to access structured things by their name and by directories.

JNDI is a Java API which allows you to use one of these, and the interface should be the largely the same, regardless of which one you use.

The objects you access via JNDI are stored using the Directory and Naming Service, not the JVM directly.

So if you have two JVMs using JNDI to access the same Directory and Naming Service and configured the same, they should access to the same objects. If they are accessing different services, they will not be able to access the same objects regardless of whether it is the same JVM.

Upvotes: 3

MaVRoSCy
MaVRoSCy

Reputation: 17839

You have missed something about JNDI. JNDI is an application programming interface (API). It is a group of classes that provide naming and directory functionality to applications written in the Java programming language.

So, since this classes run within the JVM, then we can say that by using the JVM, applications make use of the JNDI to perform their tasks.

Upvotes: 0

Ahmet Karakaya
Ahmet Karakaya

Reputation: 10139

Think about that when you are trying to access a file under d:/users/name/text.txt you just type its name and you access its contents. JNDI works at same concept, you go there with a name JNDI handles what you want.

Upvotes: 0

Related Questions