// Path: core/src/main/java/com/ning/jetty/core/CoreConfig.java
// public interface CoreConfig
// {
//     @Config("com.ning.core.server.ip")
//     @Default("127.0.0.1")
//     String getServerHost();
// 
//     @Config("com.ning.core.server.port")
//     @Default("8080")
//     int getServerPort();
// 
//     @Config("com.ning.core.server.server.ssl.enabled")
//     @Default("false")
//     boolean isSSLEnabled();
// 
//     @Config("com.ning.core.server.server.ssl.port")
//     @Default("8443")
//     int getServerSslPort();
// 
//     @Config("com.ning.core.server.jetty.stats")
//     @Default("true")
//     boolean isJettyStatsOn();
// 
//     @Config("com.ning.core.server.jetty.ssl.keystore")
//     @DefaultNull
//     String getSSLkeystoreLocation();
// 
//     @Config("com.ning.core.server.jetty.ssl.keystore.password")
//     @DefaultNull
//     String getSSLkeystorePassword();
// 
//     @Config("com.ning.core.server.jetty.maxThreads")
//     @Default("2000")
//     int getMaxThreads();
// 
//     @Config("com.ning.core.server.jetty.minThreads")
//     @Default("2")
//     int getMinThreads();
// 
//     @Config("com.ning.core.server.jetty.logPath")
//     @Default(".logs")
//     String getLogPath();
// 
//     @Config("com.ning.core.server.jetty.resourceBase")
//     @DefaultNull
//     String getResourceBase();
// }
// 
// Path: core/src/main/java/com/ning/jetty/core/listeners/SetupJULBridge.java
// public class SetupJULBridge implements ServletContextListener
// {
//     @Override
//     public void contextInitialized(final ServletContextEvent event)
//     {
//         // We first remove the default handler(s)
//         final Logger rootLogger = LogManager.getLogManager().getLogger("");
//         final Handler[] handlers = rootLogger.getHandlers();
// 
//         if (!ArrayUtils.isEmpty(handlers)) {
//             for (final Handler handler : handlers) {
//                 rootLogger.removeHandler(handler);
//             }
//         }
//         // And then we let jul-to-sfl4j do its magic so that jersey messages go to sfl4j
//         SLF4JBridgeHandler.install();
//     }
// 
//     @Override
//     public void contextDestroyed(final ServletContextEvent event)
//     {
//         SLF4JBridgeHandler.uninstall();
//     }
// }


import com.ning.jetty.core.CoreConfig;
import com.ning.jetty.core.listeners.SetupJULBridge;
import com.google.common.base.Preconditions;
import com.google.common.io.Resources;
import com.google.inject.servlet.GuiceFilter;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.NCSARequestLog;
import org.eclipse.jetty.server.RequestLog;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.RequestLogHandler;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.xml.XmlConfiguration;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.management.MBeanServer;
import javax.servlet.DispatcherType;
import java.lang.management.ManagementFactory;
import java.util.EnumSet;
import java.util.EventListener;
import java.util.Map;
        final SslSelectChannelConnector sslConnector = new SslSelectChannelConnector();
        sslConnector.setName("https");
        sslConnector.setStatsOn(isStatsOn);
        sslConnector.setPort(localSslPort);
        final SslContextFactory sslContextFactory = sslConnector.getSslContextFactory();
        sslContextFactory.setKeyStorePath(sslKeyStorePath);
        sslContextFactory.setKeyStorePassword(sslKeyStorePassword);
        server.addConnector(sslConnector);
    }

    private void configureThreadPool(final CoreConfig config)
    {
        final QueuedThreadPool threadPool = new QueuedThreadPool(config.getMaxThreads());
        threadPool.setMinThreads(config.getMinThreads());
        threadPool.setName("http-worker");
        server.setThreadPool(threadPool);
    }

    private ServletContextHandler createServletContextHandler(final String resourceBase, final Iterable<EventListener> eventListeners, final Map<FilterHolder, String> filterHolders)
    {
        final ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SESSIONS);
        context.setContextPath("/");

        if (resourceBase != null) {
            // Required if you want a webapp directory. See ContextHandler#getResource and http://docs.codehaus.org/display/JETTY/Embedding+Jetty
            final String webapp = this.getClass().getClassLoader().getResource(resourceBase).toExternalForm();
            context.setResourceBase(webapp);
        }

        // Jersey insists on using java.util.logging (JUL)
