org.browsermob.proxy.guice.JettyServerProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of browsermob-proxy Show documentation
Show all versions of browsermob-proxy Show documentation
A programmatic HTTP/S designed for performance and functional testing
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;
}
}