Java Code Examples for org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#setInterceptors()

The following examples show how to use org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#setInterceptors() . 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: StandaloneMockMvcBuilder.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public RequestMappingHandlerMapping getHandlerMapping(
		FormattingConversionService mvcConversionService,
		ResourceUrlProvider mvcResourceUrlProvider) {
	RequestMappingHandlerMapping handlerMapping = handlerMappingFactory.get();
	handlerMapping.setEmbeddedValueResolver(new StaticStringValueResolver(placeholderValues));
	handlerMapping.setUseSuffixPatternMatch(useSuffixPatternMatch);
	handlerMapping.setUseTrailingSlashMatch(useTrailingSlashPatternMatch);
	handlerMapping.setOrder(0);
	handlerMapping.setInterceptors(getInterceptors(mvcConversionService, mvcResourceUrlProvider));
	if (removeSemicolonContent != null) {
		handlerMapping.setRemoveSemicolonContent(removeSemicolonContent);
	}
	return handlerMapping;
}
 
Example 2
Source File: ApiVersionConfig.java    From jframework with Apache License 2.0 5 votes vote down vote up
@Override
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    RequestMappingHandlerMapping handlerMapping = new ApiVersionRequestMappingHandlerMapping();
    handlerMapping.setOrder(0);
    handlerMapping.setInterceptors(getInterceptors());
    return handlerMapping;
}
 
Example 3
Source File: WebMvcConfigurationSupport.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping
 * requests to annotated controllers.
 */
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
	RequestMappingHandlerMapping mapping = createRequestMappingHandlerMapping();
	mapping.setOrder(0);
	mapping.setInterceptors(getInterceptors());
	mapping.setContentNegotiationManager(mvcContentNegotiationManager());
	mapping.setCorsConfigurations(getCorsConfigurations());

	PathMatchConfigurer configurer = getPathMatchConfigurer();

	Boolean useSuffixPatternMatch = configurer.isUseSuffixPatternMatch();
	if (useSuffixPatternMatch != null) {
		mapping.setUseSuffixPatternMatch(useSuffixPatternMatch);
	}
	Boolean useRegisteredSuffixPatternMatch = configurer.isUseRegisteredSuffixPatternMatch();
	if (useRegisteredSuffixPatternMatch != null) {
		mapping.setUseRegisteredSuffixPatternMatch(useRegisteredSuffixPatternMatch);
	}
	Boolean useTrailingSlashMatch = configurer.isUseTrailingSlashMatch();
	if (useTrailingSlashMatch != null) {
		mapping.setUseTrailingSlashMatch(useTrailingSlashMatch);
	}

	UrlPathHelper pathHelper = configurer.getUrlPathHelper();
	if (pathHelper != null) {
		mapping.setUrlPathHelper(pathHelper);
	}
	PathMatcher pathMatcher = configurer.getPathMatcher();
	if (pathMatcher != null) {
		mapping.setPathMatcher(pathMatcher);
	}
	Map<String, Predicate<Class<?>>> pathPrefixes = configurer.getPathPrefixes();
	if (pathPrefixes != null) {
		mapping.setPathPrefixes(pathPrefixes);
	}

	return mapping;
}
 
Example 4
Source File: StandaloneMockMvcBuilder.java    From java-technology-stack with MIT License 5 votes vote down vote up
public RequestMappingHandlerMapping getHandlerMapping() {
	RequestMappingHandlerMapping handlerMapping = handlerMappingFactory.get();
	handlerMapping.setEmbeddedValueResolver(new StaticStringValueResolver(placeholderValues));
	handlerMapping.setUseSuffixPatternMatch(useSuffixPatternMatch);
	handlerMapping.setUseTrailingSlashMatch(useTrailingSlashPatternMatch);
	handlerMapping.setOrder(0);
	handlerMapping.setInterceptors(getInterceptors());
	if (removeSemicolonContent != null) {
		handlerMapping.setRemoveSemicolonContent(removeSemicolonContent);
	}
	return handlerMapping;
}
 
