Class InstrumentationLoadTimeWeaver
- java.lang.Object
- org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver
- All Implemented Interfaces:
LoadTimeWeaver
public class InstrumentationLoadTimeWeaver extends Object implements LoadTimeWeaver
LoadTimeWeaverrelying on VMInstrumentation.Start the JVM specifying the Java agent to be used, like as follows:
-javaagent:path/to/org.springframework.instrument.jarwhere
org.springframework.instrument.jaris a JAR file containing theInstrumentationSavingAgentclass, as shipped with Spring.In Eclipse, for example, set the "Run configuration"'s JVM args to be of the form:
-javaagent:${project_loc}/lib/org.springframework.instrument.jar- Since:
- 2.0
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
InstrumentationSavingAgent
Constructor Summary
Constructors Constructor Description InstrumentationLoadTimeWeaver()Create a new InstrumentationLoadTimeWeaver for the default ClassLoader.InstrumentationLoadTimeWeaver(ClassLoader classLoader)Create a new InstrumentationLoadTimeWeaver for the given ClassLoader.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTransformer(ClassFileTransformer transformer)Add aClassFileTransformerto be applied by thisLoadTimeWeaver.ClassLoadergetInstrumentableClassLoader()We have the ability to weave the current class loader when starting the JVM in this way, so the instrumentable class loader will always be the current loader.ClassLoadergetThrowawayClassLoader()This implementation always returns aSimpleThrowawayClassLoader.static booleanisInstrumentationAvailable()Check whether an Instrumentation instance is available for the current VM.voidremoveTransformers()Remove all registered transformers, in inverse order of registration.
Constructor Detail
InstrumentationLoadTimeWeaver
public InstrumentationLoadTimeWeaver()
Create a new InstrumentationLoadTimeWeaver for the default ClassLoader.
InstrumentationLoadTimeWeaver
public InstrumentationLoadTimeWeaver(ClassLoader classLoader)
Create a new InstrumentationLoadTimeWeaver for the given ClassLoader.- Parameters:
classLoader- the ClassLoader that registered transformers are supposed to apply to
Method Detail
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()
We have the ability to weave the current class loader when starting the JVM in this way, so the instrumentable class loader will always be the current loader.- Specified by:
getInstrumentableClassLoaderin interfaceLoadTimeWeaver- Returns:
- the
ClassLoaderwhich will expose instrumented classes according to the registered transformers
getThrowawayClassLoader
public ClassLoader getThrowawayClassLoader()
This implementation always returns aSimpleThrowawayClassLoader.- Specified by:
getThrowawayClassLoaderin interfaceLoadTimeWeaver- Returns:
- a temporary throwaway
ClassLoader; should return a new instance for each call, with no existing state
removeTransformers
public void removeTransformers()
Remove all registered transformers, in inverse order of registration.
isInstrumentationAvailable
public static boolean isInstrumentationAvailable()
Check whether an Instrumentation instance is available for the current VM.- See Also:
getInstrumentation()