Example usage for javax.naming ContextNotEmptyException ContextNotEmptyException

List of usage examples for javax.naming ContextNotEmptyException ContextNotEmptyException

Introduction

In this page you can find the example usage for javax.naming ContextNotEmptyException ContextNotEmptyException.

Prototype

public ContextNotEmptyException() 

Source Link

Document

Constructs a new instance of ContextNotEmptyException with all name resolution fields and explanation initialized to null.

Usage

From source file:com.dattack.naming.AbstractContext.java

@Override
public void destroySubcontext(final Name name) throws NamingException {

    if (name.size() > 1) {
        if (subContexts.containsKey(name.getPrefix(1))) {
            final Context subContext = subContexts.get(name.getPrefix(1));
            subContext.destroySubcontext(name.getSuffix(1));
            return;
        }// w w  w  .j a v a 2s  .co  m
        throw new NameNotFoundException();
    }

    if (objectTable.containsKey(name) || !subContexts.containsKey(name)) {
        throw new NameNotFoundException(String.format("Context not found: %s", name));
    }

    final Context subContext = subContexts.get(name);
    final NamingEnumeration<NameClassPair> names = subContext.list("");
    if (names.hasMore()) {
        throw new ContextNotEmptyException();
    }

    subContexts.get(name).close();
    subContexts.remove(name);
}