private void startServer(WebappContext webappContext, HttpServer httpServer, CompletableFuture start, CompletableFuture end) { webappContext.deploy(httpServer); try { logger.info("Starting application {} on port {}", serverData.getModule().getContext(), serverData.getPort()); logger.info("Browse to http://localhost:{}/{}/application.wadl", serverData.getPort(), serverData.getModule().getContext()); logger.info("Configured resource classes :-"); serverData.extractResources() .forEach(t -> logger.info(t._1() + " : " + "http://localhost:" + serverData.getPort() + "/" + serverData.getModule().getContext() + t._2())); ; httpServer.start(); start.complete(true); end.get(); } catch (IOException e) { throw ExceptionSoftener.throwSoftenedException(e); } catch (ExecutionException e) { throw ExceptionSoftener.throwSoftenedException(e); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw ExceptionSoftener.throwSoftenedException(e); } finally { httpServer.stop(); } }
@Override public void close() throws Exception { server.stop(); }
public static void main(String[] args) throws Exception { HttpServer server = null; try { server = GrizzlyServerFactory.createHttpServer("http://localhost:5555"); System.out.println("Press any key to stop the service..."); System.in.read(); } finally { try { if (server != null) { server.stop(); } } finally { ; } } }
@SuppressWarnings("deprecation") // TODO: use shutdown instead public void stop() { E.checkNotNull(this.httpServer, "http server"); this.httpServer.stop(); }
public class MyResourceTest { public static final String BASE_URI = "http://localhost:8080/api/" private HttpServer server; @Before public void setUp() throws Exception { final ResourceConfig rc = new ResourceConfig(Service.class); server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc); } @After public void tearDown() throws Exception { server.stop(); } @Test public void testService() { Client client = ClientBuilder.newClient(); WebTarget target = client.target(BASE_URI).path("service"); ... } }
@Override public void run() { httpServer.stop(); } });
@Override public void stop() { server.stop(); }
public void stop() { _server.stop(); } }
/** * Stop the server. */ public synchronized void stop(){ if(server != null){ server.stop(); server = null; beanServer = null; LOGGER.info("Websocket Server stopped."); } }
@Override public void stop() { LOGGER.info("Stopping the Grizzly2 Web Container..."); httpServer.stop(); // TODO: webServer.getSelectorThread().stopEndpoint(); }
public static void main(String[] args) throws IOException { final HttpServer server = startServer(); System.out.println(String.format("Jersey app started with WADL available at " + "%sapplication.wadl\nHit enter to stop it...", BASE_URI)); System.in.read(); server.stop(); }
public void stop() { if (httpServer.isStarted()) { LOGGER.info("Stopping low level grizzly2 container"); httpServer.stop(); } }
public static void main(String[] args) throws IOException { final HttpServer httpServer = startServer(); System.in.read(); httpServer.stop(); } }
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 static void main(String[] args) throws IOException { final HttpServer httpServer = startServer(); System.in.read(); httpServer.stop(); } }
public static void main(String[] args) throws IOException { final HttpServer httpServer = startServer(); System.in.read(); httpServer.stop(); } }
public static void main(String[] args) throws IOException { final HttpServer httpServer = startServer(); System.in.read(); httpServer.stop(); } }
/** * Simulates a network down situation, e.g. someone having installed the application on his laptop * and currently not having connection. * * @param runnable The code to run while the network is down */ protected void withNetworkDown(Runnable runnable) throws Exception { try { httpServer.stop(); runnable.run(); } finally { startHttpServer(); } }
@Override @After public void tearDown() throws Exception { super.tearDown(); wiser.stop(); httpServer.stop(); }