Class AbstractVersionStrategy
- java.lang.Object
- org.springframework.web.servlet.resource.AbstractVersionStrategy
- All Implemented Interfaces:
VersionPathStrategy,VersionStrategy
- Direct Known Subclasses:
ContentVersionStrategy,FixedVersionStrategy
public abstract class AbstractVersionStrategy extends Object implements VersionStrategy
Abstract base class forVersionStrategyimplementations.Supports versions as:
- prefix in the request path, like "version/static/myresource.js"
- file name suffix in the request path, like "static/myresource-version.js"
Note: This base class does not provide support for generating the version string.
- Since:
- 4.1
- Author:
- Brian Clozel, Rossen Stoyanchev
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractVersionStrategy.FileNameVersionPathStrategyFile name-basedVersionPathStrategy, e.g.protected static classAbstractVersionStrategy.PrefixVersionPathStrategyA prefix-basedVersionPathStrategy, e.g.
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractVersionStrategy(VersionPathStrategy pathStrategy)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaddVersion(String requestPath, String version)Add a version to the given request path.StringextractVersion(String requestPath)Extract the resource version from the request path.VersionPathStrategygetVersionPathStrategy()StringremoveVersion(String requestPath, String version)Remove the version from the request path.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.servlet.resource.VersionStrategy
getResourceVersion
Constructor Detail
AbstractVersionStrategy
protected AbstractVersionStrategy(VersionPathStrategy pathStrategy)
Method Detail
getVersionPathStrategy
public VersionPathStrategy getVersionPathStrategy()
extractVersion
public String extractVersion(String requestPath)
Description copied from interface:VersionPathStrategyExtract the resource version from the request path.- Specified by:
extractVersionin interfaceVersionPathStrategy- Parameters:
requestPath- the request path to check- Returns:
- the version string or
nullif none was found
removeVersion
public String removeVersion(String requestPath, String version)
Description copied from interface:VersionPathStrategyRemove the version from the request path. It is assumed that the given version was extracted viaVersionPathStrategy.extractVersion(String).- Specified by:
removeVersionin interfaceVersionPathStrategy- Parameters:
requestPath- the request path of the resource being resolvedversion- the version obtained fromVersionPathStrategy.extractVersion(String)- Returns:
- the request path with the version removed
addVersion
public String addVersion(String requestPath, String version)
Description copied from interface:VersionPathStrategyAdd a version to the given request path.- Specified by:
addVersionin interfaceVersionPathStrategy- Parameters:
requestPath- the requestPathversion- the version- Returns:
- the requestPath updated with a version string