@Override public Executor getExecutor() { return delegate.getExecutor(); }
@Override public Executor getExecutor() { return httpServer.getExecutor(); }
@Override public Executor getExecutor() { return delegate.getExecutor(); }
/** * Stop server */ public void stop() { // stop immediately ((ExecutorService) httpServer.getExecutor()).shutdown(); httpServer.stop(0); LOGGER.log(Level.INFO, "Server stopped"); }
/** * Stops synchronously, handy for unit test scenarios. * * @param delaySeconds seconds to wait for clean termination * @return this instance for call chaining */ public ODataJerseyServer stop(int delaySeconds) { server.stop(delaySeconds); Executor serverExecutor = server.getExecutor(); if (serverExecutor instanceof ThreadPoolExecutor) { ((ThreadPoolExecutor) serverExecutor).shutdown(); if (delaySeconds > 0) { try { ((ThreadPoolExecutor) serverExecutor).awaitTermination(delaySeconds, TimeUnit.SECONDS); } catch (InterruptedException ex) { // oh well.. } } } return this; }
private void shutdown() { server.stop(0); Executor executor = server.getExecutor(); if (executor instanceof ExecutorService) { ExecutorService service = (ExecutorService) executor; service.shutdown(); try { if (!service.awaitTermination(5, TimeUnit.SECONDS)) { service.shutdownNow(); } } catch (InterruptedException e) { logger.error("WebServer ExecutorService shutdown thread interrupted on disable: " + e.getMessage()); Thread.currentThread().interrupt(); } } }
/*package*/ void removeContext(HttpContext context) { InetSocketAddress inetAddress = context.getServer().getAddress(); synchronized(servers) { ServerState state = servers.get(inetAddress); int instances = state.noOfContexts(); if (instances < 2) { ((ExecutorService)state.getServer().getExecutor()).shutdown(); state.getServer().stop(0); servers.remove(inetAddress); } else { state.getServer().removeContext(context); state.oneLessContext(context.getPath()); } } }
/*package*/ void removeContext(HttpContext context) { InetSocketAddress inetAddress = context.getServer().getAddress(); synchronized(servers) { ServerState state = servers.get(inetAddress); int instances = state.noOfContexts(); if (instances < 2) { ((ExecutorService)state.getServer().getExecutor()).shutdown(); state.getServer().stop(0); servers.remove(inetAddress); } else { state.getServer().removeContext(context); state.oneLessContext(context.getPath()); } } }
/*package*/ void removeContext(HttpContext context) { InetSocketAddress inetAddress = context.getServer().getAddress(); synchronized(servers) { ServerState state = servers.get(inetAddress); int instances = state.noOfContexts(); if (instances < 2) { ((ExecutorService)state.getServer().getExecutor()).shutdown(); state.getServer().stop(0); servers.remove(inetAddress); } else { state.getServer().removeContext(context); state.oneLessContext(context.getPath()); } } }