JNDI Context and InitialContext
by, 07-07-2012 at 04:00 PM (414 Views)
In JNDI, Context interface has a very important and central role. A set of bindings are presented by a context within a naming service in which similar naming convention is being shared. Methods are provided by the context object to bind the names with objects and unbind them from objects and also to list down the bindings.
Subcontext functionality is also provided by few naming services. This is same as a directory which is present in some filesystem. Basically, subcontext is that context which is present in context. Organisation of information is permitted by the hierarchial structure. Thecontext class gives methods for destruction or creation of the subcontext, for those naming services which have been providing support to the subcontext.
Naming operations that are considered relative to a certain context will be performed by the JNDI. To find out the starting point, anInitialContext class is defined by the JNDI specification. With properties this class would be instantiated. In this way in use naming services are defined so that to give out security and ID/password while connecting.
Those who have familiarity with “RMI Naming class”, majority methods that have been defined by the context interface given below would be seen quite similar. Now let us see context methods in detail:
- void bind(String stringName, Object object): Name is bind to object. There shall be no binding of name to some other object. Intermediate context shall be existing already.
- void rebind(String stringName, Object object): Name is bind to an object. All of the intermediate contexts shall be present already.
- Object lookup(String stringName): Specified object is returned.
- void unbind(String stringName): Specified object is unbound.