Friday, March 13, 2009

What's the difference between JNDI lookup(), list(), listBindings(), and search() (JNDI)

Question :What's the difference between JNDI lookup(), list(), listBindings(), and
search()? (JNDI)

Answer :lookup() attempts to find the specified object in the given context. I.e., it
looks for a single, specific object and either finds it in the current context
or it fails.
list() attempts to return an enumeration of all of the NameClassPair's of all
of the objects in the current context. I.e., it's a listing of all of the objects
in the current context but only returns the object's name and the name of
the class to which the object belongs.
listBindings() attempts to return an enumeration of the Binding's of all of
the objects in the current context. I.e., it's a listing of all of the objects in
the current context with the object's name, its class name, and a reference
to the object itself.
search() attempts to return an enumeration of all of the objects matching
a given set of search criteria. It can search across multiple contexts (or
not). It can return whatever attributes of the objects that you desire. Etc.
It's by far the most complex and powerful of these options but is also the
most expensive.

No comments: