package org.getahead.dwrdemo.cli;

import org.directwebremoting.servlet.DwrServlet;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.ResourceHandler;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;

/**
 * JettyLauncher.
 */
public class JettyLauncher
{
    /**
     * Sets up and runs server.
     * @param args
     */
    public static void main(String[] args)
    {
        Server server = new Server();

        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(8080);
        server.addConnector(connector);

        Context htmlContext = new Context(server, "/", Context.SESSIONS);
        ResourceHandler htmlHandler = new ResourceHandler();
        htmlHandler.setResourceBase("web");
        htmlContext.setHandler(htmlHandler);

        Context servletContext = new Context(server, "/", Context.SESSIONS);
        ServletHolder holder = new ServletHolder(new DwrServlet());
        holder.setInitParameter("activeReverseAjaxEnabled", "true");
        holder.setInitParameter("debug", "true");
        servletContext.addServlet(holder, "/dwr/*");
        servletContext.setResourceBase("web");

        try
        {
            JettyShutdown.addShutdownHook(server);
            server.start();
            server.join();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
    }
}

package org.getahead.dwrdemo.cli;

import org.mortbay.jetty.Server;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.webapp.WebAppContext;

/**
 * JettyLauncher.
 */
public class JettyLauncher
{
    /**
     * Sets up and runs server.
     * @param args
     */
    public static void main(String[] args)
    {
        Server server = new Server();

        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(8080);
        server.addConnector(connector);
        server.setStopAtShutdown(true);

        server.addHandler(new WebAppContext("web","/dwr"));

        server.addHandler(new WebAppContext("test","/dwr-test"));
    }
}

Use more compact Jetty Launcher
Use more compact Jetty Launcher


git-svn-id: ba1d8d5a2a2c535e023d6080c1e5c29aa0f5364e@1318 3a8262b2-faa5-11dc-8610-ff947880b6b2
