private void cleanUpContexts() { for (Map.Entry<String, JettyHttpContext> stringJettyHttpContextEntry : _contexts.entrySet()) { JettyHttpContext context = stringJettyHttpContextEntry.getValue(); _server.removeBean(context.getJettyContextHandler()); } _contexts.clear(); }
@Override public HttpContext createContext(String path, HttpHandler handler) { checkIfContextIsFree(path); JettyHttpContext context = new JettyHttpContext(this, path, handler); J2SE6ContextHandler jettyContextHandler = context.getJettyContextHandler(); _contextCollection.addHandler(jettyContextHandler); return context; }
@Override public HttpContext createContext(String path, HttpHandler httpHandler) { checkIfContextIsFree(path); JettyHttpContext context = new JettyHttpContext(this, path, httpHandler); HttpSpiContextHandler jettyContextHandler = context.getJettyContextHandler(); ContextHandlerCollection chc = findContextHandlerCollection(_server.getHandlers()); if (chc == null) throw new RuntimeException("could not find ContextHandlerCollection, you must configure one"); chc.addHandler(jettyContextHandler); _contexts.put(path, context); return context; }
@Override public void removeContext(String path) throws IllegalArgumentException { JettyHttpContext context = _contexts.remove(path); if (context == null) return; _server.removeBean(context.getJettyContextHandler()); }