Search in sources :

Example 51 with Server

use of org.mortbay.jetty.Server in project maven-plugins by apache.

the class SiteRunMojo method execute.

/**
 * @see org.apache.maven.plugin.AbstractMojo#execute()
 */
public void execute() throws MojoExecutionException, MojoFailureException {
    checkInputEncoding();
    Server server = new Server();
    server.setStopAtShutdown(true);
    Connector defaultConnector = getDefaultConnector();
    server.setConnectors(new Connector[] { defaultConnector });
    WebAppContext webapp = createWebApplication();
    webapp.setServer(server);
    DefaultHandler defaultHandler = new DefaultHandler();
    defaultHandler.setServer(server);
    Handler[] handlers = new Handler[2];
    handlers[0] = webapp;
    handlers[1] = defaultHandler;
    server.setHandlers(handlers);
    getLog().info("Starting Jetty on http://localhost:" + port + "/");
    try {
        server.start();
    } catch (Exception e) {
        throw new MojoExecutionException("Error executing Jetty: " + e.getMessage(), e);
    }
    // Watch it
    try {
        server.getThreadPool().join();
    } catch (InterruptedException e) {
        getLog().warn("Jetty was interrupted", e);
    }
}
Also used : Connector(org.mortbay.jetty.Connector) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Server(org.mortbay.jetty.Server) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Handler(org.mortbay.jetty.Handler) DefaultHandler(org.mortbay.jetty.handler.DefaultHandler) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) FileNotFoundException(java.io.FileNotFoundException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) DefaultHandler(org.mortbay.jetty.handler.DefaultHandler)

Example 52 with Server

use of org.mortbay.jetty.Server in project maven-archetype by apache.

the class ArchetyperRoundtripIT method setUp.

public void setUp() throws Exception {
    super.setUp();
    // Start Jetty
    System.setProperty("org.apache.maven.archetype.repository.directory", getTestPath("target/test-classes/repositories/central"));
    server = new Server(0);
    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/repo");
    webapp.setWar("target/wars/archetype-repository.war");
    server.setHandler(webapp);
    server.start();
    port = server.getConnectors()[0].getLocalPort();
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Server(org.mortbay.jetty.Server)

Example 53 with Server

use of org.mortbay.jetty.Server in project maven-archetype by apache.

the class ArchetyperRoundtripWithProxyIT method setUp.

public void setUp() throws Exception {
    super.setUp();
    // Start Proxy Jetty
    System.setProperty("org.apache.maven.archetype.repository.directory", getTestPath("target/test-classes/repositories/central"));
    proxyServer = new Server(0);
    WebAppContext webappProxy = new WebAppContext();
    webappProxy.setContextPath("/");
    webappProxy.setWar("target/wars/archetype-proxy.war");
    proxyServer.setHandler(webappProxy);
    proxyServer.start();
    proxyPort = proxyServer.getConnectors()[0].getLocalPort();
    server = new Server(0);
    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/repo");
    webapp.setWar("target/wars/archetype-repository.war");
    server.setHandler(webapp);
    server.start();
    port = server.getConnectors()[0].getLocalPort();
}
Also used : WebAppContext(org.mortbay.jetty.webapp.WebAppContext) Server(org.mortbay.jetty.Server)

Example 54 with Server

use of org.mortbay.jetty.Server in project eureka by Netflix.

the class MockRemoteEurekaServer method start.

public void start() throws Exception {
    server = new Server(port);
    server.setHandler(new AppsResourceHandler());
    server.start();
    port = server.getConnectors()[0].getLocalPort();
}
Also used : Server(org.mortbay.jetty.Server)

Aggregations

Server (org.mortbay.jetty.Server)54 WebAppContext (org.mortbay.jetty.webapp.WebAppContext)20 SocketConnector (org.mortbay.jetty.bio.SocketConnector)15 SelectChannelConnector (org.mortbay.jetty.nio.SelectChannelConnector)14 Connector (org.mortbay.jetty.Connector)12 ServletHolder (org.mortbay.jetty.servlet.ServletHolder)12 Context (org.mortbay.jetty.servlet.Context)11 IOException (java.io.IOException)8 HandlerList (org.mortbay.jetty.handler.HandlerList)7 ResourceHandler (org.mortbay.jetty.handler.ResourceHandler)7 Handler (org.mortbay.jetty.Handler)6 ServletHandler (org.mortbay.jetty.servlet.ServletHandler)6 ContextHandler (org.mortbay.jetty.handler.ContextHandler)5 DefaultHandler (org.mortbay.jetty.handler.DefaultHandler)5 Configuration (org.apache.hadoop.conf.Configuration)4 FilterHolder (org.mortbay.jetty.servlet.FilterHolder)4 URL (java.net.URL)3 ServletException (javax.servlet.ServletException)3 Before (org.junit.Before)3 SslSocketConnector (org.mortbay.jetty.security.SslSocketConnector)3