org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter Java Examples
The following examples show how to use
org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InterceptorRegistry.java From spring-analysis-note with MIT License | 5 votes |
/** * Adds the provided {@link WebRequestInterceptor}. * @param interceptor the interceptor to add * @return an {@link InterceptorRegistration} that allows you optionally configure the * registered interceptor further for example adding URL patterns it should apply to. */ public InterceptorRegistration addWebRequestInterceptor(WebRequestInterceptor interceptor) { WebRequestHandlerInterceptorAdapter adapted = new WebRequestHandlerInterceptorAdapter(interceptor); InterceptorRegistration registration = new InterceptorRegistration(adapted); this.registrations.add(registration); return registration; }
Example #2
Source File: InterceptorRegistryTests.java From spring-analysis-note with MIT License | 5 votes |
private void verifyWebInterceptor(HandlerInterceptor interceptor, TestWebRequestInterceptor webInterceptor) throws Exception { assertTrue(interceptor instanceof WebRequestHandlerInterceptorAdapter); interceptor.preHandle(this.request, this.response, null); assertTrue(webInterceptor.preHandleInvoked); }
Example #3
Source File: InterceptorRegistry.java From java-technology-stack with MIT License | 5 votes |
/** * Adds the provided {@link WebRequestInterceptor}. * @param interceptor the interceptor to add * @return an {@link InterceptorRegistration} that allows you optionally configure the * registered interceptor further for example adding URL patterns it should apply to. */ public InterceptorRegistration addWebRequestInterceptor(WebRequestInterceptor interceptor) { WebRequestHandlerInterceptorAdapter adapted = new WebRequestHandlerInterceptorAdapter(interceptor); InterceptorRegistration registration = new InterceptorRegistration(adapted); this.registrations.add(registration); return registration; }
Example #4
Source File: InterceptorRegistryTests.java From java-technology-stack with MIT License | 5 votes |
private void verifyWebInterceptor(HandlerInterceptor interceptor, TestWebRequestInterceptor webInterceptor) throws Exception { assertTrue(interceptor instanceof WebRequestHandlerInterceptorAdapter); interceptor.preHandle(this.request, this.response, null); assertTrue(webInterceptor.preHandleInvoked); }
Example #5
Source File: InterceptorRegistry.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Adds the provided {@link WebRequestInterceptor}. * @param interceptor the interceptor to add * @return An {@link InterceptorRegistration} that allows you optionally configure the * registered interceptor further for example adding URL patterns it should apply to. */ public InterceptorRegistration addWebRequestInterceptor(WebRequestInterceptor interceptor) { WebRequestHandlerInterceptorAdapter adapted = new WebRequestHandlerInterceptorAdapter(interceptor); InterceptorRegistration registration = new InterceptorRegistration(adapted); this.registrations.add(registration); return registration; }
Example #6
Source File: InterceptorRegistry.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Adds the provided {@link WebRequestInterceptor}. * @param interceptor the interceptor to add * @return An {@link InterceptorRegistration} that allows you optionally configure the * registered interceptor further for example adding URL patterns it should apply to. */ public InterceptorRegistration addWebRequestInterceptor(WebRequestInterceptor interceptor) { WebRequestHandlerInterceptorAdapter adapted = new WebRequestHandlerInterceptorAdapter(interceptor); InterceptorRegistration registration = new InterceptorRegistration(adapted); registrations.add(registration); return registration; }
Example #7
Source File: MvcNamespaceTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testInterceptors() throws Exception { loadBeanDefinitions("mvc-config-interceptors.xml", 21); RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class); assertNotNull(mapping); mapping.setDefaultHandler(handlerMethod); MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); request.setRequestURI("/accounts/12345"); request.addParameter("locale", "en"); request.addParameter("theme", "green"); HandlerExecutionChain chain = mapping.getHandler(request); assertEquals(5, chain.getInterceptors().length); assertTrue(chain.getInterceptors()[0] instanceof ConversionServiceExposingInterceptor); assertTrue(chain.getInterceptors()[1] instanceof LocaleChangeInterceptor); assertTrue(chain.getInterceptors()[2] instanceof WebRequestHandlerInterceptorAdapter); assertTrue(chain.getInterceptors()[3] instanceof ThemeChangeInterceptor); assertTrue(chain.getInterceptors()[4] instanceof UserRoleAuthorizationInterceptor); request.setRequestURI("/admin/users"); chain = mapping.getHandler(request); assertEquals(3, chain.getInterceptors().length); request.setRequestURI("/logged/accounts/12345"); chain = mapping.getHandler(request); assertEquals(5, chain.getInterceptors().length); assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter); request.setRequestURI("/foo/logged"); chain = mapping.getHandler(request); assertEquals(5, chain.getInterceptors().length); assertTrue(chain.getInterceptors()[4] instanceof WebRequestHandlerInterceptorAdapter); }
Example #8
Source File: InterceptorRegistryTests.java From spring4-understanding with Apache License 2.0 | 4 votes |
private void verifyWebInterceptor(HandlerInterceptor interceptor, TestWebRequestInterceptor webInterceptor) throws Exception { assertTrue(interceptor instanceof WebRequestHandlerInterceptorAdapter); interceptor.preHandle(this.request, this.response, null); assertTrue(webInterceptor.preHandleInvoked); }