@Override public String getContextPath() { return PathUtils.getContextPath(delegate.getRequestURI()); }
public synchronized void removeHandler(String address) { server.removeContext(PathUtils.getContextPath(address) + PathUtils.getPath(address)); handlerCount--; }
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++; }