Search in sources :

Example 11 with HttpOpenListener

use of io.undertow.server.protocol.http.HttpOpenListener in project actframework by actframework.

the class UndertowNetwork method setUpClient.

@Override
protected void setUpClient(NetworkHandler client, int port, boolean secure) throws IOException {
    HttpHandler handler = new ActHttpHandler(client);
    ByteBufferPool buffers = new DefaultByteBufferPool(true, 16 * 1024, -1, 4);
    HttpOpenListener openListener = new HttpOpenListener(buffers, serverOptions);
    openListener.setRootHandler(handler);
    ChannelListener<AcceptingChannel<StreamConnection>> acceptListener = ChannelListeners.openListenerAdapter(openListener);
    if (!secure) {
        AcceptingChannel<? extends StreamConnection> server = worker.createStreamConnectionServer(new InetSocketAddress(port), acceptListener, socketOptions);
        server.resumeAccepts();
        channels.add(server);
    } else {
        XnioSsl xnioSsl;
        try {
            SSLContext sslContext = createSSLContext(loadKeyStore("server.keystore"), loadKeyStore("server.truststore"));
            xnioSsl = new UndertowXnioSsl(xnio, OptionMap.create(Options.USE_DIRECT_BUFFERS, true), sslContext);
            AcceptingChannel<SslConnection> sslServer = xnioSsl.createSslConnectionServer(worker, new InetSocketAddress(port), (ChannelListener) acceptListener, socketOptions);
            sslServer.resumeAccepts();
            channels.add(sslServer);
        } catch (Exception e) {
            throw E.unexpected(e);
        }
    }
}
Also used : DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) ByteBufferPool(io.undertow.connector.ByteBufferPool) HttpHandler(io.undertow.server.HttpHandler) DefaultByteBufferPool(io.undertow.server.DefaultByteBufferPool) XnioSsl(org.xnio.ssl.XnioSsl) UndertowXnioSsl(io.undertow.protocols.ssl.UndertowXnioSsl) InetSocketAddress(java.net.InetSocketAddress) IOException(java.io.IOException) SslConnection(org.xnio.ssl.SslConnection) HttpOpenListener(io.undertow.server.protocol.http.HttpOpenListener) UndertowXnioSsl(io.undertow.protocols.ssl.UndertowXnioSsl) AcceptingChannel(org.xnio.channels.AcceptingChannel)

Aggregations

HttpOpenListener (io.undertow.server.protocol.http.HttpOpenListener)11 InetSocketAddress (java.net.InetSocketAddress)9 IOException (java.io.IOException)8 DefaultByteBufferPool (io.undertow.server.DefaultByteBufferPool)7 OptionMap (org.xnio.OptionMap)7 ChannelListener (org.xnio.ChannelListener)6 UndertowXnioSsl (io.undertow.protocols.ssl.UndertowXnioSsl)4 AlpnOpenListener (io.undertow.server.protocol.http.AlpnOpenListener)4 Http2OpenListener (io.undertow.server.protocol.http2.Http2OpenListener)4 Xnio (org.xnio.Xnio)4 ByteBufferPool (io.undertow.connector.ByteBufferPool)3 AjpOpenListener (io.undertow.server.protocol.ajp.AjpOpenListener)3 Http2UpgradeHandler (io.undertow.server.protocol.http2.Http2UpgradeHandler)3 StreamConnection (org.xnio.StreamConnection)3 XnioSsl (org.xnio.ssl.XnioSsl)3 HttpHandler (io.undertow.server.HttpHandler)2 LoadBalancingProxyClient (io.undertow.server.handlers.proxy.LoadBalancingProxyClient)2 ProxyHandler (io.undertow.server.handlers.proxy.ProxyHandler)2 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)2 FilterInfo (io.undertow.servlet.api.FilterInfo)2