Top Description Inners Fields Constructors Methods
org.springframework.context.weaving

public Class AspectJWeavingEnabler

extends Object
implements BeanFactoryPostProcessor, BeanClassLoaderAware, LoadTimeWeaverAware, Ordered
Class Inheritance
All Implemented Interfaces
org.springframework.core.Ordered, org.springframework.context.weaving.LoadTimeWeaverAware, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.config.BeanFactoryPostProcessor
Imports
java.lang.instrument.ClassFileTransformer, .IllegalClassFormatException, java.security.ProtectionDomain, org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter, org.springframework.beans.BeansException, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.config.BeanFactoryPostProcessor, .ConfigurableListableBeanFactory, org.springframework.core.Ordered, org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver, .LoadTimeWeaver, org.springframework.lang.Nullable

Post-processor that registers AspectJ's org.aspectj.weaver.loadtime.ClassPreProcessorAgentAdapter with the Spring application context's default org.springframework.instrument.classloading.LoadTimeWeaver.
Authors
Juergen Hoeller, Ramnivas Laddad
Since
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
AspectJWeavingEnabler.AspectJClassBypassingClassFileTransformer

ClassFileTransformer decorator that suppresses processing of AspectJ classes in order to avoid potential LinkageErrors.

Field Summary

Modifier and TypeField and Description
public static final String
ASPECTJ_AOP_XML_RESOURCE

The aop.xml resource location.

private ClassLoader
private LoadTimeWeaver

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
enableAspectJWeaving(LoadTimeWeaver
the LoadTimeWeaver to apply to (or null for a default weaver)
weaverToUse
,
ClassLoader
the class loader to create a default weaver for (if necessary)
beanClassLoader
)

Enable AspectJ weaving with the given LoadTimeWeaver.

public int
getOrder()

Implements org.springframework.core.Ordered.getOrder.

Get the order value of this object.
public void
postProcessBeanFactory(ConfigurableListableBeanFactory
the bean factory used by the application context
beanFactory
)

Implements org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

Modify the application context's internal bean factory after its standard initialization.
public void
setBeanClassLoader(ClassLoader
the owning class loader
classLoader
)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class loader to a bean instance.
public void
setLoadTimeWeaver(LoadTimeWeaver
the LoadTimeWeaver instance (never null)
loadTimeWeaver
)

Implements org.springframework.context.weaving.LoadTimeWeaverAware.setLoadTimeWeaver.

Set the LoadTimeWeaver of this object's containing ApplicationContext.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ASPECTJ_AOP_XML_RESOURCEback to summary
public static final String ASPECTJ_AOP_XML_RESOURCE

The aop.xml resource location.

beanClassLoaderback to summary
private ClassLoader beanClassLoader
Annotations
@Nullable
loadTimeWeaverback to summary
private LoadTimeWeaver loadTimeWeaver
Annotations
@Nullable

Constructor Detail

AspectJWeavingEnablerback to summary
public AspectJWeavingEnabler()

Method Detail

enableAspectJWeavingback to summary
public static void enableAspectJWeaving(LoadTimeWeaver weaverToUse, ClassLoader beanClassLoader)

Enable AspectJ weaving with the given LoadTimeWeaver.

Parameters
weaverToUse:LoadTimeWeaver

the LoadTimeWeaver to apply to (or null for a default weaver)

beanClassLoader:ClassLoader

the class loader to create a default weaver for (if necessary)

getOrderback to summary
public int getOrder()

Implements org.springframework.core.Ordered.getOrder.

Doc from org.springframework.core.Ordered.getOrder.

Get the order value of this object.

Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet load-on-startup values).

Same order values will result in arbitrary sort positions for the affected objects.

Returns:int

the order value

Annotations
@Override
postProcessBeanFactoryback to summary
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException

Implements org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

Doc from org.springframework.beans.factory.config.BeanFactoryPostProcessor.postProcessBeanFactory.

