private HttpContext createDriverContextWithSeleniumDriverResourceHandler(HttpContext context) { // Associate the SeleniumDriverResourceHandler with the /selenium-server/driver context HttpContext driverContext = new HttpContext(); driverContext.setContextPath("/selenium-server/driver"); driver = new SeleniumDriverResourceHandler(this); context.addHandler(driver); return driverContext; }
private void addStaticContentHandler(boolean slowResources, RemoteControlConfiguration configuration, HttpContext context) { StaticContentHandler.setSlowResources(slowResources); staticContentHandler = new StaticContentHandler(configuration.getDebugURL(), configuration.getProxyInjectionModeArg()); String overrideJavascriptDir = System.getProperty("selenium.javascript.dir"); if (overrideJavascriptDir != null) { staticContentHandler.addStaticContent(new FsResourceLocator(new File(overrideJavascriptDir))); } staticContentHandler.addStaticContent(new ClasspathResourceLocator()); context.addHandler(staticContentHandler); }
private void assembleHandlers(boolean slowResources, RemoteControlConfiguration configuration) { server.addContext(createRootContextWithProxyHandler(configuration)); HttpContext context = new HttpContext(); context.setContextPath("/selenium-server"); context.setMimeMapping("xhtml", "application/xhtml+xml"); addSecurityHandler(context); addStaticContentHandler(slowResources, configuration, context); context.addHandler(new SessionExtensionJsHandler()); context.addHandler(new SingleTestSuiteResourceHandler()); postResultsHandler = new SeleniumHTMLRunnerResultsHandler(); context.addHandler(postResultsHandler); context.addHandler(new CachedContentTestHandler()); server.addContext(context); server.addContext(createDriverContextWithSeleniumDriverResourceHandler(context)); }
protected HttpContext createRootContextWithProxyHandler(RemoteControlConfiguration configuration) { HttpContext root; root = new HttpContext(); root.setContextPath("/"); proxyHandler = makeProxyHandler(configuration); // see docs for the lock object for information on this and why it is IMPORTANT! proxyHandler.setShutdownLock(shutdownLock); root.addHandler(proxyHandler); return root; }
@Setup @SuppressWarnings({ "unused", "serial" }) private void setUp(JettyServer server, HttpChannel channel) throws Exception { this.server = server; final String path = "/" + channel.getServiceName(); handler = new AbstractHttpHandler() { public void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException { if (pathInContext.equals(path)) { JettyEndpoint.this.handle(pathParams, request, response); request.setHandled(true); } } }; server.getContext().addHandler(handler); handler.start(); }
@Setup @SuppressWarnings({ "unused", "serial" }) private void setUp(JettyServer server, HttpChannel channel) throws Exception { this.server = server; final String path = "/" + channel.getServiceName(); handler = new AbstractHttpHandler() { public void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException { if (pathInContext.equals(path)) { JettyEndpoint.this.handle(pathParams, request, response); request.setHandled(true); } } }; server.getContext().addHandler(handler); handler.start(); }
@Setup @SuppressWarnings({ "unused", "serial" }) private void setUp(JettyServer server, HttpChannel channel) throws Exception { this.server = server; final String path = "/" + channel.getServiceName(); handler = new AbstractHttpHandler() { public void handle(String pathInContext, String pathParams, HttpRequest request, HttpResponse response) throws HttpException, IOException { if (pathInContext.equals(path)) { JettyEndpoint.this.handle(pathParams, request, response); request.setHandled(true); } } }; server.getContext().addHandler(handler); handler.start(); }
public void start( BundleContext bundleContext ) throws Exception { m_jclLogger = LogFactory.getLog( Activator.class ); m_juliLogger = org.apache.juli.logging.LogFactory.getLog( Activator.class ); m_avalonLogger = AvalonLogFactory.getLogger( Activator.class.getName() ); m_slf4jLogger = LoggerFactory.getLogger( Activator.class ); m_jdkLogger = java.util.logging.Logger.getLogger( Activator.class.getName() ); m_jclLogger.info( "Starting Example... (jcl)" ); m_avalonLogger.info( "Starting Example... (avalon)" ); m_slf4jLogger.info( "Starting Example... (slf4j)" ); m_jdkLogger.info( "Starting Example... (jdk)" ); m_juliLogger.info( "Starting Example... (juli)" ); HttpHandler handler = new TestHandler( "test" ); InetAddrPort port = new InetAddrPort( 8080 ); HttpListener listener = new SocketListener( port ); m_server = new HttpServer(); HttpContext context = new HttpContext(); context.setContextPath( "/" ); context.addHandler( handler ); m_server.addContext( context ); m_server.addListener( listener ); m_server.start(); }
handlerContext.addHandler(handler); context.addHandler(resHandler);
context.addHandler(fHandler); context.addHandler(new NotFoundHandler()); fHandler2 = new MarkersServiceHandler(); context2.addHandler(fHandler2); context2.addHandler(new NotFoundHandler()); fServer.addContext(context2);
handler.setName(smap); context.addHandler(handler); try { handler.start();
public static void main(String[] args) throws Exception { Server server = new Server(); HttpContext httpContext = new HttpContext(); httpContext.setContextPath("/"); ProxyHandler proxy = new ProxyHandler(true, "", "", false, false); proxy.useCyberVillains = false; httpContext.addHandler(proxy); server.addContext(httpContext); SocketListener listener = new SocketListener(); listener.setPort(4444); server.addListener(listener); server.start(); }
private void addSecurityHandler(HttpContext context) { SecurityConstraint constraint = new SecurityConstraint(); constraint.setName(SecurityConstraint.__BASIC_AUTH); constraint.addRole("user"); constraint.setAuthenticate(true); context.addSecurityConstraint("/tests/html/basicAuth/*", constraint); HashUserRealm realm = new HashUserRealm("MyRealm"); realm.put("alice", "foo"); realm.addUserToRole("alice", "user"); context.setRealm(realm); SecurityHandler sh = new SecurityHandler(); context.addHandler(sh); }