src/main/java/org/jboss/util/naming/NonSerializableFactory.java
public static synchronized void rebind(Context ctx, String key, 
      Object target, boolean createSubcontexts) throws NamingException
   {
	   Name name = ctx.getNameParser("").parse(key);
       if( createSubcontexts == true && name.size() > 1 )
       {
          int size = name.size() - 1;
          Util.createSubcontext(ctx, name.getPrefix(size));
       }
       rebind(ctx, key, target);
   }
public static synchronized void rebind(Context ctx, String key, 
      Object target, boolean createSubcontexts) throws NamingException
   {
	   Name name = ctx.getNameParser("").parse(key);
       if( createSubcontexts == true && name.size() > 1 )
       {
          int size = name.size() - 1;
          Util.createSubcontext(ctx, name.getPrefix(size));
       }
       rebind(ctx, key, target);
   }
A convenience method that simplifies the process of rebinding a
non-serializable object into a JNDI context.

@param ctx the JNDI context to rebind to.
@param key the key to use in both the NonSerializableFactory map and JNDI. It
must be a valid name for use in ctx.bind().
@param target the non-Serializable object to bind.
@param createSubcontexts a flag indicating if subcontexts of name should
be created if they do not already exist.
@throws NamingException thrown on failure to rebind key into ctx.