use of org.eclipse.jetty.server.Handler in project jetty.project by eclipse.
the class ServletContextHandler method setServletHandler.
/* ------------------------------------------------------------ */
/**
* @param servletHandler The servletHandler to set.
*/
public void setServletHandler(ServletHandler servletHandler) {
if (isStarted())
throw new IllegalStateException("STARTED");
Handler next = null;
if (_servletHandler != null) {
next = _servletHandler.getHandler();
_servletHandler.setHandler(null);
replaceHandler(_servletHandler, servletHandler);
}
_servletHandler = servletHandler;
if (next != null && _servletHandler.getHandler() == null)
_servletHandler.setHandler(next);
relinkHandlers();
}
use of org.eclipse.jetty.server.Handler in project jetty.project by eclipse.
the class ServletContextHandler method setSecurityHandler.
/* ------------------------------------------------------------ */
/**
* @param securityHandler The {@link SecurityHandler} to set on this context.
*/
public void setSecurityHandler(SecurityHandler securityHandler) {
if (isStarted())
throw new IllegalStateException("STARTED");
Handler next = null;
if (_securityHandler != null) {
next = _securityHandler.getHandler();
_securityHandler.setHandler(null);
replaceHandler(_securityHandler, securityHandler);
}
_securityHandler = securityHandler;
if (next != null && _securityHandler.getHandler() == null)
_securityHandler.setHandler(next);
relinkHandlers();
}
use of org.eclipse.jetty.server.Handler in project jetty.project by eclipse.
the class ServletContextHandler method setGzipHandler.
/* ------------------------------------------------------------ */
/**
* @param gzipHandler The {@link GzipHandler} to set on this context.
*/
public void setGzipHandler(GzipHandler gzipHandler) {
if (isStarted())
throw new IllegalStateException("STARTED");
Handler next = null;
if (_gzipHandler != null) {
next = _gzipHandler.getHandler();
_gzipHandler.setHandler(null);
replaceHandler(_gzipHandler, gzipHandler);
}
_gzipHandler = gzipHandler;
if (next != null && _gzipHandler.getHandler() == null)
_gzipHandler.setHandler(next);
relinkHandlers();
}
use of org.eclipse.jetty.server.Handler in project jetty.project by eclipse.
the class StatisticsServlet method init.
public void init() throws ServletException {
ServletContext context = getServletContext();
ContextHandler.Context scontext = (ContextHandler.Context) context;
Server _server = scontext.getContextHandler().getServer();
Handler handler = _server.getChildHandlerByClass(StatisticsHandler.class);
if (handler != null) {
_statsHandler = (StatisticsHandler) handler;
} else {
LOG.warn("Statistics Handler not installed!");
return;
}
_memoryBean = ManagementFactory.getMemoryMXBean();
_connectors = _server.getConnectors();
if (getInitParameter("restrictToLocalhost") != null) {
_restrictToLocalhost = "true".equals(getInitParameter("restrictToLocalhost"));
}
}
use of org.eclipse.jetty.server.Handler in project buck by facebook.
the class TraceHandlerDelegateTest method testHandleGet.
@Test
public void testHandleGet() throws IOException, ServletException {
Request baseRequest = createMock(Request.class);
expect(baseRequest.getPathInfo()).andReturn("/abcdef");
baseRequest.setHandled(true);
HttpServletRequest request = createMock(HttpServletRequest.class);
HttpServletResponse response = createMock(HttpServletResponse.class);
response.setStatus(200);
response.setContentType("text/html; charset=utf-8");
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
expect(response.getWriter()).andReturn(printWriter);
response.flushBuffer();
BuildTraces buildTraces = createMock(BuildTraces.class);
expect(buildTraces.getTraceAttributesFor("abcdef")).andReturn(new TraceAttributes(Optional.of("buck build buck"), 2000L));
Handler traceHandler = new TemplateHandler(new TraceHandlerDelegate(buildTraces));
replayAll();
traceHandler.handle("/trace/abcdef", baseRequest, request, response);
verifyAll();
String expectedScriptTag = "<script src=\"/tracedata/abcdef?callback=onTracesLoaded\">";
String html = stringWriter.toString();
assertThat(html, containsString(expectedScriptTag));
assertThat(html, containsString("buck build buck"));
}
Aggregations