@Override
  public void rebind(Name name, Object obj) throws NamingException {
    checkIsDestroyed();
    Name parsedName = getParsedName(name);
    if (parsedName.size() == 0 || parsedName.get(0).length() == 0) {
      throw new InvalidNameException(
          "Name can not be empty!");
    }
    String nameToBind = parsedName.get(0);
    if (parsedName.size() == 1) {
      ctxMaps.put(nameToBind, obj);
    } else {
      Object boundObject = ctxMaps.get(nameToBind);
      if (boundObject instanceof Context) {
        /*
         * Let the subcontext bind the object.
         */
        ((Context) boundObject).bind(parsedName.getSuffix(1), obj);
      } else {
        if (boundObject == null) {
          // Create new subcontext and let it do the binding
          Context sub = createSubcontext(nameToBind);
          sub.bind(parsedName.getSuffix(1), obj);
        } else {
          throw new NotContextException(String.format("Expected Context but found %s",
              boundObject));
        }
      }
    }
  }
Rebinds object obj to name name . If there is existing binding it will be overwritten.

@param name name of the object to rebind.
@param obj object to add. Can be null.
@throws NoPermissionException if this context has been destroyed
@throws InvalidNameException if name is empty or is CompositeName that spans more than one
        naming system
@throws NotContextException if name has more than one atomic name and intermediate context is
        not found
@throws NamingException if any other naming error occurs
geode-core/src/main/java/org/apache/geode/internal/jndi/ContextImpl.java