use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.
the class JettyHttpServer method createContext.
@Override
public HttpContext createContext(String path, HttpHandler httpHandler) {
checkIfContextIsFree(path);
JettyHttpContext context = new JettyHttpContext(this, path, httpHandler);
HttpSpiContextHandler jettyContextHandler = context.getJettyContextHandler();
ContextHandlerCollection chc = findContextHandlerCollection(_server.getHandlers());
if (chc == null)
throw new RuntimeException("could not find ContextHandlerCollection, you must configure one");
chc.addHandler(jettyContextHandler);
_contexts.put(path, context);
return context;
}
use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.
the class JettyHttpServer method findContextHandlerCollection.
private ContextHandlerCollection findContextHandlerCollection(Handler[] handlers) {
if (handlers == null)
return null;
for (Handler handler : handlers) {
if (handler instanceof ContextHandlerCollection) {
return (ContextHandlerCollection) handler;
}
if (handler instanceof HandlerCollection) {
HandlerCollection hc = (HandlerCollection) handler;
ContextHandlerCollection chc = findContextHandlerCollection(hc.getHandlers());
if (chc != null)
return chc;
}
}
return null;
}
use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project jetty.project by eclipse.
the class JettyHttpServerProvider method createHttpServer.
@Override
public HttpServer createHttpServer(InetSocketAddress addr, int backlog) throws IOException {
Server server = _server;
boolean shared = true;
if (server == null) {
ThreadPool threadPool = new DelegatingThreadPool(new QueuedThreadPool());
server = new Server(threadPool);
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[] { new ContextHandlerCollection(), new DefaultHandler() });
server.setHandler(handlerCollection);
shared = false;
}
JettyHttpServer jettyHttpServer = new JettyHttpServer(server, shared);
jettyHttpServer.bind(addr, backlog);
return jettyHttpServer;
}
use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project Openfire by igniterealtime.
the class WebSocketPlugin method destroyPlugin.
@Override
public void destroyPlugin() {
// terminate any active websocket sessions
SessionManager sm = XMPPServer.getInstance().getSessionManager();
for (ClientSession session : sm.getSessions()) {
if (session instanceof LocalSession) {
Object ws = ((LocalSession) session).getSessionData("ws");
if (ws != null && (Boolean) ws) {
session.close();
}
}
}
ContextHandlerCollection contexts = HttpBindManager.getInstance().getContexts();
contexts.removeHandler(contextHandler);
contextHandler = null;
pluginClassLoader = null;
}
use of org.eclipse.jetty.server.handler.ContextHandlerCollection in project Openfire by igniterealtime.
the class WebSocketPlugin method initializePlugin.
@Override
public void initializePlugin(final PluginManager manager, final File pluginDirectory) {
if (Boolean.valueOf(JiveGlobals.getBooleanProperty(HttpBindManager.HTTP_BIND_ENABLED, true))) {
Log.info(String.format("Initializing websocket plugin"));
try {
ContextHandlerCollection contexts = HttpBindManager.getInstance().getContexts();
contextHandler = new ServletContextHandler(contexts, "/ws", ServletContextHandler.SESSIONS);
contextHandler.addServlet(new ServletHolder(this), "/*");
} catch (Exception e) {
Log.error("Failed to start websocket plugin", e);
}
} else {
Log.warn("Failed to start websocket plugin; http-bind is disabled");
}
}
Aggregations