// 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;
        webapp.setPersistTempDirectory(true);

        for (JettyConsolePlugin plugin : pluginManager.getPlugins()) {
            plugin.beforeStart(webapp);
        }
        webapp.setAttribute("shutdownhook", shutdownHook);
        
        log.info("Added web application on path " + configuration.getContextPath() + " from war " + war.getAbsolutePath());

        log.info("Starting web application on port " + connector.getPort());

        final ClassLoader loader = Thread.currentThread().getContextClassLoader();

        try {
            Thread.currentThread().setContextClassLoader(JettyConsoleStarter.class.getClassLoader());

            try {
                server.start();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        } finally {
            Thread.currentThread().setContextClassLoader(loader);
        }


    }

    public void stopServer() {
        if(webapp != null) {
// 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;

        webapp.setPersistTempDirectory(true);

        for (JettyConsolePlugin plugin : pluginManager.getPlugins()) {
            plugin.beforeStart(webapp);
        }
        webapp.setAttribute("shutdownhook", shutdownHook);
        
        log.info("Added web application on path " + configuration.getContextPath() + " from war " + war.getAbsolutePath());

        log.info("Starting web application on port " + connector.getPort());

        final ClassLoader loader = Thread.currentThread().getContextClassLoader();

        try {
            Thread.currentThread().setContextClassLoader(JettyConsoleStarter.class.getClassLoader());

            try {
                server.start();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        } finally {
            Thread.currentThread().setContextClassLoader(loader);
        }


    }

    public void stopServer() {
        if(webapp != null) {
            for (JettyConsolePlugin plugin : pluginManager.getPlugins()) {