Introducing the JNDI Context
by, 07-07-2012 at 05:08 PM (401 Views)
Names are associated with objects by a naming servie. Association b/w an object and a name is known as binding. Such binding set is known as a context. Name present in one context could possibly be made bound with other context which utilizes similar naming conventions. Bound context is known as subcontext. For instance directory present in a filesystem is those contexts which hold binding b/w objects and filenames which are used for manipulation of files by the system. If a binding is present in a directory for some other directory then subdirectory is considered to be a subcontext.
JNDI represents a context in a naming system using the javax.naming.Context interface. This is the key interface for interacting with naming services. A Context knows about its set of bindings in the naming system, but little else. While you might be tempted to think of aContext as an exotic java.io.File object, you should resist making that analogy, as it will just confuse you. Unlike a File object, which can tell you its absolute and relative names as well as return a reference to its parent, a Context object can tell you only about its bindings. A Context cannot go up a level, tell you its absolute pathname, or even tell you its own name. When you think of a Context, think of an object that encapsulates its children as data and has methods that perform operations on that data, not on the Context itself.
In a naming system, context is represented by JNDI by using interface javax.naming.Context. Such key interface is used fot interaction with the naming services. In naming systems, set of bindings are known by context but little lesser. One might think about context to be exotic java.io.File object