org.apache.wicket.request.resource.caching.version
Class MessageDigestResourceVersion

java.lang.Object
  extended by 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 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
MessageDigestResourceVersion()
          create an instance of the message digest resource version provider using algorithm
MessageDigestResourceVersion(java.lang.String algorithm)
          create an instance of the message digest resource version provider using the specified algorithm.
MessageDigestResourceVersion(java.lang.String algorithm, Bytes bufferSize)
          create an instance of the message digest resource version provider using the specified algorithm.
 
Method Summary
protected  byte[] computeDigest(java.io.InputStream inputStream)
          compute digest for resource stream
protected  java.security.MessageDigest getMessageDigest()
          get instance of message digest provider from JCA
 java.lang.String getVersion(IStaticCacheableResource resource)
          get unique string identifying the version of the resource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageDigestResourceVersion

public MessageDigestResourceVersion()
create an instance of the message digest resource version provider using algorithm

See Also:
MessageDigestResourceVersion(String), MessageDigestResourceVersion(String, org.apache.wicket.util.lang.Bytes)

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) using MessageDigest.getInstance(String). For digest computation an internal buffer of up to 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,
                                    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) using MessageDigest.getInstance(String). For digest computation an internal buffer with a maximum size specified by parameter bufferSize will be used.

Parameters:
algorithm - digest algorithm
bufferSize - 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 interface IResourceVersion
Parameters:
resource - cacheable resource
Returns:
unique version string or null if version string could not be calculated

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:
ResourceStreamNotFoundException
java.io.IOException


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.