org.aspectj.weaver.tools.cache
Interface CacheKeyResolver

All Known Implementing Classes:
DefaultCacheKeyResolver

public interface CacheKeyResolver

Interface to allow alternate hashing schemes for weaved and generated classes. While the DefaultCacheKeyResolver may be a reasonable naive implementation, the management and invalidation of the cache may be more usefully accomplished at the Application or Container level.

The key is not a one-way hash; it must be convertible back to a className and must match the regex for the type of key it is (generated or weaved).


Method Summary
 java.lang.String createClassLoaderScope(java.lang.ClassLoader loader, java.util.List<java.lang.String> aspects)
          Create a unique string for the given classpath and aspect list
 CachedClassReference generatedKey(java.lang.String className)
          Create a key for the given className from a class generated by the weaver such that:
 java.lang.String getGeneratedRegex()
          Return a regex which matches all generated keys
 java.lang.String getWeavedRegex()
          Return a regex which matches all weaved keys;
 java.lang.String keyToClass(java.lang.String key)
          Convert a key back to a className
 CachedClassReference weavedKey(java.lang.String className, byte[] original_bytes)
          Create a key for the given class name and byte array from the pre-weaved class such that
 

Method Detail

generatedKey

CachedClassReference generatedKey(java.lang.String className)
Create a key for the given className from a class generated by the weaver such that:
    className == keyToClass(generatedKey(className)) holds
 and
    generatedKey(className).matches(getGeneratedRegex()) == true
 

Parameters:
className - class to create a key for
Returns:
key for the class, or null if no caching should be performed

weavedKey

CachedClassReference weavedKey(java.lang.String className,
                               byte[] original_bytes)
Create a key for the given class name and byte array from the pre-weaved class such that
    className == keyToClass(weavedKey(className, various_bytes)) holds
 and
    weavedKey(className, various_bytes).matches(getWeavedRegex()) == true
 

Parameters:
className - class to create a key for
original_bytes - bytes of the pre-weaved class
Returns:
key for the class, or null if no caching should be performed

keyToClass

java.lang.String keyToClass(java.lang.String key)
Convert a key back to a className

Parameters:
key - cache key
Returns:
className

createClassLoaderScope

java.lang.String createClassLoaderScope(java.lang.ClassLoader loader,
                                        java.util.List<java.lang.String> aspects)
Create a unique string for the given classpath and aspect list

Parameters:
loader - Classloader for this adapter
aspects - list of aspects; either urls or class names handled by this adapter
Returns:
scope, or null, if no caching should be performed for this classloader

getGeneratedRegex

java.lang.String getGeneratedRegex()
Return a regex which matches all generated keys

Returns:
string regex

getWeavedRegex

java.lang.String getWeavedRegex()
Return a regex which matches all weaved keys;

Returns:
string regex