org.apache.tapestry.asset
Class ResourceChecksumSourceImpl

java.lang.Object
  extended by org.apache.tapestry.asset.ResourceChecksumSourceImpl
All Implemented Interfaces:
ResourceChecksumSource

public class ResourceChecksumSourceImpl
extends Object
implements ResourceChecksumSource

Implementation of org.apache.tapestry.asset.ResourceDigestSource that calculates an checksum using a message digest and configured encoder. This code is based on code from Howard Lewis Ship from the upcoming 3.1 release.

Since:
3.0.3
Author:
Paul Ferraro

Constructor Summary
ResourceChecksumSourceImpl(String digestAlgorithm, org.apache.commons.codec.BinaryEncoder encoder)
           
 
Method Summary
protected  String computeChecksum(URL resourceURL)
          Computes a message digest of the specified resource and encodes it into a string.
 String getChecksum(URL resourceURL)
          Checksum is obtained from cache if possible.
 void reset()
          Clears the internal cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceChecksumSourceImpl

public ResourceChecksumSourceImpl(String digestAlgorithm,
                                  org.apache.commons.codec.BinaryEncoder encoder)
Method Detail

getChecksum

public String getChecksum(URL resourceURL)
Checksum is obtained from cache if possible. If not, checksum is computed using computeChecksum(URL)

Specified by:
getChecksum in interface ResourceChecksumSource
Parameters:
resourceURL - the url of a resource
Returns:
the checksum value of the specified resource
See Also:
org.apache.tapestry.asset.ResourceDigestSource#getChecksum(java.net.URL)

reset

public void reset()
Description copied from interface: ResourceChecksumSource
Clears the internal cache.

Specified by:
reset in interface ResourceChecksumSource
See Also:
org.apache.tapestry.asset.ResourceDigestSource#reset()

computeChecksum

protected String computeChecksum(URL resourceURL)
Computes a message digest of the specified resource and encodes it into a string.

Parameters:
resourceURL - the url of a resource
Returns:
the checksum value of the specified resource