use of org.springframework.util.PathMatcher in project spring-framework by spring-projects.
the class AbstractMessageBrokerConfiguration method simpAnnotationMethodMessageHandler.
@Bean
public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler() {
SimpAnnotationMethodMessageHandler handler = createAnnotationMethodMessageHandler();
handler.setDestinationPrefixes(getBrokerRegistry().getApplicationDestinationPrefixes());
handler.setMessageConverter(brokerMessageConverter());
handler.setValidator(simpValidator());
List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>();
addArgumentResolvers(argumentResolvers);
handler.setCustomArgumentResolvers(argumentResolvers);
List<HandlerMethodReturnValueHandler> returnValueHandlers = new ArrayList<>();
addReturnValueHandlers(returnValueHandlers);
handler.setCustomReturnValueHandlers(returnValueHandlers);
PathMatcher pathMatcher = getBrokerRegistry().getPathMatcher();
if (pathMatcher != null) {
handler.setPathMatcher(pathMatcher);
}
return handler;
}
use of org.springframework.util.PathMatcher in project spring-framework by spring-projects.
the class DelegatingWebMvcConfigurationTests method configurePathMatch.
@Test
public void configurePathMatch() throws Exception {
final PathMatcher pathMatcher = mock(PathMatcher.class);
final UrlPathHelper pathHelper = mock(UrlPathHelper.class);
List<WebMvcConfigurer> configurers = new ArrayList<>();
configurers.add(new WebMvcConfigurerAdapter() {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseRegisteredSuffixPatternMatch(true).setUseTrailingSlashMatch(false).setUrlPathHelper(pathHelper).setPathMatcher(pathMatcher);
}
});
delegatingConfig.setConfigurers(configurers);
RequestMappingHandlerMapping handlerMapping = delegatingConfig.requestMappingHandlerMapping();
assertNotNull(handlerMapping);
assertEquals("PathMatchConfigurer should configure RegisteredSuffixPatternMatch", true, handlerMapping.useRegisteredSuffixPatternMatch());
assertEquals("PathMatchConfigurer should configure SuffixPatternMatch", true, handlerMapping.useSuffixPatternMatch());
assertEquals("PathMatchConfigurer should configure TrailingSlashMatch", false, handlerMapping.useTrailingSlashMatch());
assertEquals("PathMatchConfigurer should configure UrlPathHelper", pathHelper, handlerMapping.getUrlPathHelper());
assertEquals("PathMatchConfigurer should configure PathMatcher", pathMatcher, handlerMapping.getPathMatcher());
}
use of org.springframework.util.PathMatcher in project spring-framework by spring-projects.
the class InterceptorRegistryTests method getInterceptorsForPath.
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;
}
use of org.springframework.util.PathMatcher in project spring-framework by spring-projects.
the class InterceptorRegistryTests method addInterceptorsWithCustomPathMatcher.
@Test
public void addInterceptorsWithCustomPathMatcher() {
PathMatcher pathMatcher = Mockito.mock(PathMatcher.class);
this.registry.addInterceptor(interceptor1).addPathPatterns("/path1/**").pathMatcher(pathMatcher);
MappedInterceptor mappedInterceptor = (MappedInterceptor) this.registry.getInterceptors().get(0);
assertSame(pathMatcher, mappedInterceptor.getPathMatcher());
}
use of org.springframework.util.PathMatcher in project AJSC by att.
the class InterceptorFilter method urlMappingResolver.
private ArrayList<String> urlMappingResolver(Map<String, String> p, String pathinfo) {
ArrayList<String> interceptorClasses = new ArrayList<String>();
PathMatcher pathMatcher = new AntPathMatcher();
for (Map.Entry<String, String> entry : p.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
String[] valueArray = value.split(",");
if (pathMatcher.match(key, pathinfo)) {
for (String val : valueArray) {
if (!interceptorClasses.contains(val)) {
interceptorClasses.add(val);
}
}
}
}
return interceptorClasses;
}
Aggregations