JNDI helper class
The com.ibm.websphere.naming.JndiHelper class contains static methods to simplify common JNDI programming and administration tasks.
These helper class functions include:
- Recursively creating subcontexts
import com.ibm.websphere.naming.JndiHelper; ... try { Context startingContext = new InitialContext(); startingContext = startingContext.lookup("com/mycompany"); // Create each intermediate subcontext, if necessary, as well as leaf context. // AlreadyBoundException is not thrown. JndiHelper.recursiveCreateSubcontext(startingContext, "apps/ accounting"); } catch (NamingException e){ // Handle other errors. }- Rebinding objects and creating intermediate contexts that do not already exist
import com.ibm.websphere.naming.JndiHelper; ... try { Context startingContext = new InitialContext(); // Creates each intermediate subcontext, if necessary, and rebinds object. JndiHelper.recursiveRebind(startingContext, "com/mycompany/apps/accounting", someObject); } catch (NamingException e){ // Handle other errors. }