Class 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

      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 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
      java.util.regex.Pattern getVersionPattern()
      a pattern that matches returned versions
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • 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 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) 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
      • getVersionPattern

        public java.util.regex.Pattern getVersionPattern()
        Description copied from interface: IResourceVersion
        a pattern that matches returned versions
        Specified by:
        getVersionPattern in interface IResourceVersion
        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