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);
}
}
}
Aggregations