Class MessageDigestResourceVersion
- java.lang.Object
-
- org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion
-
- All Implemented Interfaces:
IResourceVersion
public class MessageDigestResourceVersion extends java.lang.Object implements IResourceVersion
computes the message digest of aIStaticCacheableResource
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
Constructors Constructor Description MessageDigestResourceVersion()
create an instance of the message digest resource version provider using algorithm "MD5"MessageDigestResourceVersion(java.lang.String algorithm)
create an instance of the message digest resource version provider using the specified algorithm.MessageDigestResourceVersion(java.lang.String algorithm, org.apache.wicket.util.lang.Bytes bufferSize)
create an instance of the message digest resource version provider using the specified algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
computeDigest(java.io.InputStream inputStream)
compute digest for resource streamprotected java.security.MessageDigest
getMessageDigest()
get instance of message digest provider from JCAjava.lang.String
getVersion(IStaticCacheableResource resource)
get unique string identifying the version of the resourcejava.util.regex.Pattern
getVersionPattern()
a pattern that matches returned versions
-
-
-
Constructor Detail
-
MessageDigestResourceVersion
public MessageDigestResourceVersion()
create an instance of the message digest resource version provider using algorithm "MD5"
-
MessageDigestResourceVersion
public MessageDigestResourceVersion(java.lang.String algorithm)
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()
,MessageDigestResourceVersion(String, org.apache.wicket.util.lang.Bytes)
-
MessageDigestResourceVersion
public MessageDigestResourceVersion(java.lang.String algorithm, org.apache.wicket.util.lang.Bytes bufferSize)
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 Detail
-
getVersion
public java.lang.String getVersion(IStaticCacheableResource resource)
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
public java.util.regex.Pattern 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
protected java.security.MessageDigest getMessageDigest()
get instance of message digest provider from JCA- Returns:
- message digest provider
-
computeDigest
protected byte[] computeDigest(java.io.InputStream inputStream) throws java.io.IOException
compute digest for resource stream- Parameters:
inputStream
- input stream to compute message digest for- Returns:
- binary message digest
- Throws:
org.apache.wicket.util.resource.ResourceStreamNotFoundException
java.io.IOException
-
-