private void shutdownHttpServer(HttpServer httpServer, HostAndPort bindAddress) { if (httpServer != null && httpServer.isStarted()) { LOG.info("Shutting down HTTP listener at <{}>", bindAddress); httpServer.shutdownNow(); } }
@Override public void stop() { if (server.isStarted()) { LOGGER.log(Level.FINE, "Stopping GrizzlyTestContainer..."); this.server.shutdownNow(); } else { LOGGER.log(Level.WARNING, "Ignoring stop request - GrizzlyTestContainer is already stopped."); } } }
@Override public void stop() { if (server.isStarted()) { LOGGER.log(Level.FINE, "Stopping GrizzlyWebTestContainer..."); this.server.shutdownNow(); } else { LOGGER.log(Level.WARNING, "Ignoring stop request - GrizzlyWebTestContainer is already stopped."); } }
@Override public void start() { if (server.isStarted()) { LOGGER.log(Level.WARNING, "Ignoring start request - GrizzlyWebTestContainer is already started."); } else { LOGGER.log(Level.FINE, "Starting GrizzlyWebTestContainer..."); try { server.start(); if (baseUri.getPort() == 0) { baseUri = UriBuilder.fromUri(baseUri) .port(server.getListener("grizzly").getPort()) .build(); LOGGER.log(Level.INFO, "Started GrizzlyWebTestContainer at the base URI " + baseUri); } } catch (final IOException ioe) { throw new TestContainerException(ioe); } } }
@Override public void start() { if (server.isStarted()) { LOGGER.log(Level.WARNING, "Ignoring start request - GrizzlyTestContainer is already started."); } else { LOGGER.log(Level.FINE, "Starting GrizzlyTestContainer..."); try { server.start(); if (baseUri.getPort() == 0) { baseUri = UriBuilder.fromUri(baseUri) .port(server.getListener("grizzly").getPort()) .build(); LOGGER.log(Level.INFO, "Started GrizzlyTestContainer at the base URI " + baseUri); } } catch (final IOException ioe) { throw new TestContainerException(ioe); } } }
public static void main(String[] args) throws Exception { System.out.println("Jersey performance test web service application"); final String jaxRsApp = args.length > 0 ? args[0] : null; //noinspection unchecked final ResourceConfig resourceConfig = ResourceConfig .forApplicationClass((Class<? extends Application>) Class.forName(jaxRsApp)); URI baseUri = args.length > 1 ? URI.create(args[1]) : BASE_URI; int selectors = args.length > 2 ? Integer.parseInt(args[2]) : DEFAULT_SELECTORS; int workers = args.length > 3 ? Integer.parseInt(args[3]) : DEFAULT_WORKERS; final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, false); final TCPNIOTransport transport = server.getListener("grizzly").getTransport(); transport.setSelectorRunnersCount(selectors); transport.setWorkerThreadPoolConfig(ThreadPoolConfig.defaultConfig().setCorePoolSize(workers).setMaxPoolSize(workers)); server.start(); System.out.println(String.format("Application started.\nTry out %s\nHit Ctrl-C to stop it...", baseUri)); while (server.isStarted()) { Thread.sleep(600000); } } }
/** * Sets the logical name of this {@link HttpServer} instance. * The logical name cannot be changed after the server has been started. * * @param name server name */ public void setName(String name) { if (!instance.isStarted()) { this.name = name; } }
/** * Sets the logical name of this {@link HttpServer} instance. * The logical name cannot be changed after the server has been started. * * @param name server name */ public void setName(String name) { if (!instance.isStarted()) { this.name = name; } }
/** * Sets the logical name of this {@link HttpServer} instance. * The logical name cannot be changed after the server has been started. * * @param name server name */ public void setName(String name) { if (!instance.isStarted()) { this.name = name; } }
/** * Sets the logical name of this {@link HttpServer} instance. * The logical name cannot be changed after the server has been started. * * @param name server name */ public void setName(String name) { if (!instance.isStarted()) { this.name = name; } }
/** * Sets the logical name of this {@link HttpServer} instance. * The logical name cannot be changed after the server has been started. * * @param name server name */ public void setName(String name) { if (!instance.isStarted()) { this.name = name; } }
@Override public void stop() { if (server.isStarted()) { LOGGER.log(Level.FINE, "Stopping GrizzlyTestContainer..."); this.server.shutdownNow(); } else { LOGGER.log(Level.WARNING, "Ignoring stop request - GrizzlyTestContainer is already stopped."); } } }
/** * Modifies handlers mapping during runtime. */ synchronized void onAddHttpHandler(HttpHandler httpHandler, final HttpHandlerRegistration[] registrations) { if (isStarted()) { httpHandlerChain.addHandler(httpHandler, registrations); } }
/** * Modifies handlers mapping during runtime. */ synchronized void onRemoveHttpHandler(HttpHandler httpHandler) { if (isStarted()) { httpHandlerChain.removeHttpHandler(httpHandler); } }
/** * Modifies handlers mapping during runtime. */ synchronized void onAddHttpHandler(HttpHandler httpHandler, final HttpHandlerRegistration[] registrations) { if (isStarted()) { httpHandlerChain.addHandler(httpHandler, registrations); } }
public void run() { if (httpServer.isStarted()) { try { httpServer.stop(); } catch (Throwable e) { //never mind. log.warn("Failed stopping http server.", e); } } } }));
public void run() { if (httpServer.isStarted()) { try { httpServer.stop(); } catch (Throwable e) { //never mind. log.warn("Failed stopping http server.", e); } } } }));
public void stop() { if (httpServer.isStarted()) { LOGGER.info("Stopping low level grizzly2 container"); httpServer.stop(); } }
/** * Modifies handlers mapping during runtime. */ synchronized void onRemoveHttpHandler(HttpHandler httpHandler) { if (isStarted()) { httpHandlerChain.removeHttpHandler(httpHandler); } }
/** * Modifies handlers mapping during runtime. */ synchronized void onRemoveHttpHandler(HttpHandler httpHandler) { if (isStarted()) { httpHandlerChain.removeHttpHandler(httpHandler); } }