Class DefaultCacheKeyResolver

java.lang.Object
org.aspectj.weaver.tools.cache.DefaultCacheKeyResolver
All Implemented Interfaces:
CacheKeyResolver

public class DefaultCacheKeyResolver extends Object implements 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 Details

  • Constructor Details

    • DefaultCacheKeyResolver

      public DefaultCacheKeyResolver()
  • Method Details

    • createClassLoaderScope

      public String createClassLoaderScope(ClassLoader cl, List<String> aspects)
      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 interface CacheKeyResolver
      Parameters:
      cl - the classloader which uses the cache, can be null
      aspects - the aspects
      Returns:
      a unique string for URLClassloaders, otherwise a non-unique classname
    • getGeneratedRegex

      public String getGeneratedRegex()
      Description copied from interface: CacheKeyResolver
      Return a regex which matches all generated keys
      Specified by:
      getGeneratedRegex in interface CacheKeyResolver
      Returns:
      string regex
    • getWeavedRegex

      public String getWeavedRegex()
      Description copied from interface: CacheKeyResolver
      Return a regex which matches all weaved keys;
      Specified by:
      getWeavedRegex in interface CacheKeyResolver
      Returns:
      string regex
    • keyToClass

      public String keyToClass(String key)
      Converts a cache key back to a className
      Specified by:
      keyToClass in interface CacheKeyResolver
      Parameters:
      key - to convert
      Returns:
      className, e.g. "com.foo.Bar"
    • weavedKey

      public CachedClassReference weavedKey(String className, byte[] original_bytes)
      Description copied from interface: CacheKeyResolver
      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
       
      Specified by:
      weavedKey in interface CacheKeyResolver
      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
    • generatedKey

      public CachedClassReference generatedKey(String className)
      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 interface CacheKeyResolver
      Parameters:
      className - class to create a key for
      Returns:
      key for the class, or null if no caching should be performed