Search in sources :

Example 1 with SpdyAddOn

use of org.glassfish.grizzly.spdy.SpdyAddOn in project narayana by jbosstm.

the class SpdyEnabledHttpServer method addSpdy.

private static void addSpdy(HttpServer server) {
    NetworkListener listener = server.getListener("grizzly");
    SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
    listener.registerAddOn(spdyAddOn);
}
Also used : SpdyAddOn(org.glassfish.grizzly.spdy.SpdyAddOn) NetworkListener(org.glassfish.grizzly.http.server.NetworkListener)

Example 2 with SpdyAddOn

use of org.glassfish.grizzly.spdy.SpdyAddOn in project narayana by jbosstm.

the class SpdyEnabledHttpServer method createHttpServer.

private static HttpServer createHttpServer(final URI uri, final GrizzlyHttpContainer handler, final boolean secure, final SSLEngineConfigurator sslEngineConfigurator, final int poolSize, final boolean enableSpdy) throws ProcessingException {
    final String host = (uri.getHost() == null) ? NetworkListener.DEFAULT_NETWORK_HOST : uri.getHost();
    final int port = (uri.getPort() == -1) ? 80 : uri.getPort();
    final HttpServer server = new HttpServer();
    final NetworkListener listener = new NetworkListener("grizzly", host, port);
    listener.setSecure(secure);
    if (sslEngineConfigurator != null) {
        listener.setSSLEngineConfig(sslEngineConfigurator);
    }
    if (poolSize > 0) {
        TCPNIOTransport transport = listener.getTransport();
        transport.getKernelThreadPoolConfig().setMaxPoolSize(poolSize);
    }
    if (enableSpdy) {
        SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
        System.out.printf("SPDY: max conc. streams: %d%n", spdyAddOn.getMaxConcurrentStreams());
        listener.registerAddOn(spdyAddOn);
    }
    listener.setSecure(secure);
    server.addListener(listener);
    // Map the path to the processor.
    final ServerConfiguration config = server.getServerConfiguration();
    if (handler != null) {
        config.addHttpHandler(handler, uri.getPath());
    }
    config.setPassTraceRequest(true);
    try {
        // Start the server.
        server.start();
    } catch (IOException ex) {
        throw new ProcessingException("IOException thrown when trying to start grizzly server", ex);
    }
    return server;
}
Also used : TCPNIOTransport(org.glassfish.grizzly.nio.transport.TCPNIOTransport) ServerConfiguration(org.glassfish.grizzly.http.server.ServerConfiguration) HttpServer(org.glassfish.grizzly.http.server.HttpServer) IOException(java.io.IOException) SpdyAddOn(org.glassfish.grizzly.spdy.SpdyAddOn) NetworkListener(org.glassfish.grizzly.http.server.NetworkListener) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

NetworkListener (org.glassfish.grizzly.http.server.NetworkListener)2 SpdyAddOn (org.glassfish.grizzly.spdy.SpdyAddOn)2 IOException (java.io.IOException)1 ProcessingException (javax.ws.rs.ProcessingException)1 HttpServer (org.glassfish.grizzly.http.server.HttpServer)1 ServerConfiguration (org.glassfish.grizzly.http.server.ServerConfiguration)1 TCPNIOTransport (org.glassfish.grizzly.nio.transport.TCPNIOTransport)1