public class FixedVersionStrategy extends AbstractVersionStrategy
VersionStrategy that handles unique, static, application-wide version strings
as prefixes in the request path.
Enables inserting a unique and static version String (e.g. reduced SHA, version name, release date) at the beginning of resource paths so that when a new version of the application is released, clients are forced to reload application resources.
This is useful when changing resource names is not an option (e.g. when
using JavaScript module loaders). If that's not the case, the use of
ContentBasedVersionStrategy provides more optimal performance since
version is generated on a per-resource basis: only actually modified resources are reloaded
by the client.
VersionResourceResolverlogger| Constructor and Description |
|---|
FixedVersionStrategy(Callable<String> versionInitializer)
Create a new FixedVersionStrategy and get the version string to use by
calling the given
Callable instance. |
FixedVersionStrategy(String fixedVersion)
Create a new FixedVersionStrategy with the given version string.
|
| Modifier and Type | Method and Description |
|---|---|
String |
addVersionToUrl(String baseUrl,
List<? extends org.springframework.core.io.Resource> locations,
ResourceResolverChain chain)
Adds a version string to the given baseUrl.
|
String |
deleteVersionFromPath(String requestPath,
String candidateVersion)
Deletes the given candidate version string from the given request path.
|
String |
extractVersionFromPath(String requestPath)
Extracts a version string from the request path.
|
boolean |
resourceVersionMatches(org.springframework.core.io.Resource baseResource,
String candidateVersion)
Checks whether the given
Resource matches the candidate version string. |
addVersionAsPrefix, addVersionToFilename, deleteVersionAsPrefix, deleteVersionFromFilename, extractVersionAsPrefix, extractVersionFromFilenamepublic FixedVersionStrategy(String fixedVersion)
fixedVersion - the fixed version string to usepublic String extractVersionFromPath(String requestPath)
VersionStrategyrequestPath - the request path of the resource being resolvedpublic String deleteVersionFromPath(String requestPath, String candidateVersion)
VersionStrategyrequestPath - the request path of the resource being resolvedcandidateVersion - the candidate version stringpublic boolean resourceVersionMatches(org.springframework.core.io.Resource baseResource,
String candidateVersion)
VersionStrategyResource matches the candidate version string.
Useful when the version string is managed on a per-resource basis.baseResource - the resource to check against the given versioncandidateVersion - the candidate version for the given resourcepublic String addVersionToUrl(String baseUrl, List<? extends org.springframework.core.io.Resource> locations, ResourceResolverChain chain)
VersionStrategybaseUrl - the baseUrl of the requested resourcelocations - the resource locations to resolve resources fromchain - the chain of resource resolvers