Search in sources :

Example 1 with HandlerCollection

use of org.mortbay.jetty.handler.HandlerCollection in project gradle by gradle.

the class Jetty6PluginServer method configureHandlers.

/**
     * Set up the handler structure to receive a webapp. Also put in a DefaultHandler so we get a nice page than a 404
     * if we hit the root and the webapp's context isn't at root.
     */
public void configureHandlers() throws Exception {
    this.defaultHandler = new DefaultHandler();
    this.requestLogHandler = new RequestLogHandler();
    if (this.requestLog != null) {
        this.requestLogHandler.setRequestLog(this.requestLog);
    }
    this.contexts = (ContextHandlerCollection) server.getChildHandlerByClass(ContextHandlerCollection.class);
    if (this.contexts == null) {
        this.contexts = new ContextHandlerCollection();
        this.handlers = (HandlerCollection) server.getChildHandlerByClass(HandlerCollection.class);
        if (this.handlers == null) {
            this.handlers = new HandlerCollection();
            this.server.setHandler(handlers);
            this.handlers.setHandlers(new Handler[] { this.contexts, this.defaultHandler, this.requestLogHandler });
        } else {
            this.handlers.addHandler(this.contexts);
        }
    }
}
Also used : RequestLogHandler(org.mortbay.jetty.handler.RequestLogHandler) ContextHandlerCollection(org.mortbay.jetty.handler.ContextHandlerCollection) HandlerCollection(org.mortbay.jetty.handler.HandlerCollection) ContextHandlerCollection(org.mortbay.jetty.handler.ContextHandlerCollection) DefaultHandler(org.mortbay.jetty.handler.DefaultHandler)

Example 2 with HandlerCollection

use of org.mortbay.jetty.handler.HandlerCollection in project gradle by gradle.

the class JettyRun method finishConfigurationBeforeStart.

public void finishConfigurationBeforeStart() throws Exception {
    Handler[] handlers = getConfiguredContextHandlers();
    org.gradle.api.plugins.jetty.internal.JettyPluginServer plugin = getServer();
    Server server = (Server) plugin.getProxiedObject();
    HandlerCollection contexts = (HandlerCollection) server.getChildHandlerByClass(ContextHandlerCollection.class);
    if (contexts == null) {
        contexts = (HandlerCollection) server.getChildHandlerByClass(HandlerCollection.class);
    }
    for (int i = 0; (handlers != null) && (i < handlers.length); i++) {
        contexts.addHandler(handlers[i]);
    }
}
Also used : JettyPluginServer(org.gradle.api.plugins.jetty.internal.JettyPluginServer) Jetty6PluginServer(org.gradle.api.plugins.jetty.internal.Jetty6PluginServer) Server(org.mortbay.jetty.Server) JettyPluginServer(org.gradle.api.plugins.jetty.internal.JettyPluginServer) Handler(org.mortbay.jetty.Handler) ContextHandler(org.mortbay.jetty.handler.ContextHandler) HandlerCollection(org.mortbay.jetty.handler.HandlerCollection) ContextHandlerCollection(org.mortbay.jetty.handler.ContextHandlerCollection) ContextHandlerCollection(org.mortbay.jetty.handler.ContextHandlerCollection)

Aggregations

ContextHandlerCollection (org.mortbay.jetty.handler.ContextHandlerCollection)2 HandlerCollection (org.mortbay.jetty.handler.HandlerCollection)2 Jetty6PluginServer (org.gradle.api.plugins.jetty.internal.Jetty6PluginServer)1 JettyPluginServer (org.gradle.api.plugins.jetty.internal.JettyPluginServer)1 Handler (org.mortbay.jetty.Handler)1 Server (org.mortbay.jetty.Server)1 ContextHandler (org.mortbay.jetty.handler.ContextHandler)1 DefaultHandler (org.mortbay.jetty.handler.DefaultHandler)1 RequestLogHandler (org.mortbay.jetty.handler.RequestLogHandler)1