src/main/java/org/jboss/util/naming/NonSerializableFactory.java
public static synchronized void rebind(Name name, Object target, boolean createSubcontexts) throws NamingException
   {
      String key = name.toString();
      InitialContext ctx = new InitialContext();
      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(Name name, Object target, boolean createSubcontexts) throws NamingException
   {
      String key = name.toString();
      InitialContext ctx = new InitialContext();
      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. This version binds the
target object into the default IntitialContext using name path.

@param name the name to use as JNDI path name. The key into the
NonSerializableFactory map is obtained from the toString() value of name.
The name parameter cannot be a 0 length name.
@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.
@author Matt Carter