Top Description Fields Constructors Methods
org.springframework.web.reactive.resource

public Class CachingResourceTransformer

extends Object
implements ResourceTransformer
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.resource.ResourceTransformer
Imports
org.apache.commons.logging.Log, .LogFactory, reactor.core.publisher.Mono, org.springframework.cache.Cache, .CacheManager, org.springframework.core.io.Resource, org.springframework.util.Assert, org.springframework.web.server.ServerWebExchange

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.
Author
Rossen Stoyanchev
Since
5.0

Field Summary

Modifier and TypeField and Description
private final Cache
private static final Log

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public Cache
getCache()

Return the configured Cache.

public Mono<Resource>
transform(ServerWebExchange
the current exchange
exchange
,
Resource
the resource to transform
resource
,
ResourceTransformerChain
the chain of remaining transformers to delegate to
transformerChain
)

Implements org.springframework.web.reactive.resource.ResourceTransformer.transform.

Transform the given resource.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final Cache cache
loggerback to summary
private static final Log logger

Constructor Detail

CachingResourceTransformerback to summary
public CachingResourceTransformer(Cache cache)
CachingResourceTransformerback to summary
public CachingResourceTransformer(CacheManager cacheManager, String cacheName)

Method Detail

getCacheback to summary
public Cache getCache()

Return the configured Cache.

transformback to summary
public Mono<Resource> transform(ServerWebExchange exchange, Resource resource, ResourceTransformerChain transformerChain)

Implements org.springframework.web.reactive.resource.ResourceTransformer.transform.

Doc from org.springframework.web.reactive.resource.ResourceTransformer.transform.

Transform the given resource.

Parameters
exchange:ServerWebExchange

the current exchange

resource:Resource

the resource to transform

transformerChain:ResourceTransformerChain

the chain of remaining transformers to delegate to

Returns:Mono<Resource>

the transformed resource (never empty)

Annotations
@Override