Modify the application context's internal bean factory after its standard initialization. All bean definitions will have been loaded, but no beans will have been instantiated yet. This allows for overriding or adding properties even to eager-initializing beans.

Parameters
beanFactory:ConfigurableListableBeanFactory

the bean factory used by the application context

Annotations
@Override
Exceptions
BeansException:
in case of errors
setBeanClassLoaderback to summary
public void setBeanClassLoader(ClassLoader classLoader)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Doc from org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class loader to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's InitializingBean#afterPropertiesSet() method or a custom init-method.

Parameters
classLoader:ClassLoader

the owning class loader

Annotations
@Override
setLoadTimeWeaverback to summary
public void setLoadTimeWeaver(LoadTimeWeaver loadTimeWeaver)

Implements org.springframework.context.weaving.LoadTimeWeaverAware.setLoadTimeWeaver.

Doc from org.springframework.context.weaving.LoadTimeWeaverAware.setLoadTimeWeaver.

Set the LoadTimeWeaver of this object's containing ApplicationContext.

Invoked after the population of normal bean properties but before an initialization callback like InitializingBean's afterPropertiesSet() or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext(..).

Note

This method will only be called if there actually is a LoadTimeWeaver available in the application context. If there is none, the method will simply not get invoked, assuming that the implementing object is able to activate its weaving dependency accordingly.

Parameters
loadTimeWeaver:LoadTimeWeaver

the LoadTimeWeaver instance (never null)

Annotations
@Override
org.springframework.context.weaving back to summary

private Class AspectJWeavingEnabler.AspectJClassBypassingClassFileTransformer

extends Object
implements ClassFileTransformer
Class Inheritance
  • java.lang.Object
  • org.springframework.context.weaving.AspectJWeavingEnabler.AspectJClassBypassingClassFileTransformer
All Implemented Interfaces
java.lang.instrument.ClassFileTransformer

ClassFileTransformer decorator that suppresses processing of AspectJ classes in order to avoid potential LinkageErrors.
See Also
org.springframework.context.annotation.LoadTimeWeavingConfiguration

Field Summary

Modifier and TypeField and Description
private final ClassFileTransformer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public byte[]
transform(ClassLoader
the defining loader of the class to be transformed, may be null if the bootstrap loader
loader
,
String
the name of the class in the internal form of fully qualified class and interface names as defined in The Java Virtual Machine Specification. For example, "java/util/List".
className
,
Class<?>
if this is triggered by a redefine or retransform, the class being redefined or retransformed; if this is a class load, null
classBeingRedefined
,
ProtectionDomain
the protection domain of the class being defined or redefined
protectionDomain
,
byte[]
the input byte buffer in class file format - must not be modified
classfileBuffer
)

Overrides default java.lang.instrument.ClassFileTransformer.transform.

Transforms the given class file and returns a new replacement class file.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final ClassFileTransformer delegate

Constructor Detail

AspectJClassBypassingClassFileTransformerback to summary
public AspectJClassBypassingClassFileTransformer(ClassFileTransformer delegate)

Method Detail

transformback to summary
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException

Overrides default java.lang.instrument.ClassFileTransformer.transform.

Doc from java.lang.instrument.ClassFileTransformer.transform.

Transforms the given class file and returns a new replacement class file. This method is invoked when the Module bearing transform is not overridden.

Parameters
loader:ClassLoader

the defining loader of the class to be transformed, may be null if the bootstrap loader

className:String

the name of the class in the internal form of fully qualified class and interface names as defined in The Java Virtual Machine Specification. For example, "java/util/List".

classBeingRedefined:Class<?>

if this is triggered by a redefine or retransform, the class being redefined or retransformed; if this is a class load, null

protectionDomain:ProtectionDomain

the protection domain of the class being defined or redefined

classfileBuffer:byte[]

the input byte buffer in class file format - must not be modified

Returns:byte[]

a well-formed class file buffer (the result of the transform), or null if no transform is performed

Annotations
@Override
Exceptions
IllegalClassFormatException:
if the input does not represent a well-formed class file