Package org.eclipse.steady.java.monitor
Class DynamicTransformer
- java.lang.Object
-
- org.eclipse.steady.java.monitor.DynamicTransformer
-
- All Implemented Interfaces:
ClassFileTransformer
public class DynamicTransformer extends Object implements ClassFileTransformer
Uses theClassVisitorto dynamically instrument Java constructors and methods during the class loading process. When executed, the injected code will call theExecutionMonitorto collect and upload runtime information to the Vulas backend.The name has been chosen to contrast with static instrumentation, which can be done with help of the Vulas Maven plugin (goal vulas:instr).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DynamicTransformergetInstance()Singleton method: Creates (if necessary) and returns the single instance that can be created for this class.LoaderHierarchygetLoaderHierarchy()Getter for the fieldloaderHierarchy.static booleanisInstantiated()Returns true if the Singleton has been created.booleanisTransformationEnabled()isTransformationEnabled.static voidpremain(String agentArgs, Instrumentation inst)premain.voidsetTransformationEnabled(boolean transformationEnabled)Setter for the fieldtransformationEnabled.StringtoString()toString.byte[]transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer)Adds instrumentation code to all constructors and methods of all classes (thereby considering certain blacklists and whitelists read from the configuration file).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.instrument.ClassFileTransformer
transform
-
-
-
-
Method Detail
-
isTransformationEnabled
public boolean isTransformationEnabled()
isTransformationEnabled.
- Returns:
- a boolean.
-
setTransformationEnabled
public void setTransformationEnabled(boolean transformationEnabled)
Setter for the field
transformationEnabled.- Parameters:
transformationEnabled- a boolean.
-
getLoaderHierarchy
public LoaderHierarchy getLoaderHierarchy()
Getter for the field
loaderHierarchy.- Returns:
- a
LoaderHierarchyobject.
-
transform
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException
Adds instrumentation code to all constructors and methods of all classes (thereby considering certain blacklists and whitelists read from the configuration file).The method is called by the JRE class loading process and returns the instrumented bytecode for a given class.
- Specified by:
transformin interfaceClassFileTransformer- Parameters:
loader- aClassLoaderobject.className- aStringobject.classBeingRedefined- aClassobject.protectionDomain- aProtectionDomainobject.classfileBuffer- an array ofbyteobjects.- Returns:
- the instrumented bytecode
- Throws:
IllegalClassFormatException- if any.
-
toString
public String toString()
toString.
-
getInstance
public static DynamicTransformer getInstance()
Singleton method: Creates (if necessary) and returns the single instance that can be created for this class.- Returns:
- a
DynamicTransformerobject.
-
isInstantiated
public static boolean isInstantiated()
Returns true if the Singleton has been created.- Returns:
- a boolean.
-
premain
public static void premain(String agentArgs, Instrumentation inst)
premain.
- Parameters:
agentArgs- aStringobject.inst- aInstrumentationobject.
-
-