use of org.eclipse.jetty.servlet.ServletHandler in project neo4j by neo4j.
the class OcspStaplingIT method startOcspMock.
private static int startOcspMock() throws Exception {
Server jettyServer = new Server(0);
ServletHandler handler = new ServletHandler();
jettyServer.setHandler(handler);
jettyServer.setDumpBeforeStop(true);
handler.addServletWithMapping(EndUserOcspResponderServlet.class, "/endUserCA");
handler.addServletWithMapping(IntOcspResponderServlet.class, "/intCA");
jettyServer.start();
return jettyServer.getURI().getPort();
}
use of org.eclipse.jetty.servlet.ServletHandler in project qi4j-sdk by Qi4j.
the class AbstractJettyMixin method startJetty.
@Override
public final void startJetty() throws Exception {
// Prepare ServletContext
ServletContextHandler root = new ServletContextHandler(server, "/", new SessionHandler(), buildSecurityHandler(), new ServletHandler(), new ErrorHandler());
root.setDisplayName(identity);
configureContext(root, configuration());
// Register ContextListeners, Servlets and Filters
addContextListeners(root, contextListeners);
addServlets(root, servlets);
addFilters(root, filters);
// Prepare Connector
Connector connector = buildConnector();
configureConnector(connector, configuration());
// Prepare Server
configureServer(server, configuration());
server.addConnector(connector);
if (mBeanServer != null) {
server.getContainer().addEventListener(new MBeanContainer(mBeanServer));
}
// Start
server.start();
}
use of org.eclipse.jetty.servlet.ServletHandler in project chassis by Kixeye.
the class TestSpringWebApp method httpServer.
@Bean(initMethod = "start", destroyMethod = "stop", name = "httpServer")
@Order(0)
public Server httpServer(ConfigurableWebApplicationContext webApplicationContext) {
// set up servlets
ServletHandler servlets = new ServletHandler();
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SECURITY);
context.setErrorHandler(null);
context.setWelcomeFiles(new String[] { "/" });
// set up spring with the servlet context
setServletContext(context.getServletContext());
// configure the spring mvc dispatcher
DispatcherServlet dispatcher = new DispatcherServlet(webApplicationContext);
// map application servlets
context.addServlet(new ServletHolder(dispatcher), "/");
servlets.setHandler(context);
// create the server
InetSocketAddress address = new InetSocketAddress(SocketUtils.findAvailableTcpPort());
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
connector.setHost(address.getHostName());
connector.setPort(address.getPort());
server.setConnectors(new Connector[] { connector });
server.setHandler(servlets);
server.setStopAtShutdown(true);
return server;
}
use of org.eclipse.jetty.servlet.ServletHandler in project druid by druid-io.
the class AsyncManagementForwardingServletTest method makeTestServer.
private static Server makeTestServer(int port, ExpectedRequest expectedRequest) {
Server server = new Server(port);
ServletHandler handler = new ServletHandler();
handler.addServletWithMapping(new ServletHolder(new HttpServlet() {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
handle(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
handle(req, resp);
}
@Override
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException {
handle(req, resp);
}
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException {
handle(req, resp);
}
private void handle(HttpServletRequest req, HttpServletResponse resp) throws IOException {
boolean passed = expectedRequest.path.equals(req.getRequestURI());
passed &= expectedRequest.query == null || expectedRequest.query.equals(req.getQueryString());
passed &= expectedRequest.method.equals(req.getMethod());
if (expectedRequest.headers != null) {
for (Map.Entry<String, String> header : expectedRequest.headers.entrySet()) {
passed &= header.getValue().equals(req.getHeader(header.getKey()));
}
}
passed &= expectedRequest.body == null || expectedRequest.body.equals(IOUtils.toString(req.getReader()));
expectedRequest.called = true;
resp.setStatus(passed ? 200 : 400);
}
}), "/*");
server.setHandler(handler);
return server;
}
use of org.eclipse.jetty.servlet.ServletHandler in project jena by apache.
the class ExFusekiMain_1_Servlet_AddFilter method addExtraFilter.
// Find the FusekiFilter and replace it with an indirection filter.
private static void addExtraFilter(FusekiServer server) {
Handler handler = server.getJettyServer().getHandler();
ServletContextHandler sch = (ServletContextHandler) handler;
ServletHandler servletHander = sch.getServletHandler();
FilterHolder[] fHolders = servletHander.getFilters();
for (int i = 0; i < fHolders.length; i++) {
FilterHolder fh = fHolders[i];
if (fh.getClassName().equals(FusekiFilter.class.getName())) {
FilterHolder fh2 = replacement(fh);
// ** Replacement.
fHolders[i] = fh2;
}
}
}
Aggregations