Class DefaultContextLoadTimeWeaver
- java.lang.Object
- org.springframework.context.weaving.DefaultContextLoadTimeWeaver
- All Implemented Interfaces:
Aware,BeanClassLoaderAware,DisposableBean,LoadTimeWeaver
public class DefaultContextLoadTimeWeaver extends Object implements LoadTimeWeaver, BeanClassLoaderAware, DisposableBean
DefaultLoadTimeWeaverbean for use in an application context, decorating an automatically detected internalLoadTimeWeaver.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 4.0, it detects Oracle WebLogic 10, GlassFish 3, Tomcat 6, 7 and 8, JBoss AS 5, 6 and 7, IBM WebSphere 7 and 8,
Spring's VM agent, and anyClassLoadersupported by Spring'sReflectiveLoadTimeWeaver.- Since:
- 2.5
- Author:
- Juergen Hoeller, Ramnivas Laddad, Costin Leau
- See Also:
ConfigurableApplicationContext.LOAD_TIME_WEAVER_BEAN_NAME
Constructor Summary
Constructors Constructor Description DefaultContextLoadTimeWeaver()DefaultContextLoadTimeWeaver(ClassLoader beanClassLoader)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTransformer(ClassFileTransformer transformer)Add aClassFileTransformerto be applied by thisLoadTimeWeaver.protected LoadTimeWeavercreateServerSpecificLoadTimeWeaver(ClassLoader classLoader)voiddestroy()Invoked by the containingBeanFactoryon destruction of a bean.ClassLoadergetInstrumentableClassLoader()Return aClassLoaderthat supports instrumentation through AspectJ-style load-time weaving based on user-definedClassFileTransformers.ClassLoadergetThrowawayClassLoader()Return a throwawayClassLoader, enabling classes to be loaded and inspected without affecting the parentClassLoader.voidsetBeanClassLoader(ClassLoader classLoader)Callback that supplies the beanclass loaderto a bean instance.
Constructor Detail
DefaultContextLoadTimeWeaver
public DefaultContextLoadTimeWeaver()
DefaultContextLoadTimeWeaver
public DefaultContextLoadTimeWeaver(ClassLoader beanClassLoader)
Method Detail
setBeanClassLoader
public void setBeanClassLoader(ClassLoader classLoader)
Description copied from interface:BeanClassLoaderAwareCallback that supplies the beanclass loaderto a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean'sInitializingBean.afterPropertiesSet()method or a custom init-method.- Specified by:
setBeanClassLoaderin interfaceBeanClassLoaderAware- Parameters:
classLoader- the owning class loader; may benullin which case a defaultClassLoadermust be used, for example theClassLoaderobtained viaClassUtils.getDefaultClassLoader()
createServerSpecificLoadTimeWeaver
protected LoadTimeWeaver createServerSpecificLoadTimeWeaver(ClassLoader classLoader)
destroy
public void destroy()
Description copied from interface:DisposableBeanInvoked by the containingBeanFactoryon destruction of a bean.- Specified by:
destroyin interfaceDisposableBean
addTransformer
public void addTransformer(ClassFileTransformer transformer)
Description copied from interface:LoadTimeWeaverAdd aClassFileTransformerto be applied by thisLoadTimeWeaver.- Specified by:
addTransformerin interfaceLoadTimeWeaver- Parameters:
transformer- theClassFileTransformerto add
getInstrumentableClassLoader
public ClassLoader getInstrumentableClassLoader()
Description copied from interface:LoadTimeWeaverReturn aClassLoaderthat supports instrumentation through AspectJ-style load-time weaving based on user-definedClassFileTransformers.May be the current
ClassLoader, or aClassLoadercreated by thisLoadTimeWeaverinstance.- Specified by:
getInstrumentableClassLoaderin interfaceLoadTimeWeaver- Returns:
- the
ClassLoaderwhich will expose instrumented classes according to the registered transformers
getThrowawayClassLoader
public ClassLoader getThrowawayClassLoader()
Description copied from interface:LoadTimeWeaverReturn a throwawayClassLoader, enabling classes to be loaded and inspected without affecting the parentClassLoader.Should not return the same instance of the
ClassLoaderreturned from an invocation ofLoadTimeWeaver.getInstrumentableClassLoader().- Specified by:
getThrowawayClassLoaderin interfaceLoadTimeWeaver- Returns:
- a temporary throwaway
ClassLoader; should return a new instance for each call, with no existing state