Class DefaultContextLoadTimeWeaver
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,DisposableBean
,LoadTimeWeaver
LoadTimeWeaver
bean for use in an application context,
decorating an automatically detected internal LoadTimeWeaver
.
Typically registered for the default bean name "loadTimeWeaver
";
the most convenient way to achieve this is Spring's
<context:load-time-weaver>
XML tag or @EnableLoadTimeWeaving
on a @Configuration
class.
This class implements a runtime environment check for obtaining the
appropriate weaver implementation, including
Spring's VM agent
and any ClassLoader
supported by Spring's ReflectiveLoadTimeWeaver
.
- Since:
- 2.5
- Author:
- Juergen Hoeller, Ramnivas Laddad, Costin Leau
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTransformer
(ClassFileTransformer transformer) Add aClassFileTransformer
to be applied by thisLoadTimeWeaver
.protected LoadTimeWeaver
createServerSpecificLoadTimeWeaver
(ClassLoader classLoader) void
destroy()
Invoked by the containingBeanFactory
on destruction of a bean.Return aClassLoader
that supports instrumentation through AspectJ-style load-time weaving based on user-definedClassFileTransformers
.Return a throwawayClassLoader
, enabling classes to be loaded and inspected without affecting the parentClassLoader
.void
setBeanClassLoader
(ClassLoader classLoader) Callback that supplies the beanclass loader
to a bean instance.
-
Field Details
-
logger
-
-
Constructor Details
-
DefaultContextLoadTimeWeaver
public DefaultContextLoadTimeWeaver() -
DefaultContextLoadTimeWeaver
-
-
Method Details
-
setBeanClassLoader
Description copied from interface:BeanClassLoaderAware
Callback that supplies the beanclass 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.- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
- Parameters:
classLoader
- the owning class loader
-
createServerSpecificLoadTimeWeaver
-
destroy
public void destroy()Description copied from interface:DisposableBean
Invoked by the containingBeanFactory
on destruction of a bean.- Specified by:
destroy
in interfaceDisposableBean
-
addTransformer
Description copied from interface:LoadTimeWeaver
Add aClassFileTransformer
to be applied by thisLoadTimeWeaver
.- Specified by:
addTransformer
in interfaceLoadTimeWeaver
- Parameters:
transformer
- theClassFileTransformer
to add
-
getInstrumentableClassLoader
Description copied from interface:LoadTimeWeaver
Return aClassLoader
that supports instrumentation through AspectJ-style load-time weaving based on user-definedClassFileTransformers
.May be the current
ClassLoader
, or aClassLoader
created by thisLoadTimeWeaver
instance.- Specified by:
getInstrumentableClassLoader
in interfaceLoadTimeWeaver
- Returns:
- the
ClassLoader
which will expose instrumented classes according to the registered transformers
-
getThrowawayClassLoader
Description copied from interface:LoadTimeWeaver
Return a throwawayClassLoader
, enabling classes to be loaded and inspected without affecting the parentClassLoader
.Should not return the same instance of the
ClassLoader
returned from an invocation ofLoadTimeWeaver.getInstrumentableClassLoader()
.- Specified by:
getThrowawayClassLoader
in interfaceLoadTimeWeaver
- Returns:
- a temporary throwaway
ClassLoader
; should return a new instance for each call, with no existing state
-