Example 5
Source File: WebMvcConfigurationSupport.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping
 * requests to annotated controllers.
 */
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
	RequestMappingHandlerMapping mapping = createRequestMappingHandlerMapping();
	mapping.setOrder(0);
	mapping.setInterceptors(getInterceptors());
	mapping.setContentNegotiationManager(mvcContentNegotiationManager());
	mapping.setCorsConfigurations(getCorsConfigurations());

	PathMatchConfigurer configurer = getPathMatchConfigurer();
	if (configurer.isUseSuffixPatternMatch() != null) {
		mapping.setUseSuffixPatternMatch(configurer.isUseSuffixPatternMatch());
	}
	if (configurer.isUseRegisteredSuffixPatternMatch() != null) {
		mapping.setUseRegisteredSuffixPatternMatch(configurer.isUseRegisteredSuffixPatternMatch());
	}
	if (configurer.isUseTrailingSlashMatch() != null) {
		mapping.setUseTrailingSlashMatch(configurer.isUseTrailingSlashMatch());
	}
	UrlPathHelper pathHelper = configurer.getUrlPathHelper();
	if (pathHelper != null) {
		mapping.setUrlPathHelper(pathHelper);
	}
	PathMatcher pathMatcher = configurer.getPathMatcher();
	if (pathMatcher != null) {
		mapping.setPathMatcher(pathMatcher);
	}

	return mapping;
}
 
Example 6
Source File: WebMvcConfigurationSupport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping
 * requests to annotated controllers.
 */
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
	RequestMappingHandlerMapping handlerMapping = createRequestMappingHandlerMapping();
	handlerMapping.setOrder(0);
	handlerMapping.setInterceptors(getInterceptors());
	handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager());
	handlerMapping.setCorsConfigurations(getCorsConfigurations());

	PathMatchConfigurer configurer = getPathMatchConfigurer();
	if (configurer.isUseSuffixPatternMatch() != null) {
		handlerMapping.setUseSuffixPatternMatch(configurer.isUseSuffixPatternMatch());
	}
	if (configurer.isUseRegisteredSuffixPatternMatch() != null) {
		handlerMapping.setUseRegisteredSuffixPatternMatch(configurer.isUseRegisteredSuffixPatternMatch());
	}
	if (configurer.isUseTrailingSlashMatch() != null) {
		handlerMapping.setUseTrailingSlashMatch(configurer.isUseTrailingSlashMatch());
	}
	if (configurer.getPathMatcher() != null) {
		handlerMapping.setPathMatcher(configurer.getPathMatcher());
	}
	if (configurer.getUrlPathHelper() != null) {
		handlerMapping.setUrlPathHelper(configurer.getUrlPathHelper());
	}

	return handlerMapping;
}
 
Example 7
Source File: AppDispatcherServletConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
    LOGGER.debug("Creating requestMappingHandlerMapping");
    RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
    requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
    requestMappingHandlerMapping.setRemoveSemicolonContent(false);
    Object[] interceptors = { localeChangeInterceptor() };
    requestMappingHandlerMapping.setInterceptors(interceptors);
    return requestMappingHandlerMapping;
}
 
Example 8
Source File: DispatcherServletConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
    LOGGER.debug("Creating requestMappingHandlerMapping");
    RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
    requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
    Object[] interceptors = {localeChangeInterceptor()};
    requestMappingHandlerMapping.setInterceptors(interceptors);
    return requestMappingHandlerMapping;
}
 
Example 9
Source File: AppDispatcherServletConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
    LOGGER.debug("Creating requestMappingHandlerMapping");
    RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
    requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
    requestMappingHandlerMapping.setRemoveSemicolonContent(false);
    Object[] interceptors = { localeChangeInterceptor() };
    requestMappingHandlerMapping.setInterceptors(interceptors);
    return requestMappingHandlerMapping;
}
 
