public void destroySubcontext(Name name) throws NamingException { if (name.size() == 0) throw new NamingException(L.l("can't destroy root subcontext")); AbstractModel model = _model; int i = 0; for (; i + 1 < name.size(); i++) { String first = name.get(i); Object value = model.lookup(first); if (value instanceof AbstractModel) { model = (AbstractModel) value; continue; } value = dereference(value, null, model); if (value instanceof Context) { ((Context) value).destroySubcontext(name.getSuffix(i + 1)); return; } else if (value != null) throw new NotContextException( L.l("{0}: expected intermediate context at `{1}'", getFullPath(name), value)); else throw new NameNotFoundException(getFullPath(name)); } String first = name.get(i); model.unbind(first); }
/** Destroys the named subcontext. */ public void destroySubcontext(String name) throws NamingException { String tail = name; AbstractModel model = _model; while (true) { String first = parseFirst(tail); String rest = parseRest(tail); if (first == null) throw new NamingException(L.l("can't destroy root subcontext")); if (rest == null) { model.unbind(first); return; } Object value = model.lookup(first); if (value instanceof AbstractModel) { model = (AbstractModel) value; tail = rest; continue; } value = dereference(value, null, model); if (value instanceof Context) { ((Context) value).destroySubcontext(rest); return; } else if (value != null) throw new NotContextException( L.l("{0}: expected intermediate context at `{1}'", getFullPath(name), value)); else throw new NameNotFoundException(getFullPath(name)); } }