| 298 | |
| 299 | |
| 300 | @Override |
| 301 | public void destroySubcontext(Name name) throws NamingException { |
| 302 | |
| 303 | if (!checkWritable()) { |
| 304 | return; |
| 305 | } |
| 306 | |
| 307 | while ((!name.isEmpty()) && (name.get(0).isEmpty())) { |
| 308 | name = name.getSuffix(1); |
| 309 | } |
| 310 | if (name.isEmpty()) { |
| 311 | throw new NamingException(sm.getString("namingContext.invalidName")); |
| 312 | } |
| 313 | |
| 314 | NamingEntry entry = bindings.get(name.get(0)); |
| 315 | |
| 316 | if (entry == null) { |
| 317 | throw new NameNotFoundException(sm.getString("namingContext.nameNotBound", name, name.get(0))); |
| 318 | } |
| 319 | |
| 320 | if (name.size() > 1) { |
| 321 | if (entry.type == NamingEntry.CONTEXT) { |
| 322 | ((Context) entry.value).destroySubcontext(name.getSuffix(1)); |
| 323 | } else { |
| 324 | throw new NamingException(sm.getString("namingContext.contextExpected", name.get(0))); |
| 325 | } |
| 326 | } else { |
| 327 | if (entry.type == NamingEntry.CONTEXT) { |
| 328 | ((Context) entry.value).close(); |
| 329 | bindings.remove(name.get(0)); |
| 330 | } else { |
| 331 | throw new NotContextException(sm.getString("namingContext.contextExpected", name.get(0))); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | } |
| 336 | |
| 337 | |
| 338 | @Override |