.set(Options.BALANCING_CONNECTIONS, 2)
.addAll(this.socketOptions)
.getMap();
Pool<ByteBuffer> buffers = new ByteBufferSlicePool(directBuffers ? BufferAllocator.DIRECT_BYTE_BUFFER_ALLOCATOR : BufferAllocator.BYTE_BUFFER_ALLOCATOR, bufferSize, bufferSize * buffersPerRegion);
for (ListenerConfig listener : listeners) {
if (listener.type == ListenerType.AJP) {
AjpOpenListener openListener = new AjpOpenListener(buffers, serverOptions);
openListener.setRootHandler(rootHandler);
ChannelListener<AcceptingChannel<StreamConnection>> acceptListener = ChannelListeners.openListenerAdapter(openListener);
AcceptingChannel<? extends StreamConnection> server = worker.createStreamConnectionServer(new InetSocketAddress(Inet4Address.getByName(listener.host), listener.port), acceptListener, socketOptions);
server.resumeAccepts();
channels.add(server);
} else {
OptionMap undertowOptions = OptionMap.builder().set(UndertowOptions.BUFFER_PIPELINED_DATA, true).addAll(serverOptions).getMap();
if (listener.type == ListenerType.HTTP) {
HttpOpenListener openListener = new HttpOpenListener(buffers, undertowOptions, bufferSize);
openListener.setRootHandler(rootHandler);
ChannelListener<AcceptingChannel<StreamConnection>> acceptListener = ChannelListeners.openListenerAdapter(openListener);
AcceptingChannel<? extends StreamConnection> server = worker.createStreamConnectionServer(new InetSocketAddress(Inet4Address.getByName(listener.host), listener.port), acceptListener, socketOptions);
server.resumeAccepts();
channels.add(server);
} else if (listener.type == ListenerType.HTTPS) {
ChannelListener<StreamConnection> openListener;
HttpOpenListener httpOpenListener = new HttpOpenListener(buffers, undertowOptions);
httpOpenListener.setRootHandler(rootHandler);
boolean spdy = serverOptions.get(UndertowOptions.ENABLE_SPDY, false);
boolean http2 = serverOptions.get(UndertowOptions.ENABLE_HTTP2, false);
if(spdy || http2) {
AlpnOpenListener alpn = new AlpnOpenListener(buffers, httpOpenListener);
if(spdy) {
SpdyOpenListener spdyListener = new SpdyOpenListener(buffers, new ByteBufferSlicePool(BufferAllocator.BYTE_BUFFER_ALLOCATOR, 1024, 1024), undertowOptions);
spdyListener.setRootHandler(rootHandler);
alpn.addProtocol(SpdyOpenListener.SPDY_3_1, spdyListener, 5);
}
if(http2) {
Http2OpenListener http2Listener = new Http2OpenListener(buffers, undertowOptions);