@Override protected void addInterceptors(InterceptorRegistry registry) { for (MappedInterceptor interceptor : mappedInterceptors) { InterceptorRegistration registration = registry.addInterceptor(interceptor.getInterceptor()); if (interceptor.getPathPatterns() != null) { registration.addPathPatterns(interceptor.getPathPatterns()); } } }
private List<HandlerInterceptor> getInterceptorsForPath(String lookupPath) { PathMatcher pathMatcher = new AntPathMatcher(); List<HandlerInterceptor> result = new ArrayList<>(); for (Object interceptor : this.registry.getInterceptors()) { if (interceptor instanceof MappedInterceptor) { MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor; if (mappedInterceptor.matches(lookupPath, pathMatcher)) { result.add(mappedInterceptor.getInterceptor()); } } else if (interceptor instanceof HandlerInterceptor) { result.add((HandlerInterceptor) interceptor); } else { fail("Unexpected interceptor type: " + interceptor.getClass().getName()); } } return result; }
@Test public void orderedInterceptors() throws Exception { HandlerInterceptor i1 = Mockito.mock(HandlerInterceptor.class); MappedInterceptor mappedInterceptor1 = new MappedInterceptor(new String[]{"/**"}, i1); HandlerInterceptor i2 = Mockito.mock(HandlerInterceptor.class); HandlerInterceptor i3 = Mockito.mock(HandlerInterceptor.class); MappedInterceptor mappedInterceptor3 = new MappedInterceptor(new String[]{"/**"}, i3); HandlerInterceptor i4 = Mockito.mock(HandlerInterceptor.class); this.handlerMapping.setInterceptors(mappedInterceptor1, i2, mappedInterceptor3, i4); this.handlerMapping.setApplicationContext(this.context); HandlerExecutionChain chain = this.handlerMapping.getHandlerExecutionChain(new SimpleHandler(), this.request); Assert.assertThat(chain.getInterceptors(), Matchers.arrayContaining( mappedInterceptor1.getInterceptor(), i2, mappedInterceptor3.getInterceptor(), i4)); }
MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor; if (mappedInterceptor.matches(lookupPath, this.pathMatcher)) { chain.addInterceptor(mappedInterceptor.getInterceptor());
MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor; if (mappedInterceptor.matches(lookupPath, this.pathMatcher)) { chain.addInterceptor(mappedInterceptor.getInterceptor());
.map(mappedInterceptor -> mappedInterceptor.getInterceptor().getClass()) .collect(Collectors.toList()); assertThat(interceptors, containsInAnyOrder(ConversionServiceExposingInterceptor.class,
/** * Obtain the {@link FacesHandlerInterceptor} by searching all mapped interceptors. * @return the interceptor */ protected HandlerInterceptor findFacesHandlerInterceptor() { HandlerInterceptor interceptor = null; Map<String, MappedInterceptor> mappedInterceptors = BeanFactoryUtils.beansOfTypeIncludingAncestors( getApplicationContext(), MappedInterceptor.class, true, false); for (MappedInterceptor mappedInterceptor : mappedInterceptors.values()) { if (mappedInterceptor.getInterceptor() instanceof FacesHandlerInterceptor) { Assert.state(interceptor == null, "Multiple " + FacesHandlerInterceptor.class.getSimpleName() + " registered within the web context"); interceptor = mappedInterceptor.getInterceptor(); } } Assert.state(interceptor != null, "No " + FacesHandlerInterceptor.class.getSimpleName() + " registered within the web context"); return interceptor; }
@Override protected void addInterceptors(InterceptorRegistry registry) { for (MappedInterceptor interceptor : mappedInterceptors) { InterceptorRegistration registration = registry.addInterceptor(interceptor.getInterceptor()); if (interceptor.getPathPatterns() != null) { registration.addPathPatterns(interceptor.getPathPatterns()); } } }
@Override protected void addInterceptors(InterceptorRegistry registry) { for (MappedInterceptor interceptor : mappedInterceptors) { InterceptorRegistration registration = registry.addInterceptor(interceptor.getInterceptor()); if (interceptor.getPathPatterns() != null) { registration.addPathPatterns(interceptor.getPathPatterns()); } } }
@Override protected void addInterceptors(InterceptorRegistry registry) { for (MappedInterceptor interceptor : mappedInterceptors) { InterceptorRegistration registration = registry.addInterceptor(interceptor.getInterceptor()); if (interceptor.getPathPatterns() != null) { registration.addPathPatterns(interceptor.getPathPatterns()); } } }
if ( mappedInterceptors != null ) { for ( MappedInterceptor interceptor : mappedInterceptors ) { table.addRow( "mapped", interceptor.getInterceptor().getClass().getName(), StringUtils.join( interceptor.getPathPatterns(), ", " ) );
MappedInterceptor mappedInterceptor = (MappedInterceptor) interceptor; if (mappedInterceptor.matches(lookupPath, this.pathMatcher)) { chain.addInterceptor(mappedInterceptor.getInterceptor());