use of org.eclipse.jetty.server.handler.HandlerCollection in project cxf by apache.
the class AtomBookServer method run.
protected void run() {
server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
WebAppContext webappcontext = new WebAppContext();
String contextPath = null;
try {
contextPath = getClass().getResource("/jaxrs_atom").toURI().getPath();
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
webappcontext.setContextPath("/");
webappcontext.setWar(contextPath);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
server.setHandler(handlers);
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.jetty.server.handler.HandlerCollection in project cxf by apache.
the class NioBookStoreServer method run.
protected void run() {
server = new org.eclipse.jetty.server.Server(Integer.parseInt(PORT));
WebAppContext webappcontext = new WebAppContext();
String contextPath = null;
try {
contextPath = getClass().getResource("/jaxrs_nio").toURI().getPath();
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
webappcontext.setContextPath("/");
webappcontext.setWar(contextPath);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
server.setHandler(handlers);
try {
server.start();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.jetty.server.handler.HandlerCollection in project camel by apache.
the class JettyHttpComponent method addJettyHandlers.
protected void addJettyHandlers(Server server, List<Handler> handlers) {
if (handlers != null && !handlers.isEmpty()) {
for (Handler handler : handlers) {
if (handler instanceof HandlerWrapper) {
// avoid setting a handler more than once
if (!isHandlerInChain(server.getHandler(), handler)) {
((HandlerWrapper) handler).setHandler(server.getHandler());
server.setHandler(handler);
}
} else {
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.addHandler(server.getHandler());
handlerCollection.addHandler(handler);
server.setHandler(handlerCollection);
}
}
}
}
use of org.eclipse.jetty.server.handler.HandlerCollection in project core by weld.
the class EclipseWeldServletHandler method findWAC.
protected static WebAppContext findWAC(ServletContext context) {
if (context instanceof ContextHandler.Context) {
ContextHandler.Context sContext = (ContextHandler.Context) context;
ContextHandler contextHandler = sContext.getContextHandler();
Handler handler = contextHandler.getHandler();
if (handler instanceof ServletHandler) {
ServletHandler servletHandler = (ServletHandler) handler;
Server server = servletHandler.getServer();
Handler serverHandler = server.getHandler();
if (serverHandler instanceof HandlerCollection) {
HandlerCollection hc = (HandlerCollection) serverHandler;
for (Handler h : hc.getHandlers()) {
if (h instanceof WebAppContext) {
WebAppContext wac = (WebAppContext) h;
if (wac.getServletHandler() == servletHandler) {
return wac;
}
}
}
}
}
}
return null;
}
use of org.eclipse.jetty.server.handler.HandlerCollection in project vespa by vespa-engine.
the class JettyHttpServer method getHandlerCollection.
private HandlerCollection getHandlerCollection(ServerConfig serverConfig, ServletPathsConfig servletPathsConfig, ServletHolder jdiscServlet, ComponentRegistry<ServletHolder> servletHolders, FilterHolder jDiscFilterInvokerFilter, RequestLog requestLog) {
ServletContextHandler servletContextHandler = createServletContextHandler();
servletHolders.allComponentsById().forEach((id, servlet) -> {
String path = getServletPath(servletPathsConfig, id);
servletContextHandler.addServlet(servlet, path);
servletContextHandler.addFilter(jDiscFilterInvokerFilter, path, EnumSet.allOf(DispatcherType.class));
});
servletContextHandler.addServlet(jdiscServlet, "/*");
GzipHandler gzipHandler = newGzipHandler(serverConfig);
gzipHandler.setHandler(servletContextHandler);
StatisticsHandler statisticsHandler = newStatisticsHandler();
statisticsHandler.setHandler(gzipHandler);
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { statisticsHandler, requestLogHandler });
return handlerCollection;
}
Aggregations