private void checkIfContextIsFree(String path) { Handler[] handlers = _contextCollection.getChildHandlersByClass(ContextHandler.class); for (int i = 0; handlers != null && i < handlers.length; i++) { ContextHandler ctx = (ContextHandler) handlers[i]; if (ctx.getContextPath().equals(path)) throw new IllegalArgumentException("another context already bound to path " + path); } }
@Override public void removeContext(String path) throws IllegalArgumentException { Handler handler = null; Handler[] handlers = _contextCollection.getChildHandlersByClass(ContextHandler.class); for (int i = 0; handlers != null && i < handlers.length && handler == null; i++) { ContextHandler ctx = (ContextHandler) handlers[i]; if (ctx.getContextPath().equals(path)) handler = ctx; } if (handler != null) _contextCollection.removeHandler(handler); }