Class ClassLoaderWeavingAdaptor
java.lang.Object
org.aspectj.weaver.tools.WeavingAdaptor
org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor
- All Implemented Interfaces:
IMessageContext
- Author:
- Alexandre Vasseur, Andy Clement, Abraham Nevado, David Knibb, John Kew
-
Nested Class Summary
Nested classes/interfaces inherited from class WeavingAdaptor
WeavingAdaptor.WeavingAdaptorMessageHolder, WeavingAdaptor.WeavingAdaptorMessageWriterModifier and TypeClassDescriptionprotected classProcesses messages arising from weaver operations.protected class -
Field Summary
Fields inherited from class WeavingAdaptor
activeProtectionDomain, bcelWorld, cache, delegateForCurrentClass, generatedClasses, generatedClassHandler, SHOW_WEAVE_INFO_PROPERTY, TRACE_MESSAGES_PROPERTY, verbose, weaver, WEAVING_ADAPTOR_VERBOSEModifier and TypeFieldDescriptionprotected ProtectionDomainprotected BcelWorldprotected WeavedClassCacheprotected Map<String, IUnwovenClassFile> protected GeneratedClassHandlerstatic final Stringstatic final Stringprotected booleanprotected BcelWeaverstatic final StringSystem property used to turn on verbose weaving messages -
Constructor Summary
ConstructorsConstructorDescriptionClassLoaderWeavingAdaptor(ClassLoader deprecatedLoader, IWeavingContext deprecatedContext) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanDetermine whether a type should be accepted for weaving, by checking it against any includes/excludes.static MethodHandlecreateMethodHandle(Method method) static MethodHandlecreateMethodHandle(Method method, boolean setAccessible) static MethodHandlecreateMethodHandle(String className, String methodName, Class<?>... argumentTypes) protected voiddefineClass(ClassLoader loader, String name, byte[] bytes) protected voiddefineClass(ClassLoader loader, String name, byte[] bytes, ProtectionDomain protectionDomain) voidFlush the generated classes cachevoidflushGeneratedClassesFor(String className) Remove generated classes based on the supplied className.booleangeneratedClassesExistFor(String className) Check to see if any classes are stored in the generated classes cache.protected Stringvoidinitialize(ClassLoader classLoader, IWeavingContext context) protected voidprotected booleanshouldDump(String className, boolean before) Methods inherited from class WeavingAdaptor
addURL, createMessageHandler, debug, disable, dump, enable, ensureDelegateInitialized, error, error, getFullClassPath, getMessageHandler, getMessageHolder, info, initializeCache, isEnabled, setActiveProtectionDomain, setMessageHandler, warn, warn, weaveClass, weaveClassModifier and TypeMethodDescriptionvoidAppends URL to path used by the WeavingAdptor to resolve classesprotected voidprotected booleanprotected voiddisable()protected voidDump the given bytcode in _dump/...protected voidenable()protected voidensureDelegateInitialized(String name, byte[] bytes) protected booleanprotected booleangetFullClassPath(ClassLoader loader) protected IMessageHandlerprotected booleanprotected voidinitializeCache(ClassLoader loader, List<String> aspects, GeneratedClassHandler existingClassHandler, IMessageHandler myMessageHandler) If the cache is enabled, initialize it and swap out the existing classhandler for the caching one -protected booleanvoidsetActiveProtectionDomain(ProtectionDomain protectionDomain) protected voidprotected booleanprotected booleanbyte[]weaveClass(String name, byte[] bytes) Weave a class using aspects previously supplied to the adaptor.byte[]weaveClass(String name, byte[] bytes, boolean mustWeave) Weave a class using aspects previously supplied to the adaptor.
-
Constructor Details
-
ClassLoaderWeavingAdaptor
public ClassLoaderWeavingAdaptor() -
ClassLoaderWeavingAdaptor
@Deprecated public ClassLoaderWeavingAdaptor(ClassLoader deprecatedLoader, IWeavingContext deprecatedContext) Deprecated.We don't need a reference to the class loader and using it during construction can cause problems with recursion. It also makes sense to supply the weaving context during initialization to.
-
-
Method Details
-
initialize
-
lint
-
getContextId
- Specified by:
getContextIdin interfaceIMessageContext- Overrides:
getContextIdin classWeavingAdaptor
-
accept
Determine whether a type should be accepted for weaving, by checking it against any includes/excludes.- Overrides:
acceptin classWeavingAdaptor- Parameters:
className- the name of the type to possibly acceptbytes- the bytecode for the type (in case we need to look inside, eg. annotations)- Returns:
- true if it should be accepted for weaving
-
shouldDump
- Overrides:
shouldDumpin classWeavingAdaptor
-
getDumpDir
- Overrides:
getDumpDirin classWeavingAdaptor- Returns:
- the directory in which to dump - default is _ajdump but it
-
getNamespace
- Returns:
- Returns the key.
-
generatedClassesExistFor
Check to see if any classes are stored in the generated classes cache. Then flush the cache if it is not empty- Parameters:
className- TODO- Returns:
- true if a class has been generated and is stored in the cache
-
flushGeneratedClasses
public void flushGeneratedClasses()Flush the generated classes cache -
flushGeneratedClassesFor
Remove generated classes based on the supplied className. This will remove any entries related to this name - so the class itself plus and inner classes.- Parameters:
className- a slashed classname (e.g. com/foo/Bar)
-
createMethodHandle
public static MethodHandle createMethodHandle(String className, String methodName, Class<?>... argumentTypes) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException -
createMethodHandle
- Throws:
IllegalAccessException
-
createMethodHandle
public static MethodHandle createMethodHandle(Method method, boolean setAccessible) throws IllegalAccessException - Throws:
IllegalAccessException
-
defineClass
-
defineClass
protected void defineClass(ClassLoader loader, String name, byte[] bytes, ProtectionDomain protectionDomain)
-