// Path: core/src/main/java/com/ning/jetty/core/CoreConfig.java
// public interface CoreConfig
// {
//     @Config("com.ning.core.server.ip")
//     @Default("127.0.0.1")
//     String getServerHost();
// 
//     @Config("com.ning.core.server.port")
//     @Default("8080")
//     int getServerPort();
// 
//     @Config("com.ning.core.server.server.ssl.enabled")
//     @Default("false")
//     boolean isSSLEnabled();
// 
//     @Config("com.ning.core.server.server.ssl.port")
//     @Default("8443")
//     int getServerSslPort();
// 
//     @Config("com.ning.core.server.jetty.stats")
//     @Default("true")
//     boolean isJettyStatsOn();
// 
//     @Config("com.ning.core.server.jetty.ssl.keystore")
//     @DefaultNull
//     String getSSLkeystoreLocation();
// 
//     @Config("com.ning.core.server.jetty.ssl.keystore.password")
//     @DefaultNull
//     String getSSLkeystorePassword();
// 
//     @Config("com.ning.core.server.jetty.maxThreads")
//     @Default("2000")
//     int getMaxThreads();
// 
//     @Config("com.ning.core.server.jetty.minThreads")
//     @Default("2")
//     int getMinThreads();
// 
//     @Config("com.ning.core.server.jetty.logPath")
//     @Default(".logs")
//     String getLogPath();
// 
//     @Config("com.ning.core.server.jetty.resourceBase")
//     @DefaultNull
//     String getResourceBase();
// }
// 
// Path: core/src/main/java/com/ning/jetty/core/listeners/SetupJULBridge.java
// public class SetupJULBridge implements ServletContextListener
// {
//     @Override
//     public void contextInitialized(final ServletContextEvent event)
//     {
//         // We first remove the default handler(s)
//         final Logger rootLogger = LogManager.getLogManager().getLogger("");
//         final Handler[] handlers = rootLogger.getHandlers();
// 
//         if (!ArrayUtils.isEmpty(handlers)) {
//             for (final Handler handler : handlers) {
//                 rootLogger.removeHandler(handler);
//             }
//         }
//         // And then we let jul-to-sfl4j do its magic so that jersey messages go to sfl4j
//         SLF4JBridgeHandler.install();
//     }
// 
//     @Override
//     public void contextDestroyed(final ServletContextEvent event)
//     {
//         SLF4JBridgeHandler.uninstall();
//     }
// }


// Path: core/src/main/java/com/ning/jetty/core/server/HttpServer.java
import com.ning.jetty.core.CoreConfig;
import com.ning.jetty.core.listeners.SetupJULBridge;
import com.google.common.base.Preconditions;
import com.google.common.io.Resources;
import com.google.inject.servlet.GuiceFilter;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.NCSARequestLog;
import org.eclipse.jetty.server.RequestLog;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.RequestLogHandler;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.xml.XmlConfiguration;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.management.MBeanServer;
import javax.servlet.DispatcherType;
import java.lang.management.ManagementFactory;
import java.util.EnumSet;
import java.util.EventListener;
import java.util.Map;

        final SslSelectChannelConnector sslConnector = new SslSelectChannelConnector();
        sslConnector.setName("https");
        sslConnector.setStatsOn(isStatsOn);
        sslConnector.setPort(localSslPort);
        final SslContextFactory sslContextFactory = sslConnector.getSslContextFactory();
        sslContextFactory.setKeyStorePath(sslKeyStorePath);
        sslContextFactory.setKeyStorePassword(sslKeyStorePassword);
        server.addConnector(sslConnector);
    }

    private void configureThreadPool(final CoreConfig config)
    {
        final QueuedThreadPool threadPool = new QueuedThreadPool(config.getMaxThreads());
        threadPool.setMinThreads(config.getMinThreads());
        threadPool.setName("http-worker");
        server.setThreadPool(threadPool);
    }

    private ServletContextHandler createServletContextHandler(final String resourceBase, final Iterable<EventListener> eventListeners, final Map<FilterHolder, String> filterHolders)
    {
        final ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SESSIONS);
        context.setContextPath("/");

        if (resourceBase != null) {
            // Required if you want a webapp directory. See ContextHandler#getResource and http://docs.codehaus.org/display/JETTY/Embedding+Jetty
            final String webapp = this.getClass().getClassLoader().getResource(resourceBase).toExternalForm();
            context.setResourceBase(webapp);
        }

        // Jersey insists on using java.util.logging (JUL)
        final EventListener listener = new SetupJULBridge();