The Essential Components |
The flat namespace example uses in-memory storage; it does not support persistence. Whether a context implementation supports persistence typically is determined by the underlying naming/directory service or the requirements of the service provider.Here is the implementation of lookup().
According to the JNDI specification, a lookup() of the empty name should return a copy of the context itself. After extracting the component that belongs to this context's namespace, the implementation proceeds to find the named binding from its internal data structure--a hash table. If it is not found, then it throws a NameNotFoundException. In an actual implementation, you would access the underlying naming/directory service instead of accessing a hash table.public Object lookup(Name name) throws NamingException { if (name.isEmpty()) { // Ask to look up this context itself; create and return // a new instance that has its own independent environment. return (createCtx(myEnv)); } // Extract the components that belong to this namespace String nm = getMyComponents(name); // Find the object in the internal hash table Object answer = bindings.get(nm); if (answer == null) { throw new NameNotFoundException(name + " not found"); } return answer; }This example does not support link references, so this method does not look for LinkRefs or treat them specially.
LookupLink
This example's definition of lookupLink() is the same as its definition of lookup(). This example does not support link references. See the Miscellaneous lesson for a description of how to support link references.
The Essential Components |