Top Description Fields Constructors Methods
org.aspectj.weaver.tools.cache

public Class DefaultCacheKeyResolver

extends Object
implements CacheKeyResolver
Class Inheritance
All Implemented Interfaces
org.aspectj.weaver.tools.cache.CacheKeyResolver
Imports
java.net.URL, .URLClassLoader, java.util.Collections, .LinkedList, .List, java.util.zip.CRC32

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

Modifier and TypeField and Description
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private String
crc(byte[] input)

public String

Returns:

a unique string for URLClassloaders, otherwise a non-unique classname
createClassLoaderScope
(ClassLoader
the classloader which uses the cache, can be null
cl
,
List<String>
the aspects
aspects
)

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.createClassLoaderScope.

Create a scope from a set of urls and aspect urls.
public CachedClassReference
generatedKey(String
class to create a key for
className
)

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.generatedKey.

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
public String
getGeneratedRegex()

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.getGeneratedRegex.

Return a regex which matches all generated keys
public String
getWeavedRegex()

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.getWeavedRegex.

Return a regex which matches all weaved keys;
public String

Returns:

className, e.g. "com.foo.Bar"
keyToClass
(String
to convert
key
)

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.keyToClass.

Converts a cache key back to a className
public CachedClassReference
weavedKey(String
class to create a key for
className
,
byte[]
bytes of the pre-weaved class
original_bytes
)

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.weavedKey.

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
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

GENERATED_SUFFIXback to summary
public static final String GENERATED_SUFFIX
WEAVED_SUFFIXback to summary
public static final String WEAVED_SUFFIX

Constructor Detail

DefaultCacheKeyResolverback to summary
public DefaultCacheKeyResolver()

Method Detail

crcback to summary
private String crc(byte[] input)
createClassLoaderScopeback to summary
public String createClassLoaderScope(ClassLoader cl, List<String> aspects)

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.createClassLoaderScope.

Create a scope from a set of urls and aspect urls. Creates scope of the form "ExampleClassLoaderName.[md5sum]" or "ExampleClassLoaderName.[crc]"

Parameters
cl:ClassLoader

the classloader which uses the cache, can be null

aspects:List<String>

the aspects

Returns:String

a unique string for URLClassloaders, otherwise a non-unique classname

generatedKeyback to summary
public CachedClassReference generatedKey(String className)

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.generatedKey.

Doc from org.aspectj.weaver.tools.cache.CacheKeyResolver.generatedKey.

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:String

class to create a key for

Returns:CachedClassReference

key for the class, or null if no caching should be performed

getGeneratedRegexback to summary
public String getGeneratedRegex()

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.getGeneratedRegex.

Doc from org.aspectj.weaver.tools.cache.CacheKeyResolver.getGeneratedRegex.

Return a regex which matches all generated keys

Returns:String

string regex

getWeavedRegexback to summary
public String getWeavedRegex()

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.getWeavedRegex.

Doc from org.aspectj.weaver.tools.cache.CacheKeyResolver.getWeavedRegex.

Return a regex which matches all weaved keys;

Returns:String

string regex

keyToClassback to summary
public String keyToClass(String key)

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.keyToClass.

Converts a cache key back to a className

Parameters
key:String

to convert

Returns:String

className, e.g. "com.foo.Bar"

weavedKeyback to summary
public CachedClassReference weavedKey(String className, byte[] original_bytes)

Implements org.aspectj.weaver.tools.cache.CacheKeyResolver.weavedKey.

Doc from org.aspectj.weaver.tools.cache.CacheKeyResolver.weavedKey.

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:String

class to create a key for

original_bytes:byte[]

bytes of the pre-weaved class

Returns:CachedClassReference

key for the class, or null if no caching should be performed