Class MessageDigestResourceVersion
- java.lang.Object
-
- org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion
-
- All Implemented Interfaces:
IResourceVersion
public class MessageDigestResourceVersion extends 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(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]
computeDigest(InputStream inputStream)
compute digest for resource streamprotected MessageDigest
getMessageDigest()
get instance of message digest provider from JCAString
getVersion(IStaticCacheableResource resource)
get unique string identifying the version of the resourcePattern
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(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(String algorithm, 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 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 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 MessageDigest getMessageDigest()
get instance of message digest provider from JCA- Returns:
- message digest provider
-
computeDigest
protected byte[] computeDigest(InputStream inputStream) throws IOException
compute digest for resource stream- Parameters:
inputStream
- input stream to compute message digest for- Returns:
- binary message digest
- Throws:
IOException
-
-