org.glowroot.local.ui.HttpServer Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2011-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.glowroot.local.ui;
import java.net.InetSocketAddress;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.regex.Pattern;
import org.glowroot.shaded.google.common.util.concurrent.ThreadFactoryBuilder;
import org.glowroot.shaded.netty.bootstrap.ServerBootstrap;
import org.glowroot.shaded.netty.channel.Channel;
import org.glowroot.shaded.netty.channel.ChannelInitializer;
import org.glowroot.shaded.netty.channel.ChannelPipeline;
import org.glowroot.shaded.netty.channel.EventLoopGroup;
import org.glowroot.shaded.netty.channel.nio.NioEventLoopGroup;
import org.glowroot.shaded.netty.channel.socket.SocketChannel;
import org.glowroot.shaded.netty.channel.socket.nio.NioServerSocketChannel;
import org.glowroot.shaded.netty.handler.codec.http.HttpObjectAggregator;
import org.glowroot.shaded.netty.handler.codec.http.HttpServerCodec;
import org.glowroot.shaded.netty.handler.stream.ChunkedWriteHandler;
import org.glowroot.shaded.netty.util.internal.logging.InternalLoggerFactory;
import org.glowroot.shaded.netty.util.internal.logging.Slf4JLoggerFactory;
import org.glowroot.shaded.slf4j.Logger;
import org.glowroot.shaded.slf4j.LoggerFactory;
class HttpServer {
private static final Logger logger = LoggerFactory.getLogger(HttpServer.class);
private final ServerBootstrap bootstrap;
private final HttpServerHandler handler;
private final EventLoopGroup bossGroup;
private final EventLoopGroup workerGroup;
private final String bindAddress;
private volatile Channel serverChannel;
private volatile int port;
HttpServer(String bindAddress, int port, int numWorkerThreads, LayoutService layoutService,
Map httpServices, HttpSessionManager httpSessionManager,
List