com.googlecode.ehcache.annotations.key
Class MessageDigestCacheKeyGenerator

java.lang.Object
  extended by com.googlecode.ehcache.annotations.key.AbstractCacheKeyGenerator<T>
      extended by com.googlecode.ehcache.annotations.key.AbstractDeepCacheKeyGenerator<G,T>
          extended by com.googlecode.ehcache.annotations.key.AbstractHashingCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>
              extended by com.googlecode.ehcache.annotations.key.MessageDigestCacheKeyGenerator
All Implemented Interfaces:
CacheKeyGenerator<java.lang.String>, ReflectionHelperAware

public class MessageDigestCacheKeyGenerator
extends AbstractHashingCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

Version:
$Revision: 656 $
Author:
Eric Dalquist

Field Summary
static java.lang.String DEFAULT_ALGORITHM
           
static java.lang.String DEFAULT_BEAN_NAME
          Name of the bean this generator is registered under using the default constructor.
protected static int DEFAULT_BYTE_BUFFER_SIZE
           
protected  org.slf4j.Logger logger
           
 
Constructor Summary
MessageDigestCacheKeyGenerator()
          Uses DEFAULT_ALGORITHM for the algorithm
MessageDigestCacheKeyGenerator(boolean includeMethod, boolean includeParameterTypes)
          Uses DEFAULT_ALGORITHM for the algorithm
MessageDigestCacheKeyGenerator(java.lang.String algorithm)
           
MessageDigestCacheKeyGenerator(java.lang.String algorithm, boolean includeMethod, boolean includeParameterTypes)
           
 
Method Summary
protected  void append(MessageDigestOutputStream generator, boolean[] a)
          Append a boolean array.
protected  void append(MessageDigestOutputStream generator, byte[] a)
          Append a byte array.
protected  void append(MessageDigestOutputStream generator, char[] a)
          Append a char array.
protected  void append(MessageDigestOutputStream generator, double[] a)
          Append a double array.
protected  void append(MessageDigestOutputStream generator, float[] a)
          Append a float array.
protected  void append(MessageDigestOutputStream generator, int[] a)
          Append a int array.
protected  void append(MessageDigestOutputStream generator, long[] a)
          Append a long array.
protected  void append(MessageDigestOutputStream generator, short[] a)
          Append a short array.
protected  void appendGraphCycle(MessageDigestOutputStream generator, java.lang.Object o)
          Called if a graph cycle is detected.
protected  void appendHash(MessageDigestOutputStream generator, java.lang.Object e)
           
protected  void appendNull(MessageDigestOutputStream generator)
          Called if a null value is found in the object graph
protected  java.lang.String encodeHash(byte[] digest)
          Encode the digested hash bytes as a String
 java.lang.String generateKey(MessageDigestOutputStream generator)
          Generate the cache key from the generator
 MessageDigestOutputStream getGenerator(java.lang.Object... data)
          Create the object used to generate the key.
protected  java.security.MessageDigest getMessageDigest()
          Tries to clone the MessageDigest that was created during construction.
 
Methods inherited from class com.googlecode.ehcache.annotations.key.AbstractHashingCacheKeyGenerator
append, appendClass, appendEnum, shouldReflect
 
Methods inherited from class com.googlecode.ehcache.annotations.key.AbstractDeepCacheKeyGenerator
beginRecursion, deepHashCode, deepHashCode, deepHashCode, deepHashCode, endRecursion, generateKey, getReflectionHelper, isUseReflection, reflectionDeepHashCode, setReflectionHelper, setUseReflection, toString
 
Methods inherited from class com.googlecode.ehcache.annotations.key.AbstractCacheKeyGenerator
generateKey, isCheckforCycles, isIncludeMethod, isIncludeParameterTypes, register, setCheckforCycles, setIncludeMethod, setIncludeParameterTypes, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_BEAN_NAME

public static final java.lang.String DEFAULT_BEAN_NAME
Name of the bean this generator is registered under using the default constructor.

See Also:
Constant Field Values

DEFAULT_ALGORITHM

public static final java.lang.String DEFAULT_ALGORITHM
See Also:
Constant Field Values

DEFAULT_BYTE_BUFFER_SIZE

protected static final int DEFAULT_BYTE_BUFFER_SIZE
See Also:
Constant Field Values

logger

protected final org.slf4j.Logger logger
Constructor Detail

MessageDigestCacheKeyGenerator

public MessageDigestCacheKeyGenerator()
                               throws java.security.NoSuchAlgorithmException
Uses DEFAULT_ALGORITHM for the algorithm

Throws:
java.security.NoSuchAlgorithmException
See Also:
AbstractCacheKeyGenerator.AbstractCacheKeyGenerator()

MessageDigestCacheKeyGenerator

public MessageDigestCacheKeyGenerator(java.lang.String algorithm)
                               throws java.security.NoSuchAlgorithmException
Throws:
java.security.NoSuchAlgorithmException
See Also:
AbstractCacheKeyGenerator.AbstractCacheKeyGenerator()

MessageDigestCacheKeyGenerator

public MessageDigestCacheKeyGenerator(boolean includeMethod,
                                      boolean includeParameterTypes)
                               throws java.security.NoSuchAlgorithmException
Uses DEFAULT_ALGORITHM for the algorithm

