public class GenericClassAdapter
extends org.objectweb.asm.ClassVisitor
InvocationHandler
and calling
InvocationHandler.invoke(Object, java.lang.reflect.Method, Object[])
to get a handler which is also an
InvocationHandler
. When the method finishes this handler will be invoked with the return value of the method
or the exception if one was thrown.
InvocationHandlerTracingMethodAdapter
: If this is the first time a class is being loaded, a field of type
InvocationHandler
is created for every instrumented method. A static method is added which initializes these
fields and this is called from the class initializer. These invocation handlers are factories which create the
tracing invocation handler for the method, and they're created through a callback to
PointCutClassTransformer.evaluate(Class, com.newrelic.agent.TracerService, Object, Object, Object, boolean, Object[])
. This is the faster of the two instrumentation approaches.
ReflectionStyleClassMethodAdapter
: If the class has already been loaded no fields can be added to it. In this
case we fetch the tracer by making a call to AgentWrapper.invoke(Object, java.lang.reflect.Method, Object[])
passing in the invocation handler id ( see TracerService.getInvocationHandler(int)
.Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
className |
Constructor and Description |
---|
GenericClassAdapter(org.objectweb.asm.ClassVisitor cv,
java.lang.ClassLoader classLoader,
java.lang.String className,
java.lang.Class<?> classBeingRedefined,
java.util.Collection<PointCut> strongMatches,
InstrumentationContext context) |
Modifier and Type | Method and Description |
---|---|
java.util.List<PointCut> |
getAppliedPointCuts() |
java.util.Collection<com.newrelic.agent.instrumentation.AbstractTracingMethodAdapter> |
getInstrumentedMethods() |
void |
visit(int version,
int access,
java.lang.String name,
java.lang.String signature,
java.lang.String superName,
java.lang.String[] interfaces) |
void |
visitEnd() |
org.objectweb.asm.MethodVisitor |
visitMethod(int access,
java.lang.String name,
java.lang.String desc,
java.lang.String signature,
java.lang.String[] exceptions) |
public GenericClassAdapter(org.objectweb.asm.ClassVisitor cv, java.lang.ClassLoader classLoader, java.lang.String className, java.lang.Class<?> classBeingRedefined, java.util.Collection<PointCut> strongMatches, InstrumentationContext context)
public void visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)
visit
in class org.objectweb.asm.ClassVisitor
public org.objectweb.asm.MethodVisitor visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
visitMethod
in class org.objectweb.asm.ClassVisitor
public void visitEnd()
visitEnd
in class org.objectweb.asm.ClassVisitor
public java.util.Collection<com.newrelic.agent.instrumentation.AbstractTracingMethodAdapter> getInstrumentedMethods()
public java.util.List<PointCut> getAppliedPointCuts()