public class DefaultContextLoadTimeWeaver extends Object implements LoadTimeWeaver, BeanClassLoaderAware, DisposableBean
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.
This class implements a runtime environment check for obtaining the
appropriate weaver implementation: As of Spring Framework 5.0, it detects
Oracle WebLogic 10+, GlassFish 4+, Tomcat 8+, WildFly 8+, IBM WebSphere 8.5+,
Spring's VM agent
, and any ClassLoader
supported by Spring's ReflectiveLoadTimeWeaver
.
ConfigurableApplicationContext.LOAD_TIME_WEAVER_BEAN_NAME
Constructor and Description |
---|
DefaultContextLoadTimeWeaver() |
DefaultContextLoadTimeWeaver(ClassLoader beanClassLoader) |
Modifier and Type | Method and Description |
---|---|
void |
addTransformer(ClassFileTransformer transformer)
Add a
ClassFileTransformer to be applied by this
LoadTimeWeaver . |
protected LoadTimeWeaver |
createServerSpecificLoadTimeWeaver(ClassLoader classLoader) |
void |
destroy()
Invoked by a BeanFactory on destruction of a singleton.
|
ClassLoader |
getInstrumentableClassLoader()
Return a
ClassLoader that supports instrumentation
through AspectJ-style load-time weaving based on user-defined
ClassFileTransformers . |
ClassLoader |
getThrowawayClassLoader()
Return a throwaway
ClassLoader , enabling classes to be
loaded and inspected without affecting the parent ClassLoader . |
void |
setBeanClassLoader(ClassLoader classLoader)
Callback that supplies the bean
class loader to
a bean instance. |
protected final Log logger
public DefaultContextLoadTimeWeaver()
public DefaultContextLoadTimeWeaver(ClassLoader beanClassLoader)
public void setBeanClassLoader(ClassLoader classLoader)
BeanClassLoaderAware
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.
setBeanClassLoader
in interface BeanClassLoaderAware
classLoader
- the owning class loader@Nullable protected LoadTimeWeaver createServerSpecificLoadTimeWeaver(ClassLoader classLoader)
public void destroy()
DisposableBean
destroy
in interface DisposableBean
public void addTransformer(ClassFileTransformer transformer)
LoadTimeWeaver
ClassFileTransformer
to be applied by this
LoadTimeWeaver
.addTransformer
in interface LoadTimeWeaver
transformer
- the ClassFileTransformer
to addpublic ClassLoader getInstrumentableClassLoader()
LoadTimeWeaver
ClassLoader
that supports instrumentation
through AspectJ-style load-time weaving based on user-defined
ClassFileTransformers
.
May be the current ClassLoader
, or a ClassLoader
created by this LoadTimeWeaver
instance.
getInstrumentableClassLoader
in interface LoadTimeWeaver
ClassLoader
which will expose
instrumented classes according to the registered transformerspublic ClassLoader getThrowawayClassLoader()
LoadTimeWeaver
ClassLoader
, enabling classes to be
loaded and inspected without affecting the parent ClassLoader
.
Should not return the same instance of the ClassLoader
returned from an invocation of LoadTimeWeaver.getInstrumentableClassLoader()
.
getThrowawayClassLoader
in interface LoadTimeWeaver
ClassLoader
; should return
a new instance for each call, with no existing state