Throws:
java.security.NoSuchAlgorithmException
See Also:
AbstractCacheKeyGenerator.AbstractCacheKeyGenerator(boolean, boolean)

MessageDigestCacheKeyGenerator

public MessageDigestCacheKeyGenerator(java.lang.String algorithm,
                                      boolean includeMethod,
                                      boolean includeParameterTypes)
                               throws java.security.NoSuchAlgorithmException
Throws:
java.security.NoSuchAlgorithmException
See Also:
AbstractCacheKeyGenerator.AbstractCacheKeyGenerator(boolean, boolean)
Method Detail

getGenerator

public MessageDigestOutputStream getGenerator(java.lang.Object... data)
Description copied from class: AbstractDeepCacheKeyGenerator
Create the object used to generate the key. This object is passed into every AbstractDeepCacheKeyGenerator.deepHashCode(G, java.lang.Object[]) and AbstractDeepCacheKeyGenerator.append(G, java.lang.Object) call.

Specified by:
getGenerator in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

generateKey

public java.lang.String generateKey(MessageDigestOutputStream generator)
Description copied from class: AbstractDeepCacheKeyGenerator
Generate the cache key from the generator

Specified by:
generateKey in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

encodeHash

protected java.lang.String encodeHash(byte[] digest)
Encode the digested hash bytes as a String


getMessageDigest

protected java.security.MessageDigest getMessageDigest()
Tries to clone the MessageDigest that was created during construction. If the clone fails that is remembered and from that point on new MessageDigest instances will be created on every call.

Returns:
Generates a MessageDigest to use during a call to AbstractDeepCacheKeyGenerator.generateKey(Object...)

append

protected void append(MessageDigestOutputStream generator,
                      boolean[] a)
Description copied from class: AbstractDeepCacheKeyGenerator
Append a boolean array. Calls AbstractDeepCacheKeyGenerator.append(Object, Object) on each value in the array. If the implementing class can handle boolean or boolean array primitives directly this should be overridden to avoid auto-boxing each array element.

Overrides:
append in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

append

protected void append(MessageDigestOutputStream generator,
                      byte[] a)
Description copied from class: AbstractDeepCacheKeyGenerator
Append a byte array. Calls AbstractDeepCacheKeyGenerator.append(Object, Object) on each value in the array. If the implementing class can handle byte or byte array primitives directly this should be overridden to avoid auto-boxing each array element.

Overrides:
append in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

append

protected void append(MessageDigestOutputStream generator,
                      char[] a)
Description copied from class: AbstractDeepCacheKeyGenerator
Append a char array. Calls AbstractDeepCacheKeyGenerator.append(Object, Object) on each value in the array. If the implementing class can handle char or char array primitives directly this should be overridden to avoid auto-boxing each array element.

Overrides:
append in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

append

protected void append(MessageDigestOutputStream generator,
                      double[] a)
Description copied from class: AbstractDeepCacheKeyGenerator
Append a double array. Calls AbstractDeepCacheKeyGenerator.append(Object, Object) on each value in the array. If the implementing class can handle double or double array primitives directly this should be overridden to avoid auto-boxing each array element.

Overrides:
append in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

append

protected void append(MessageDigestOutputStream generator,
                      float[] a)
Description copied from class: AbstractDeepCacheKeyGenerator
Append a float array. Calls AbstractDeepCacheKeyGenerator.append(Object, Object) on each value in the array. If the implementing class can handle float or float array primitives directly this should be overridden to avoid auto-boxing each array element.

Overrides:
append in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

append

protected void append(MessageDigestOutputStream generator,
                      int[] a)
Description copied from class: AbstractDeepCacheKeyGenerator
Append a int array. Calls AbstractDeepCacheKeyGenerator.append(Object, Object) on each value in the array. If the implementing class can handle int or int array primitives directly this should be overridden to avoid auto-boxing each array element.

Overrides:
append in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

append

protected void append(MessageDigestOutputStream generator,
                      long[] a)
Description copied from class: AbstractDeepCacheKeyGenerator
Append a long array. Calls AbstractDeepCacheKeyGenerator.append(Object, Object) on each value in the array. If the implementing class can handle long or long array primitives directly this should be overridden to avoid auto-boxing each array element.

Overrides:
append in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

append

protected void append(MessageDigestOutputStream generator,
                      short[] a)
Description copied from class: AbstractDeepCacheKeyGenerator
Append a short array. Calls AbstractDeepCacheKeyGenerator.append(Object, Object) on each value in the array. If the implementing class can handle short or short array primitives directly this should be overridden to avoid auto-boxing each array element.

Overrides:
append in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

appendGraphCycle

protected void appendGraphCycle(MessageDigestOutputStream generator,
                                java.lang.Object o)
Description copied from class: AbstractDeepCacheKeyGenerator
Called if a graph cycle is detected.

Specified by:
appendGraphCycle in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>
o - The object that started the cycle

appendNull

protected void appendNull(MessageDigestOutputStream generator)
Description copied from class: AbstractDeepCacheKeyGenerator
Called if a null value is found in the object graph

Specified by:
appendNull in class AbstractDeepCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>

appendHash

protected void appendHash(MessageDigestOutputStream generator,
                          java.lang.Object e)
Specified by:
appendHash in class AbstractHashingCacheKeyGenerator<MessageDigestOutputStream,java.lang.String>


Copyright © 2011. All Rights Reserved.