Class ResourceUrlProvider
- All Implemented Interfaces:
EventListener,Aware,ApplicationContextAware,ApplicationListener<ContextRefreshedEvent>
This class is aware of Spring WebFlux handler mappings used to serve static
resources and uses the ResourceResolver chains of the configured
ResourceHttpRequestHandlers to make its decisions.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Brian Clozel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal reactor.core.publisher.Mono<String>getForUriString(String uriString, ServerWebExchange exchange) Get the public resource URL for the given URI string.Return a read-only view of the resource handler mappings either manually configured or auto-detected from Spring configuration.voidHandle an application event.voidregisterHandlers(Map<String, ResourceWebHandler> handlerMap) Manually configure resource handler mappings.voidsetApplicationContext(ApplicationContext applicationContext) Set the ApplicationContext that this object runs in.
-
Constructor Details
-
ResourceUrlProvider
public ResourceUrlProvider()
-
-
Method Details
-
setApplicationContext
Description copied from interface:ApplicationContextAwareSet the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as
InitializingBean.afterPropertiesSet()or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader),ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)andMessageSourceAware, if applicable.- Specified by:
setApplicationContextin interfaceApplicationContextAware- Parameters:
applicationContext- the ApplicationContext object to be used by this object- Throws:
ApplicationContextException- in case of context initialization errorsBeansException- if thrown by application context methods- See Also:
-
getHandlerMap
Return a read-only view of the resource handler mappings either manually configured or auto-detected from Spring configuration. -
registerHandlers
Manually configure resource handler mappings.Note: by default resource mappings are auto-detected from the Spring
ApplicationContext. If this property is used, auto-detection is turned off. -
onApplicationEvent
Description copied from interface:ApplicationListenerHandle an application event.- Specified by:
onApplicationEventin interfaceApplicationListener<ContextRefreshedEvent>- Parameters:
event- the event to respond to
-
getForUriString
public final reactor.core.publisher.Mono<String> getForUriString(String uriString, ServerWebExchange exchange) Get the public resource URL for the given URI string.The URI string is expected to be a path and if it contains a query or fragment those will be preserved in the resulting public resource URL.
- Parameters:
uriString- the URI string to transformexchange- the current exchange- Returns:
- the resolved public resource URL path, or empty if unresolved
-