private ServletContextHandler buildServletContextHandler() { ServletContextHandler result = new ServletContextHandler(ServletContextHandler.SESSIONS); result.setContextPath("/"); return result; }
/** * Gets the {@link ServletContextHandler} of the metrics servlet. * * @return the {@link ServletContextHandler} object */ public ServletContextHandler getHandler() { ServletContextHandler contextHandler = new ServletContextHandler(); contextHandler.setContextPath(SERVLET_PATH); contextHandler.addServlet(new ServletHolder(createServlet()), "/"); return contextHandler; }
/** * Creates a Jetty context handler that can be used to expose Websocket functionality. * * Note that an invocation of this method will not register the handler (and thus make the related functionality * available to the end user). Instead, the created handler is returned by this method, and will need to be * registered with the embedded Jetty webserver by the caller. * * @return A Jetty context handler (never null). */ protected Handler createWebsocketHandler() { final ServletContextHandler context = new ServletContextHandler( null, "/ws", ServletContextHandler.SESSIONS ); context.setAllowNullPathInfo(true); // Add the functionality-providers. context.addServlet( new ServletHolder( new OpenfireWebSocketServlet() ), "/*" ); return context; }
public static void main(String[] args) throws Exception { Server server = new Server(HTTP_PORT); ServletContextHandler context = new ServletContextHandler(server, "/", SESSIONS); context.addServlet(DefaultServlet.class, "/"); server.start(); logger.info("Server running on port " + HTTP_PORT);
final Server server = new Server(port); final ContextHandlerCollection contexts = new ContextHandlerCollection(); final ServletContextHandler context = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS); server.setHandler(handlers);
webServer.setHandler(contexts); new ServletContextHandler(contexts, "/prof-output"); setContextAttributes(genCtx.getServletContext(), b.contextAttrs); genCtx.addServlet(ProfileOutputServlet.class, "/*"); genCtx.setResourceBase(tmpDir.toAbsolutePath().toString()); genCtx.setDisplayName("prof-output"); new ServletContextHandler(contexts, "/static"); staticCtx.setResourceBase(appDir + "/static"); staticCtx.addServlet(DefaultServlet.class, "/*"); staticCtx.setDisplayName("static"); if (logDir != null) { ServletContextHandler logCtx = new ServletContextHandler(contexts, "/logs"); setContextAttributes(logCtx.getServletContext(), b.contextAttrs); logCtx.addServlet(AdminAuthorizedServlet.class, "/*"); logCtx.setResourceBase(logDir); logCtx.setDisplayName("logs");
@BeforeClass public static void init() throws Exception { Map<String, Object> map = new HashMap<>(); map.put("key", "value1"); map.put("num", 42); JSON_RESPONSE = objectMapper.writeValueAsString(map); server = new Server(7009); ServletContextHandler servletContextHandler = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); servletContextHandler.setHandler(new EchoHandler()); server.start(); }
/** recreates the server so that it uses the supplied trace configuration */ public final void init() { stop(); server = newServer(port); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); server.setHandler(context); init(context); try { server.start(); port = getLocalPort(server); } catch (Exception e) { throw new IllegalStateException("Failed to start server.", e); } }
public void registerServlet(String path, Servlet servletContainer) { ServletHolder servletHolder = new ServletHolder(Source.EMBEDDED); servletHolder.setName("Data Transfer Project"); servletHolder.setServlet(servletContainer); servletHolder.setInitOrder(1); ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); handler.setContextPath("/"); handlers.add(handler); handler.getServletHandler().addServletWithMapping(servletHolder, path); }
public EmbeddedWebServer(String host, int port) { server = new Server(); final AccumuloConfiguration conf = Monitor.getContext().getConfiguration(); connector = new ServerConnector(server, getConnectionFactories(conf)); connector.setHost(host); connector.setPort(port); handler = new ServletContextHandler( ServletContextHandler.SESSIONS | ServletContextHandler.SECURITY); handler.getSessionHandler().getSessionCookieConfig().setHttpOnly(true); handler.setContextPath("/"); }
private void loadJAXRSResource( String mountPoint, JaxRsServletHolderFactory jaxRsServletHolderFactory ) { SessionHandler sessionHandler = new SessionHandler(); sessionHandler.setServer( getJetty() ); log.debug( "Mounting servlet at [%s]", mountPoint ); ServletContextHandler jerseyContext = new ServletContextHandler(); jerseyContext.setServer( getJetty() ); jerseyContext.setErrorHandler( new NeoJettyErrorHandler() ); jerseyContext.setContextPath( mountPoint ); jerseyContext.setSessionHandler( sessionHandler ); jerseyContext.addServlet( jaxRsServletHolderFactory.create( defaultInjectables, wadlEnabled ), "/*" ); addFiltersTo( jerseyContext ); handlers.addHandler( jerseyContext ); }
ServletContextHandler logContext = new ServletContextHandler(parent, "/logs"); logContext.addServlet(AdminAuthorizedServlet.class, "/*"); logContext.setResourceBase(logDir); ServletContextHandler staticContext = new ServletContextHandler(parent, "/static"); staticContext.setResourceBase(appDir + "/static"); staticContext.addServlet(DefaultServlet.class, "/*"); staticContext.setDisplayName("static"); setContextAttributes(staticContext, conf);
/** * Gets the {@link ServletContextHandler} of the metrics servlet. * * @return the {@link ServletContextHandler} object */ public ServletContextHandler getHandler() { ServletContextHandler contextHandler = new ServletContextHandler(); contextHandler.setContextPath(SERVLET_PATH); contextHandler.addServlet(new ServletHolder(new MetricsServlet(mCollectorRegistry)), "/"); return contextHandler; }
public static void main(String[] args) throws Exception { Server server = new Server(HTTP_PORT); ServletContextHandler context = new ServletContextHandler(server, "/", SESSIONS); context.addServlet(DefaultServlet.class, "/"); server.start(); logger.info("Server running on port " + HTTP_PORT);
server = new Server(port); final ContextHandlerCollection contexts = new ContextHandlerCollection(); final ServletContextHandler context = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS); server.setHandler(handlers);
htrootContext.setContextPath("/"); ServletContextHandler servletHandler = new ServletContextHandler(); servletHandler.addServlet(InstallationPageService.class, (InstallationPageService.class.newInstance()).getAPIPath()); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); ipaccess.setHandler(securityHandler); LoklakInstallation.server.setHandler(ipaccess);
private void initClientProxy(Config config, HandlerList handlers) { int port = config.getInteger("osmand.port"); if (port != 0) { ServletContextHandler servletHandler = new ServletContextHandler() { @Override public void doScope( String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (target.equals("/") && request.getMethod().equals(HttpMethod.POST.asString())) { super.doScope(target, baseRequest, request, response); } } }; ServletHolder servletHolder = new ServletHolder(new AsyncProxyServlet.Transparent()); servletHolder.setInitParameter("proxyTo", "http://localhost:" + port); servletHandler.addServlet(servletHolder, "/"); handlers.addHandler(servletHandler); } }
threadPool.setMinThreads(threads); server = new Server(threadPool); ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); context.setServletHandler(servletHandler); ServletManager.getInstance().addServletContext(url.getParameter(Constants.BIND_PORT_KEY, url.getPort()), context.getServletContext());
private ServletContextHandler getContext(HandlerContainer pContainer, MuleAgentConfig pConfig) { ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); context.setContextPath("/jolokia"); server.setHandler(context); if (pConfig.getUser() != null && pConfig.getPassword() != null) { context.setSecurityHandler( getSecurityHandler(pConfig.getUser(), pConfig.getPassword(), "jolokia-role")); } return context; }
= new ServletContextHandler(); boolean b = false; servletContextHandler.setContextPath("/");