|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver
public class InstrumentationLoadTimeWeaver
LoadTimeWeaver
relying on VM Instrumentation
.
Start the JVM specifying the Java agent to be used, like as follows:
-javaagent:path/to/org.springframework.instrument.jar
where org.springframework.instrument.jar
is a JAR file containing
the InstrumentationSavingAgent
class, 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
InstrumentationSavingAgent
Nested Class Summary | |
---|---|
private static class |
InstrumentationLoadTimeWeaver.FilteringClassFileTransformer
Decorator that only applies the given target transformer to a specific ClassLoader. |
private static class |
InstrumentationLoadTimeWeaver.InstrumentationAccessor
Inner class to avoid InstrumentationSavingAgent dependency. |
Field Summary | |
---|---|
private static boolean |
AGENT_CLASS_PRESENT
|
private java.lang.ClassLoader |
classLoader
|
private java.lang.instrument.Instrumentation |
instrumentation
|
private java.util.List<java.lang.instrument.ClassFileTransformer> |
transformers
|
Constructor Summary | |
---|---|
InstrumentationLoadTimeWeaver()
Create a new InstrumentationLoadTimeWeaver for the default ClassLoader. |
|
InstrumentationLoadTimeWeaver(java.lang.ClassLoader classLoader)
Create a new InstrumentationLoadTimeWeaver for the given ClassLoader. |
Method Summary | |
---|---|
void |
addTransformer(java.lang.instrument.ClassFileTransformer transformer)
Add a ClassFileTransformer to be applied by this
LoadTimeWeaver . |
java.lang.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. |
private static java.lang.instrument.Instrumentation |
getInstrumentation()
Obtain the Instrumentation instance for the current VM, if available. |
java.lang.ClassLoader |
getThrowawayClassLoader()
This implementation always returns a SimpleThrowawayClassLoader . |
static boolean |
isInstrumentationAvailable()
Check whether an Instrumentation instance is available for the current VM. |
void |
removeTransformers()
Remove all registered transformers, in inverse order of registration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final boolean AGENT_CLASS_PRESENT
private final java.lang.ClassLoader classLoader
private final java.lang.instrument.Instrumentation instrumentation
private final java.util.List<java.lang.instrument.ClassFileTransformer> transformers
Constructor Detail |
---|
public InstrumentationLoadTimeWeaver()
public InstrumentationLoadTimeWeaver(java.lang.ClassLoader classLoader)
classLoader
- the ClassLoader that registered transformers are supposed to apply toMethod Detail |
---|
public void addTransformer(java.lang.instrument.ClassFileTransformer transformer)
LoadTimeWeaver
ClassFileTransformer
to be applied by this
LoadTimeWeaver
.
addTransformer
in interface LoadTimeWeaver
transformer
- the ClassFileTransformer
to addpublic java.lang.ClassLoader getInstrumentableClassLoader()
getInstrumentableClassLoader
in interface LoadTimeWeaver
ClassLoader
which will expose
instrumented classes according to the registered transformerspublic java.lang.ClassLoader getThrowawayClassLoader()
SimpleThrowawayClassLoader
.
getThrowawayClassLoader
in interface LoadTimeWeaver
ClassLoader
; should return
a new instance for each call, with no existing statepublic void removeTransformers()
public static boolean isInstrumentationAvailable()
getInstrumentation()
private static java.lang.instrument.Instrumentation getInstrumentation()
null
if none foundisInstrumentationAvailable()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |