Class CachingResourceTransformer
java.lang.Object
org.springframework.web.reactive.resource.CachingResourceTransformer
- All Implemented Interfaces:
ResourceTransformer
A
ResourceTransformer that checks a Cache to see if a
previously transformed resource exists in the cache and returns it if found,
or otherwise delegates to the resolver chain and caches the result.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
-
Constructor Summary
ConstructorsConstructorDescriptionCachingResourceTransformer(org.springframework.cache.Cache cache) CachingResourceTransformer(org.springframework.cache.CacheManager cacheManager, String cacheName) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.cache.CachegetCache()Return the configuredCache.reactor.core.publisher.Mono<org.springframework.core.io.Resource>transform(org.springframework.web.server.ServerWebExchange exchange, org.springframework.core.io.Resource resource, ResourceTransformerChain transformerChain) Transform the given resource.
-
Constructor Details
-
CachingResourceTransformer
public CachingResourceTransformer(org.springframework.cache.Cache cache) -
CachingResourceTransformer
public CachingResourceTransformer(org.springframework.cache.CacheManager cacheManager, String cacheName)
-
-
Method Details
-
getCache
public org.springframework.cache.Cache getCache()Return the configuredCache. -
transform
public reactor.core.publisher.Mono<org.springframework.core.io.Resource> transform(org.springframework.web.server.ServerWebExchange exchange, org.springframework.core.io.Resource resource, ResourceTransformerChain transformerChain) Description copied from interface:ResourceTransformerTransform the given resource.- Specified by:
transformin interfaceResourceTransformer- Parameters:
exchange- the current exchangeresource- the resource to transformtransformerChain- the chain of remaining transformers to delegate to- Returns:
- the transformed resource (never empty)
-