All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.browsermob.proxy.guice.JettyServerProvider Maven / Gradle / Ivy

There is a newer version: 2.0-beta-7
Show newest version
package org.browsermob.proxy.guice;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.name.Named;
import com.google.inject.servlet.GuiceFilter;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;

public class JettyServerProvider implements Provider {

    private Server server;

    @Inject
    public JettyServerProvider(@Named("port") int port) {
        server = new Server(port);

        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");

        context.addFilter(GuiceFilter.class, "/*", 0);
        context.addServlet(DefaultServlet.class, "/");

        server.setHandler(context);
    }

    @Override
    public Server get() {
        return server;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy