Search in sources :

Example 6 with DefaultHandler

use of org.mortbay.jetty.handler.DefaultHandler 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)

Aggregations

DefaultHandler (org.mortbay.jetty.handler.DefaultHandler)6 Server (org.mortbay.jetty.Server)5 Connector (org.mortbay.jetty.Connector)4 SelectChannelConnector (org.mortbay.jetty.nio.SelectChannelConnector)4 HandlerList (org.mortbay.jetty.handler.HandlerList)3 IOException (java.io.IOException)2 Handler (org.mortbay.jetty.Handler)2 ResourceHandler (org.mortbay.jetty.handler.ResourceHandler)2 SslSocketConnector (org.mortbay.jetty.security.SslSocketConnector)2 WebAppContext (org.mortbay.jetty.webapp.WebAppContext)2 FileNotFoundException (java.io.FileNotFoundException)1 ServerSocket (java.net.ServerSocket)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 SocketConnector (org.mortbay.jetty.bio.SocketConnector)1 ContextHandlerCollection (org.mortbay.jetty.handler.ContextHandlerCollection)1 HandlerCollection (org.mortbay.jetty.handler.HandlerCollection)1 RequestLogHandler (org.mortbay.jetty.handler.RequestLogHandler)1