use of javax.servlet.DispatcherType in project jetty.project by eclipse.
the class ContextHandler method checkContext.
/* ------------------------------------------------------------ */
/*
* @see org.eclipse.jetty.server.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public boolean checkContext(final String target, final Request baseRequest, final HttpServletResponse response) throws IOException {
DispatcherType dispatch = baseRequest.getDispatcherType();
// Check the vhosts
if (!checkVirtualHost(baseRequest))
return false;
if (!checkContextPath(target))
return false;
// redirect null path infos
if (!_allowNullPathInfo && _contextPath.length() == target.length() && _contextPath.length() > 1) {
// context request must end with /
baseRequest.setHandled(true);
if (baseRequest.getQueryString() != null)
response.sendRedirect(URIUtil.addPaths(baseRequest.getRequestURI(), URIUtil.SLASH) + "?" + baseRequest.getQueryString());
else
response.sendRedirect(URIUtil.addPaths(baseRequest.getRequestURI(), URIUtil.SLASH));
return false;
}
switch(_availability) {
case SHUTDOWN:
case UNAVAILABLE:
baseRequest.setHandled(true);
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
return false;
default:
if ((DispatcherType.REQUEST.equals(dispatch) && baseRequest.isHandled()))
return false;
}
return true;
}
use of javax.servlet.DispatcherType in project jetty.project by eclipse.
the class ContextHandler method doHandle.
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.server.handler.ScopedHandler#doHandle(java.lang.String, org.eclipse.jetty.server.Request, javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
@Override
public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
final DispatcherType dispatch = baseRequest.getDispatcherType();
final boolean new_context = baseRequest.takeNewContext();
try {
if (new_context)
requestInitialized(baseRequest, request);
switch(dispatch) {
case REQUEST:
if (isProtectedTarget(target)) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
baseRequest.setHandled(true);
return;
}
break;
case ERROR:
// If this is already a dispatch to an error page, proceed normally
if (Boolean.TRUE.equals(baseRequest.getAttribute(Dispatcher.__ERROR_DISPATCH)))
break;
// We can just call doError here. If there is no error page, then one will
// be generated. If there is an error page, then a RequestDispatcher will be
// used to route the request through appropriate filters etc.
doError(target, baseRequest, request, response);
return;
default:
break;
}
nextHandle(target, baseRequest, request, response);
} finally {
if (new_context)
requestDestroyed(baseRequest, request);
}
}
use of javax.servlet.DispatcherType in project Activiti by Activiti.
the class WebConfigurer method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext servletContext = sce.getServletContext();
log.debug("Configuring Spring root application context");
AnnotationConfigWebApplicationContext rootContext = null;
if (context == null) {
rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(ApplicationConfiguration.class);
rootContext.refresh();
} else {
rootContext = context;
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootContext);
EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
initSpring(servletContext, rootContext);
initSpringSecurity(servletContext, disps);
log.debug("Web application fully configured");
}
use of javax.servlet.DispatcherType in project Activiti by Activiti.
the class JPAWebConfigurer method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext servletContext = sce.getServletContext();
log.debug("Configuring Spring root application context");
AnnotationConfigWebApplicationContext rootContext = null;
if (context == null) {
rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(JPAApplicationConfiguration.class);
rootContext.refresh();
} else {
rootContext = context;
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootContext);
EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
initSpring(servletContext, rootContext);
initSpringSecurity(servletContext, disps);
log.debug("Web application fully configured");
}
use of javax.servlet.DispatcherType in project Activiti by Activiti.
the class WebConfigurer method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext servletContext = sce.getServletContext();
log.debug("Configuring Spring root application context");
AnnotationConfigWebApplicationContext rootContext = null;
if (context == null) {
rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(ApplicationConfiguration.class);
rootContext.refresh();
} else {
rootContext = context;
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootContext);
EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
initSpring(servletContext, rootContext);
initSpringSecurity(servletContext, disps);
log.debug("Web application fully configured");
}
Aggregations