src/main/java/org/jboss/util/naming/Util.java
/** Create a subcontext including any intermediate contexts.
    @param ctx the parent JNDI Context under which value will be bound
    @param name the name relative to ctx of the subcontext.
    @return The new or existing JNDI subcontext
    @throws NamingException on any JNDI failure
    */
Create a subcontext including any intermediate contexts.
Create a subcontext including any intermediate contexts .
public static Context createSubcontext(Context ctx, Name name) throws NamingException
   {
      Context subctx = ctx;
      for (int pos = 0; pos < name.size(); pos++)
      {
         String ctxName = name.get(pos);
         try
         {
            subctx = (Context) ctx.lookup(ctxName);
         }
         catch (NameNotFoundException e)
         {
            subctx = ctx.createSubcontext(ctxName);
         }
         ctx = subctx;
      }
      return subctx;
   }
public static Context createSubcontext ( Context ctx , Name name ) throws NamingException { Context subctx = ctx ; for ( int pos = 0 ; pos < name . size ( ) ; pos ++ ) { String ctxName = name . get ( pos ) ; try { subctx = ( Context ) ctx . lookup ( ctxName ) ; } catch ( NameNotFoundException e ) { subctx = ctx . createSubcontext ( ctxName ) ; } ctx = subctx ; } return subctx ; }
Create a subcontext including any intermediate contexts.
Create a subcontext including any intermediate contexts .
// The current subctx will be the ctx for the next name component