Search in sources :

Example 1 with AbstractHandlerMapping

use of org.springframework.web.reactive.handler.AbstractHandlerMapping in project spring-framework by spring-projects.

the class WebFluxConfigurationSupport method resourceHandlerMapping.

/**
	 * Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped
	 * resource handlers. To configure resource handling, override
	 * {@link #addResourceHandlers}.
	 */
@Bean
public HandlerMapping resourceHandlerMapping() {
    ResourceHandlerRegistry registry = new ResourceHandlerRegistry(this.applicationContext, webFluxContentTypeResolver());
    addResourceHandlers(registry);
    AbstractHandlerMapping handlerMapping = registry.getHandlerMapping();
    if (handlerMapping != null) {
        PathMatchConfigurer pathMatchConfigurer = getPathMatchConfigurer();
        if (pathMatchConfigurer.getPathMatcher() != null) {
            handlerMapping.setPathMatcher(pathMatchConfigurer.getPathMatcher());
        }
        if (pathMatchConfigurer.getPathHelper() != null) {
            handlerMapping.setPathHelper(pathMatchConfigurer.getPathHelper());
        }
    } else {
        handlerMapping = new EmptyHandlerMapping();
    }
    return handlerMapping;
}
Also used : AbstractHandlerMapping(org.springframework.web.reactive.handler.AbstractHandlerMapping) Bean(org.springframework.context.annotation.Bean)

Example 2 with AbstractHandlerMapping

use of org.springframework.web.reactive.handler.AbstractHandlerMapping in project spring-framework by spring-projects.

the class WebFluxConfigurationSupport method resourceHandlerMapping.

/**
 * Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped
 * resource handlers. To configure resource handling, override
 * {@link #addResourceHandlers}.
 */
@Bean
public HandlerMapping resourceHandlerMapping(ResourceUrlProvider resourceUrlProvider) {
    ResourceLoader resourceLoader = this.applicationContext;
    if (resourceLoader == null) {
        resourceLoader = new DefaultResourceLoader();
    }
    ResourceHandlerRegistry registry = new ResourceHandlerRegistry(resourceLoader);
    registry.setResourceUrlProvider(resourceUrlProvider);
    addResourceHandlers(registry);
    AbstractHandlerMapping handlerMapping = registry.getHandlerMapping();
    if (handlerMapping != null) {
        configureAbstractHandlerMapping(handlerMapping, getPathMatchConfigurer());
    } else {
        handlerMapping = new EmptyHandlerMapping();
    }
    return handlerMapping;
}
Also used : ResourceLoader(org.springframework.core.io.ResourceLoader) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) DefaultResourceLoader(org.springframework.core.io.DefaultResourceLoader) AbstractHandlerMapping(org.springframework.web.reactive.handler.AbstractHandlerMapping) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)2 AbstractHandlerMapping (org.springframework.web.reactive.handler.AbstractHandlerMapping)2 DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)1 ResourceLoader (org.springframework.core.io.ResourceLoader)1