Java Code Examples for org.glassfish.grizzly.http.server.HttpServer#createSimpleServer()

The following examples show how to use org.glassfish.grizzly.http.server.HttpServer#createSimpleServer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Ahc2Test.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
@Before
public void before(final MockTracer tracer) throws IOException {
  // clear traces
  tracer.reset();

  httpServer = HttpServer.createSimpleServer(".", port);
  httpServer.start();
  setupServer(httpServer);
}
 
Example 2
Source File: GrizzlyHttpServer.java    From piranha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @see cloud.piranha.http.api.HttpServer#start()
 */
@Override
public void start() {
    if (httpServer == null) {
        httpServer = HttpServer.createSimpleServer(null, port);
        httpServer.getListener("grizzly").setSecure(ssl);
    }
    addHttpHandler();
    try {
        httpServer.start();
    } catch (IOException ioe) {
        LOGGER.log(Level.WARNING, "An I/O error occurred while starting the HTTP server", ioe);
    }
}
 
Example 3
Source File: SrvTakeTest.java    From takes with MIT License 5 votes vote down vote up
@Test
public void executeATakesAsAServlet() throws Exception {
    final String name = "webapp";
    final HttpServer server = HttpServer.createSimpleServer("./", 18080);
    final WebappContext context = new WebappContext(name);
    final ServletRegistration servlet = context.addServlet(
        "takes",
        SrvTake.class
    );
    servlet.setInitParameter("take", TkApp.class.getName());
    servlet.addMapping("/test");
    context.deploy(server);
    server.start();
    new JdkRequest("http://localhost:18080/test")
        .fetch()
        .as(RestResponse.class)
        .assertStatus(HttpURLConnection.HTTP_OK)
        .assertBody(
            new StringContains(
                new FormattedText(
                    SrvTakeTest.MSG,
                    name
                ).asString()
            )
        );
    server.shutdownNow();
}
 
Example 4
Source File: GrizzlyApplication.java    From micro-server with Apache License 2.0 4 votes vote down vote up
public void run(CompletableFuture start,  JaxRsServletConfigurer jaxRsConfigurer, CompletableFuture end) {

		WebappContext webappContext = new WebappContext("WebappContext", "");

		new ServletContextListenerConfigurer(serverData, servletContextListenerData, servletRequestListenerData);


		jaxRsConfigurer.addServlet(this.serverData,webappContext);

		new ServletConfigurer(serverData, servletData).addServlets(webappContext);

		new FilterConfigurer(serverData, this.filterData).addFilters(webappContext);

		addListeners(webappContext);

		HttpServer httpServer = HttpServer.createSimpleServer(null, "0.0.0.0", serverData.getPort());
		serverData.getModule().getServerConfigManager().accept(new WebServerProvider(httpServer));
		addAccessLog(httpServer);
		addSSL(httpServer);

		startServer(webappContext, httpServer, start, end);
	}