Class MessageDigestResourceVersion
java.lang.Object
org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion
- All Implemented Interfaces:
IResourceVersion
computes the message digest of a
IStaticCacheableResource
and uses it as a version string
you can use any message digest algorithm that can be retrieved
by Java Cryptography Architecture (JCA) on your current platform.
Check here
for more information on possible algorithms.- Since:
- 1.5
- Author:
- Peter Ertl
-
Constructor Summary
ConstructorDescriptioncreate an instance of the message digest resource version provider using algorithm "MD5"MessageDigestResourceVersion
(String algorithm) create an instance of the message digest resource version provider using the specified algorithm.MessageDigestResourceVersion
(String algorithm, Bytes bufferSize) create an instance of the message digest resource version provider using the specified algorithm. -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]
computeDigest
(InputStream inputStream) compute digest for resource streamprotected MessageDigest
get instance of message digest provider from JCAgetVersion
(IStaticCacheableResource resource) get unique string identifying the version of the resourcea pattern that matches returned versions
-
Constructor Details
-
MessageDigestResourceVersion
public MessageDigestResourceVersion()create an instance of the message digest resource version provider using algorithm "MD5" -
MessageDigestResourceVersion
create an instance of the message digest resource version provider using the specified algorithm. The algorithm name must be one that can be retrieved by Java Cryptography Architecture (JCA) usingMessageDigest.getInstance(String)
. For digest computation an internal buffer of up to 8192 bytes will be used.- Parameters:
algorithm
- digest algorithm- See Also:
-
MessageDigestResourceVersion
create an instance of the message digest resource version provider using the specified algorithm. The algorithm name must be one that can be retrieved by Java Cryptography Architecture (JCA) usingMessageDigest.getInstance(String)
. For digest computation an internal buffer with a maximum size specified by parameterbufferSize
will be used.- Parameters:
algorithm
- digest algorithmbufferSize
- maximum size for internal buffer
-
-
Method Details
-
getVersion
Description copied from interface:IResourceVersion
get unique string identifying the version of the resource- Specified by:
getVersion
in interfaceIResourceVersion
- Parameters:
resource
- cacheable resource- Returns:
- unique version string or
null
if version string could not be calculated
-
getVersionPattern
Description copied from interface:IResourceVersion
a pattern that matches returned versions- Specified by:
getVersionPattern
in interfaceIResourceVersion
- Returns:
- a pattern or
null
if no pattern is available
-
getMessageDigest
get instance of message digest provider from JCA- Returns:
- message digest provider
-
computeDigest
compute digest for resource stream- Parameters:
inputStream
- input stream to compute message digest for- Returns:
- binary message digest
- Throws:
IOException
-