public synchronized void removeHandler(String address) { server.removeContext(PathUtils.getContextPath(address) + PathUtils.getPath(address)); handlerCount--; }
@Override public HttpContext getHttpContext() { if (contextDelegate == null) { contextDelegate = new HttpContextDelegate(delegate.getHttpContext(), PathUtils.getPath(delegate.getRequestURI())); } return contextDelegate; }
public synchronized void addHandler(String address, HttpHandler handler) { if (server == null) //start the server on first call { InetSocketAddress isa = host != null ? new InetSocketAddress(host, port) : new InetSocketAddress(port); try { server = HttpServer.create(isa, BACKLOG); server.setExecutor(Executors.newCachedThreadPool()); server.start(); } catch (IOException e) { throw new RuntimeException(e); } } server.createContext(PathUtils.getContextPath(address) + PathUtils.getPath(address), handler); handlerCount++; }