Search in sources :

Example 11 with Connector

use of org.mortbay.jetty.Connector in project roboguice by roboguice.

the class Main method main.

public static void main(String[] args) throws Exception {
    Server server = new Server();
    Connector connector = new SelectChannelConnector();
    connector.setPort(8080);
    server.setConnectors(new Connector[] { connector });
    WebAppContext webapp = new WebAppContext("./root", "/example");
    server.addHandler(webapp);
    server.start();
    server.join();
}
Also used : Connector(org.mortbay.jetty.Connector) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) WebAppContext(org.mortbay.jetty.webapp.WebAppContext) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) Server(org.mortbay.jetty.Server)

Example 12 with Connector

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

the class SiteRunMojo method getDefaultConnector.

private Connector getDefaultConnector() {
    Connector connector = new SelectChannelConnector();
    connector.setPort(port);
    connector.setMaxIdleTime(MAX_IDLE_TIME);
    return connector;
}
Also used : Connector(org.mortbay.jetty.Connector) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector)

Example 13 with Connector

use of org.mortbay.jetty.Connector 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 14 with Connector

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

the class ProjectInfoReportUtilsTest method getDefaultConnector.

private Connector getDefaultConnector() {
    Connector connector = new SelectChannelConnector();
    connector.setMaxIdleTime(MAX_IDLE_TIME);
    return connector;
}
Also used : Connector(org.mortbay.jetty.Connector) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector) SslSocketConnector(org.mortbay.jetty.security.SslSocketConnector) SelectChannelConnector(org.mortbay.jetty.nio.SelectChannelConnector)

Aggregations

Connector (org.mortbay.jetty.Connector)14 SelectChannelConnector (org.mortbay.jetty.nio.SelectChannelConnector)12 Server (org.mortbay.jetty.Server)8 WebAppContext (org.mortbay.jetty.webapp.WebAppContext)5 IOException (java.io.IOException)4 DefaultHandler (org.mortbay.jetty.handler.DefaultHandler)4 SslSocketConnector (org.mortbay.jetty.security.SslSocketConnector)4 Handler (org.mortbay.jetty.Handler)3 ArrayList (java.util.ArrayList)2 SocketConnector (org.mortbay.jetty.bio.SocketConnector)2 HandlerList (org.mortbay.jetty.handler.HandlerList)2 Constraint (org.mortbay.jetty.security.Constraint)2 ThreadPoolExecutorAdapter (com.google.util.threads.ThreadPoolExecutorAdapter)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 BindException (java.net.BindException)1 ServerSocket (java.net.ServerSocket)1 URL (java.net.URL)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1