// Path: jetty-console-api/src/main/java/org/simplericity/jettyconsole/api/Configuration.java
// public interface Configuration {
// 
//     boolean isHeadless();
// 
//     void setHeadless(boolean headless);
// 
//     String getContextPath();
// 
//     void setContextPath(String contextPath);
// }
// 
// Path: jetty-console-api/src/main/java/org/simplericity/jettyconsole/api/JettyConsolePlugin.java
// public interface JettyConsolePlugin {
//     
//      List<StartOption> getStartOptions();
//      void beforeStart(WebAppContext context);
//      void beforeStop(WebAppContext context);
// 
//      void customizeServer(Server server);
// 
//      void customizeConnector(ServerConnector connector);
// 
//      void bootstrap();
// 
//      void configureConsole(Configuration configuration);
// }


import org.eclipse.jetty.annotations.AnnotationConfiguration;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.webapp.*;
import org.kantega.jexmec.PluginManager;
import org.simplericity.jettyconsole.api.Configuration;
import org.simplericity.jettyconsole.api.JettyConsolePlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

    public DefaultJettyManager(Properties settings, PluginManager<JettyConsolePlugin> pluginManager, File jettyWorkDirectory) {
        this.settings = settings;
        this.pluginManager = pluginManager;
        this.jettyWorkDirectory = jettyWorkDirectory;
        this.name = DefaultJettyManager.this.settings.getProperty("name");

        shutdownHook = new Runnable() {
            public void run() {
                shutdown();
            }
        };
    }


    public void shutdown() {
        log.info("Shutting down " + name + "..");
        try {
            if (server != null && (server.isStarted() || server.isStarting())) {
                server.stop();
                log.info("Shutdown of " + name + " complete.");
                for (JettyListener listener : listenerList) {
                    listener.serverStopped();
                }
            }
        } catch (Exception e) {
            log.info("Exception shutting down " + name + ": " + e.getMessage(), e);
        }
    }

// Path: jetty-console-api/src/main/java/org/simplericity/jettyconsole/api/Configuration.java
// public interface Configuration {
// 
//     boolean isHeadless();
// 
//     void setHeadless(boolean headless);
// 
//     String getContextPath();
// 
//     void setContextPath(String contextPath);
// }
// 
// Path: jetty-console-api/src/main/java/org/simplericity/jettyconsole/api/JettyConsolePlugin.java
// public interface JettyConsolePlugin {
//     
//      List<StartOption> getStartOptions();
//      void beforeStart(WebAppContext context);
//      void beforeStop(WebAppContext context);
// 
//      void customizeServer(Server server);
// 
//      void customizeConnector(ServerConnector connector);
// 
//      void bootstrap();
// 
//      void configureConsole(Configuration configuration);
// }


// Path: jetty-console-core/src/main/java/org/simplericity/jettyconsole/DefaultJettyManager.java
import org.eclipse.jetty.annotations.AnnotationConfiguration;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.plus.webapp.EnvConfiguration;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.webapp.*;
import org.kantega.jexmec.PluginManager;
import org.simplericity.jettyconsole.api.Configuration;
import org.simplericity.jettyconsole.api.JettyConsolePlugin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;


    public DefaultJettyManager(Properties settings, PluginManager<JettyConsolePlugin> pluginManager, File jettyWorkDirectory) {
        this.settings = settings;
        this.pluginManager = pluginManager;
        this.jettyWorkDirectory = jettyWorkDirectory;
        this.name = DefaultJettyManager.this.settings.getProperty("name");

        shutdownHook = new Runnable() {
            public void run() {
                shutdown();
            }
        };
    }


    public void shutdown() {
        log.info("Shutting down " + name + "..");
        try {
            if (server != null && (server.isStarted() || server.isStarting())) {
                server.stop();
                log.info("Shutdown of " + name + " complete.");
                for (JettyListener listener : listenerList) {
                    listener.serverStopped();
                }
            }
        } catch (Exception e) {
            log.info("Exception shutting down " + name + ": " + e.getMessage(), e);
        }
    }

    public void startServer(Configuration configuration) {