// 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;
/*
 * Copyright 2010-2011 Ning, Inc.
 *
 * Ning licenses this file to you 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 com.ning.jetty.core.server;




/**
 * Embed Jetty
 */
public class HttpServer
{
    private final Server server;

    public HttpServer()
    {
        this.server = new Server();
        server.setSendServerVersion(false);
    }

    public HttpServer(final String jettyXml) throws Exception
    {
        this();
        configure(jettyXml);
    }

    public void configure(final String jettyXml) throws Exception
    {
        final XmlConfiguration configuration = new XmlConfiguration(Resources.getResource(jettyXml));
        configuration.configure(server);
    }

// 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;

/*
 * Copyright 2010-2011 Ning, Inc.
 *
 * Ning licenses this file to you 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 com.ning.jetty.core.server;




/**
 * Embed Jetty
 */
public class HttpServer
{
    private final Server server;

    public HttpServer()
    {
        this.server = new Server();
        server.setSendServerVersion(false);
    }

    public HttpServer(final String jettyXml) throws Exception
    {
        this();
        configure(jettyXml);
    }

    public void configure(final String jettyXml) throws Exception
    {
        final XmlConfiguration configuration = new XmlConfiguration(Resources.getResource(jettyXml));
        configuration.configure(server);
    }

    public void configure(final CoreConfig config, final Iterable<EventListener> eventListeners, final Map<FilterHolder, String> filterHolders)