use of org.eclipse.jetty.server.handler.HotSwapHandler in project jetty.project by eclipse.
the class HttpServerTestFixture method configureServer.
protected void configureServer(Handler handler) throws Exception {
HotSwapHandler swapper = (HotSwapHandler) _server.getHandler();
swapper.setHandler(handler);
handler.start();
}
use of org.eclipse.jetty.server.handler.HotSwapHandler in project jetty.project by eclipse.
the class HttpOutputTest method init.
@Before
public void init() throws Exception {
_server = new Server();
HttpConnectionFactory http = new HttpConnectionFactory();
http.getHttpConfiguration().setRequestHeaderSize(1024);
http.getHttpConfiguration().setResponseHeaderSize(1024);
http.getHttpConfiguration().setOutputBufferSize(4096);
_connector = new LocalConnector(_server, http, null);
_server.addConnector(_connector);
_swap = new HotSwapHandler();
_handler = new ContentHandler();
_swap.setHandler(_handler);
_server.setHandler(_swap);
_server.start();
}
use of org.eclipse.jetty.server.handler.HotSwapHandler in project jetty.project by eclipse.
the class WebAppContextTest method testServletContextListener.
@Test
public void testServletContextListener() throws Exception {
Server server = new Server();
HotSwapHandler swap = new HotSwapHandler();
server.setHandler(swap);
server.start();
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
context.setResourceBase(System.getProperty("java.io.tmpdir"));
final List<String> history = new ArrayList<>();
context.addEventListener(new ServletContextListener() {
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
history.add("I0");
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
history.add("D0");
}
});
context.addEventListener(new ServletContextListener() {
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
history.add("I1");
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
history.add("D1");
throw new RuntimeException("Listener1 destroy broken");
}
});
context.addEventListener(new ServletContextListener() {
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
history.add("I2");
throw new RuntimeException("Listener2 init broken");
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
history.add("D2");
}
});
context.addEventListener(new ServletContextListener() {
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
history.add("I3");
}
@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
history.add("D3");
}
});
try {
swap.setHandler(context);
context.start();
} catch (Exception e) {
history.add(e.getMessage());
} finally {
try {
swap.setHandler(null);
} catch (Exception e) {
while (e.getCause() instanceof Exception) e = (Exception) e.getCause();
history.add(e.getMessage());
} finally {
}
}
Assert.assertThat(history, Matchers.contains("I0", "I1", "I2", "Listener2 init broken", "D1", "D0", "Listener1 destroy broken"));
server.stop();
}
Aggregations