Binding JNDI Objects
by, 07-07-2012 at 05:17 PM (759 Views)
Subordinates of Context are stored as Binding objects set. Binding is basically an association present b/w objects and name. Hence it has already been observed that Binding objects hold its name, object and its class. A newer Binding could be added to Context along with thebind() method. E.g, Addition of binding could be done to already existing Context as following:
Now if at this context list() is being called we will be observing a new child, named as newfile. As it has already been discussed, you shall drop down JNDI, so that a new file could be created by the help of Sun filesystem provider. For creation of a file java.io.File constructor is used that is not JNDI part. Hence file could be binded into naming system by using Context bind()method.Java Code:java.io.File newfile = java.io.File("c:\temp\newfile"); tempContext.bind("newfile", newfile);
When name and object are bound, and already name is in use then a NameAlreadyBoundException is being thrown by the method. If a new object is required to bound to some already existing name then rebind() method shall be used. An unbind() method is also present in Context that is used for removal of a binding.