Package org.aspectj.weaver.tools.cache
Class DefaultCacheKeyResolver
java.lang.Object
org.aspectj.weaver.tools.cache.DefaultCacheKeyResolver
- All Implemented Interfaces:
CacheKeyResolver
Naive default class and classloader hashing implementation useful
for some multi-classloader environments.
This implementation creates classloader scopes of the form:
"ExampleClassLoaderName.[crc hash]"
And weaved class keys of the form:
"com.foo.BarClassName.[bytes len][crc].weaved"
And generated class keys of the form:
"com.foo.BarClassName$AjClosure.generated
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateClassLoaderScope(ClassLoader cl, List<String> aspects)
Create a scope from a set of urls and aspect urls.generatedKey(String className)
Create a key for the given className from a class generated by the weaver such that:Return a regex which matches all generated keysReturn a regex which matches all weaved keys;keyToClass(String key)
Converts a cache key back to a classNameCreate a key for the given class name and byte array from the pre-weaved class such that
-
Field Details
-
GENERATED_SUFFIX
- See Also:
- Constant Field Values
-
WEAVED_SUFFIX
- See Also:
- Constant Field Values
-
-
Constructor Details
-
DefaultCacheKeyResolver
public DefaultCacheKeyResolver()
-
-
Method Details
-
createClassLoaderScope
Create a scope from a set of urls and aspect urls. Creates scope of the form "ExampleClassLoaderName.[md5sum]" or "ExampleClassLoaderName.[crc]"- Specified by:
createClassLoaderScope
in interfaceCacheKeyResolver
- Parameters:
cl
- the classloader which uses the cache, can be nullaspects
- the aspects- Returns:
- a unique string for URLClassloaders, otherwise a non-unique classname
-
getGeneratedRegex
Description copied from interface:CacheKeyResolver
Return a regex which matches all generated keys- Specified by:
getGeneratedRegex
in interfaceCacheKeyResolver
- Returns:
- string regex
-
getWeavedRegex
Description copied from interface:CacheKeyResolver
Return a regex which matches all weaved keys;- Specified by:
getWeavedRegex
in interfaceCacheKeyResolver
- Returns:
- string regex
-
keyToClass
Converts a cache key back to a className- Specified by:
keyToClass
in interfaceCacheKeyResolver
- Parameters:
key
- to convert- Returns:
- className, e.g. "com.foo.Bar"
-
weavedKey
Description copied from interface:CacheKeyResolver
Create a key for the given class name and byte array from the pre-weaved class such thatclassName == keyToClass(weavedKey(className, various_bytes)) holds and weavedKey(className, various_bytes).matches(getWeavedRegex()) == true
- Specified by:
weavedKey
in interfaceCacheKeyResolver
- Parameters:
className
- class to create a key fororiginal_bytes
- bytes of the pre-weaved class- Returns:
- key for the class, or null if no caching should be performed
-
generatedKey
Description copied from interface:CacheKeyResolver
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
- Specified by:
generatedKey
in interfaceCacheKeyResolver
- Parameters:
className
- class to create a key for- Returns:
- key for the class, or null if no caching should be performed
-