Example 10
Source File: AppDispatcherServletConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
    LOGGER.debug("Creating requestMappingHandlerMapping");
    RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
    requestMappingHandlerMapping.setUseSuffixPatternMatch(false);
    requestMappingHandlerMapping.setRemoveSemicolonContent(false);
    Object[] interceptors = { localeChangeInterceptor() };
    requestMappingHandlerMapping.setInterceptors(interceptors);
    return requestMappingHandlerMapping;
}
 
Example 11
Source File: SpringMvcConfiguration.java    From chassis with Apache License 2.0 5 votes vote down vote up
/**
 * Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping
 * requests to annotated controllers.
 */
@Bean
@Override
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
    PathMatchConfigurer configurer = new PathMatchConfigurer();
    configurePathMatch(configurer);
    RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
    handlerMapping.setOrder(0);
    handlerMapping.setDetectHandlerMethodsInAncestorContexts(true);
    handlerMapping.setInterceptors(getInterceptors());
    handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager());
    if (configurer.isUseSuffixPatternMatch() != null) {
        handlerMapping.setUseSuffixPatternMatch(configurer.isUseSuffixPatternMatch());
    }
    if (configurer.isUseRegisteredSuffixPatternMatch() != null) {
        handlerMapping.setUseRegisteredSuffixPatternMatch(configurer.isUseRegisteredSuffixPatternMatch());
    }
    if (configurer.isUseTrailingSlashMatch() != null) {
        handlerMapping.setUseTrailingSlashMatch(configurer.isUseTrailingSlashMatch());
    }
    if (configurer.getPathMatcher() != null) {
        handlerMapping.setPathMatcher(configurer.getPathMatcher());
    }
    if (configurer.getUrlPathHelper() != null) {
        handlerMapping.setUrlPathHelper(configurer.getUrlPathHelper());
    }
    return handlerMapping;
}
 
Example 12
Source File: WebMvcConfigurationSupport.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Return a {@link RequestMappingHandlerMapping} ordered at 0 for mapping
 * requests to annotated controllers.
 */
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping(
		ContentNegotiationManager mvcContentNegotiationManager,
		FormattingConversionService mvcConversionService,
		ResourceUrlProvider mvcResourceUrlProvider) {
	RequestMappingHandlerMapping mapping = createRequestMappingHandlerMapping();
	mapping.setOrder(0);
	mapping.setInterceptors(getInterceptors(mvcConversionService, mvcResourceUrlProvider));
	mapping.setContentNegotiationManager(mvcContentNegotiationManager);
	mapping.setCorsConfigurations(getCorsConfigurations());

	PathMatchConfigurer configurer = getPathMatchConfigurer();

	Boolean useSuffixPatternMatch = configurer.isUseSuffixPatternMatch();
	if (useSuffixPatternMatch != null) {
		mapping.setUseSuffixPatternMatch(useSuffixPatternMatch);
	}
	Boolean useRegisteredSuffixPatternMatch = configurer.isUseRegisteredSuffixPatternMatch();
	if (useRegisteredSuffixPatternMatch != null) {
		mapping.setUseRegisteredSuffixPatternMatch(useRegisteredSuffixPatternMatch);
	}
	Boolean useTrailingSlashMatch = configurer.isUseTrailingSlashMatch();
	if (useTrailingSlashMatch != null) {
		mapping.setUseTrailingSlashMatch(useTrailingSlashMatch);
	}

	UrlPathHelper pathHelper = configurer.getUrlPathHelper();
	if (pathHelper != null) {
		mapping.setUrlPathHelper(pathHelper);
	}
	PathMatcher pathMatcher = configurer.getPathMatcher();
	if (pathMatcher != null) {
		mapping.setPathMatcher(pathMatcher);
	}
	Map<String, Predicate<Class<?>>> pathPrefixes = configurer.getPathPrefixes();
	if (pathPrefixes != null) {
		mapping.setPathPrefixes(pathPrefixes);
	}

	return mapping;
}