public abstract class InvocationHandlerAdapter extends Object implements Instrumentation
InvocationHandler
. The adapter allows the invocation handler
to also intercept method calls to non-interface methods.Instrumentation.Compound, Instrumentation.Context, Instrumentation.ForAbstractMethod
Modifier and Type | Field and Description |
---|---|
protected Assigner |
assigner
The assigner that is used for assigning the return invocation handler's return value to the
intercepted method's return value.
|
protected String |
fieldName
The name of the field for storing an invocation handler.
|
Modifier | Constructor and Description |
---|---|
protected |
InvocationHandlerAdapter(String fieldName)
Creates a new invocation handler for a given field.
|
Modifier and Type | Method and Description |
---|---|
protected ByteCodeAppender.Size |
apply(org.objectweb.asm.MethodVisitor methodVisitor,
Instrumentation.Context instrumentationContext,
MethodDescription instrumentedMethod,
TypeDescription instrumentedType,
StackManipulation preparingManipulation)
Applies an instrumentation that delegates to a invocation handler.
|
boolean |
equals(Object other) |
int |
hashCode() |
static Instrumentation |
of(InvocationHandler invocationHandler)
Creates an instrumentation for any instance of an
InvocationHandler that delegates
all method interceptions to the given instance which will be stored in a static field. |
static Instrumentation |
of(InvocationHandler invocationHandler,
String fieldName)
Creates an instrumentation for any instance of an
InvocationHandler that delegates
all method interceptions to the given instance which will be stored in a static field. |
static Instrumentation |
of(String fieldName)
Creates an instrumentation for any
InvocationHandler that delegates
all method interceptions to a public instance field with the given name. |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
appender, prepare
protected final String fieldName
protected final Assigner assigner
protected InvocationHandlerAdapter(String fieldName)
fieldName
- The name of the field.public static Instrumentation of(InvocationHandler invocationHandler)
InvocationHandler
that delegates
all method interceptions to the given instance which will be stored in a static
field.invocationHandler
- The invocation handler to which all method calls are delegated.public static Instrumentation of(InvocationHandler invocationHandler, String fieldName)
InvocationHandler
that delegates
all method interceptions to the given instance which will be stored in a static
field.invocationHandler
- The invocation handler to which all method calls are delegated.fieldName
- The name of the field.public static Instrumentation of(String fieldName)
InvocationHandler
that delegates
all method interceptions to a public
instance field with the given name. This field has to be
set before any invocations are intercepted. Otherwise, a NullPointerException
will be
thrown.fieldName
- The name of the field.protected ByteCodeAppender.Size apply(org.objectweb.asm.MethodVisitor methodVisitor, Instrumentation.Context instrumentationContext, MethodDescription instrumentedMethod, TypeDescription instrumentedType, StackManipulation preparingManipulation)
methodVisitor
- The method visitor for writing the byte code to.instrumentationContext
- The instrumentation context for the current instrumentation.instrumentedMethod
- The method that is instrumented.instrumentedType
- The type that is instrumented.preparingManipulation
- A stack manipulation that applies any preparation to the operand stack.Copyright © 2014. All rights reserved.