Java Code Examples for com.sun.net.httpserver.HttpContext#setHandler()

The following examples show how to use com.sun.net.httpserver.HttpContext#setHandler() . 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: SimpleMetricsPublishingService.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
@Override
public void start(MetricsSession session) {
  registry = new PrometheusMeterRegistry(DEFAULT);
  session.addSubregistry(registry);

  InetSocketAddress address = new InetSocketAddress(HOSTNAME, port);
  server = null;
  try {
    server = HttpServer.create(address, 0);

    HttpContext context = server.createContext("/");
    context.setHandler(this::requestHandler);
    server.start();

    int boundPort = server.getAddress().getPort();
    LOG.info("Started {} http://{}:{}/", getClass().getSimpleName(), HOSTNAME, boundPort);
  } catch (IOException thrown) {
    LOG.error("Exception while starting " + getClass().getSimpleName(), thrown);
  }
}
 
Example 2
Source File: SimpleMetricsPublishingService.java    From geode-examples with Apache License 2.0 6 votes vote down vote up
@Override
public void start(MetricsSession session) {
  registry = new PrometheusMeterRegistry(DEFAULT);
  session.addSubregistry(registry);

  InetSocketAddress address = new InetSocketAddress(HOSTNAME, port);
  server = null;
  try {
    server = HttpServer.create(address, 0);

    HttpContext context = server.createContext("/");
    context.setHandler(this::requestHandler);
    server.start();

    int boundPort = server.getAddress().getPort();
    LOG.info("Started {} http://{}:{}/", getClass().getSimpleName(), HOSTNAME, boundPort);
  } catch (IOException thrown) {
    LOG.error("Exception while starting " + getClass().getSimpleName(), thrown);
  }
}
 
Example 3
Source File: JWKSServer.java    From cellery-security with Apache License 2.0 5 votes vote down vote up
public void startServer() throws IOException, KeyResolverException {

        HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
        HttpContext context = server.createContext("/");
        context.setHandler(JWKSServer::handleRequest);
        server.start();
        log.info("JWKS endpoint started in port : {}", port);
    }
 
Example 4
Source File: NotifyTest.java    From dew with Apache License 2.0 5 votes vote down vote up
private static void startHttpServer(int port, String path) {
    HttpServer server = null;
    try {
        server = HttpServer.create(new InetSocketAddress(port), 0);
    } catch (IOException e) {
        e.printStackTrace();
    }
    HttpContext context = server.createContext("/" + path);
    context.setHandler(NotifyTest::handleRequest);
    server.start();
}
 
Example 5
Source File: Contexts.java    From nano with Apache License 2.0 5 votes vote down vote up
public static HttpContext create(HttpServer server, Path path) {
    HttpHandler handler = instantiate(path);
    final String extracted = extractContext(path);
    HttpContext context = server.createContext(extracted);
    context.setHandler(handler);
    System.out.println("Context registered: " + context.getPath());
    return context;
}
 
Example 6
Source File: HttpEndpoint.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private void setHandler(HttpContext context) {
    context.setHandler(new WSHttpHandler(adapter, executor));
}
 
Example 7
Source File: HttpEndpoint.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private void setHandler(HttpContext context) {
    context.setHandler(new WSHttpHandler(adapter, executor));
}
 
Example 8
Source File: HttpEndpoint.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private void setHandler(HttpContext context) {
    context.setHandler(new WSHttpHandler(adapter, executor));
}
 
Example 9
Source File: HttpEndpoint.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private void setHandler(HttpContext context) {
    context.setHandler(new WSHttpHandler(adapter, executor));
}
 
Example 10
Source File: HttpEndpoint.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private void setHandler(HttpContext context) {
    context.setHandler(new WSHttpHandler(adapter, executor));
}
 
Example 11
Source File: HttpEndpoint.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private void setHandler(HttpContext context) {
    context.setHandler(new WSHttpHandler(adapter, executor));
}
 
Example 12
Source File: HttpEndpoint.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void setHandler(HttpContext context) {
    context.setHandler(new WSHttpHandler(adapter, executor));
}
 
Example 13
Source File: HttpEndpoint.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private void setHandler(HttpContext context) {
    context.setHandler(new WSHttpHandler(adapter, executor));
}