use of org.eclipse.jetty.server.Handler in project jetty.project by eclipse.
the class JettyHttpServer method checkIfContextIsFree.
private void checkIfContextIsFree(String path) {
Handler serverHandler = _server.getHandler();
if (serverHandler instanceof ContextHandler) {
ContextHandler ctx = (ContextHandler) serverHandler;
if (ctx.getContextPath().equals(path))
throw new RuntimeException("another context already bound to path " + path);
}
Handler[] handlers = _server.getHandlers();
if (handlers == null)
return;
for (Handler handler : handlers) {
if (handler instanceof ContextHandler) {
ContextHandler ctx = (ContextHandler) handler;
if (ctx.getContextPath().equals(path))
throw new RuntimeException("another context already bound to path " + path);
}
}
}
use of org.eclipse.jetty.server.Handler 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 in project jetty.project by eclipse.
the class Invoker method init.
/* ------------------------------------------------------------ */
public void init() {
ServletContext config = getServletContext();
_contextHandler = ((ContextHandler.Context) config).getContextHandler();
Handler handler = _contextHandler.getHandler();
while (handler != null && !(handler instanceof ServletHandler) && (handler instanceof HandlerWrapper)) handler = ((HandlerWrapper) handler).getHandler();
_servletHandler = (ServletHandler) handler;
Enumeration<String> e = getInitParameterNames();
while (e.hasMoreElements()) {
String param = e.nextElement();
String value = getInitParameter(param);
String lvalue = value.toLowerCase(Locale.ENGLISH);
if ("nonContextServlets".equals(param)) {
_nonContextServlets = value.length() > 0 && lvalue.startsWith("t");
}
if ("verbose".equals(param)) {
_verbose = value.length() > 0 && lvalue.startsWith("t");
} else {
if (_parameters == null)
_parameters = new HashMap<String, String>();
_parameters.put(param, value);
}
}
}
use of org.eclipse.jetty.server.Handler in project jetty.project by eclipse.
the class ServletContextHandler method setSessionHandler.
/* ------------------------------------------------------------ */
/**
* @param sessionHandler The sessionHandler to set.
*/
public void setSessionHandler(SessionHandler sessionHandler) {
if (isStarted())
throw new IllegalStateException("STARTED");
Handler next = null;
if (_sessionHandler != null) {
next = _sessionHandler.getHandler();
_sessionHandler.setHandler(null);
replaceHandler(_sessionHandler, sessionHandler);
}
_sessionHandler = sessionHandler;
if (next != null && _sessionHandler.getHandler() == null)
_sessionHandler.setHandler(next);
relinkHandlers();
}
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();
}
Aggregations