Search in sources :

Example 1 with WebRequestInterceptor

use of org.springframework.web.context.request.WebRequestInterceptor in project grails-core by grails.

the class WebUtils method lookupHandlerInterceptors.

/**
 * Looks up all of the HandlerInterceptor instances registered for the application
 *
 * @param servletContext The ServletContext instance
 * @return An array of HandlerInterceptor instances
 */
public static HandlerInterceptor[] lookupHandlerInterceptors(ServletContext servletContext) {
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    final Collection<HandlerInterceptor> allHandlerInterceptors = new ArrayList<HandlerInterceptor>();
    WebRequestInterceptor[] webRequestInterceptors = lookupWebRequestInterceptors(servletContext);
    for (WebRequestInterceptor webRequestInterceptor : webRequestInterceptors) {
        allHandlerInterceptors.add(new WebRequestHandlerInterceptorAdapter(webRequestInterceptor));
    }
    final Collection<HandlerInterceptor> handlerInterceptors = wac.getBeansOfType(HandlerInterceptor.class).values();
    allHandlerInterceptors.addAll(handlerInterceptors);
    return allHandlerInterceptors.toArray(new HandlerInterceptor[allHandlerInterceptors.size()]);
}
Also used : HandlerInterceptor(org.springframework.web.servlet.HandlerInterceptor) WebRequestInterceptor(org.springframework.web.context.request.WebRequestInterceptor) ArrayList(java.util.ArrayList) WebRequestHandlerInterceptorAdapter(org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Example 2 with WebRequestInterceptor

use of org.springframework.web.context.request.WebRequestInterceptor in project grails-core by grails.

the class WebUtils method lookupWebRequestInterceptors.

/**
 * Looks up all of the WebRequestInterceptor instances registered with the application
 *
 * @param servletContext The ServletContext instance
 * @return An array of WebRequestInterceptor instances
 */
public static WebRequestInterceptor[] lookupWebRequestInterceptors(ServletContext servletContext) {
    WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    final Collection<WebRequestInterceptor> webRequestInterceptors = wac.getBeansOfType(WebRequestInterceptor.class).values();
    return webRequestInterceptors.toArray(new WebRequestInterceptor[webRequestInterceptors.size()]);
}
Also used : WebRequestInterceptor(org.springframework.web.context.request.WebRequestInterceptor) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Aggregations

WebApplicationContext (org.springframework.web.context.WebApplicationContext)2 WebRequestInterceptor (org.springframework.web.context.request.WebRequestInterceptor)2 ArrayList (java.util.ArrayList)1 HandlerInterceptor (org.springframework.web.servlet.HandlerInterceptor)1 WebRequestHandlerInterceptorAdapter (org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter)1