public class Forwarding extends Object implements Implementation
MethodDelegation
Modifier and Type | Class and Description |
---|---|
protected class |
Forwarding.Appender
An appender for implementing a
Forwarding operation. |
protected static interface |
Forwarding.PreparationHandler
A handler for preparing a
Forwarding implementation. |
Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target
Modifier and Type | Field and Description |
---|---|
protected String |
fieldName
The name of the field.
|
protected TypeDescription |
fieldType
The type of the field.
|
protected Forwarding.PreparationHandler |
preparationHandler
A handler for preparing the instrumented type and the field invocation operation.
|
Modifier | Constructor and Description |
---|---|
protected |
Forwarding(String fieldName,
TypeDescription fieldType,
Forwarding.PreparationHandler preparationHandler)
Creates a new forwarding implementation.
|
Modifier and Type | Method and Description |
---|---|
ByteCodeAppender |
appender(Implementation.Target implementationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.
|
boolean |
equals(Object other) |
int |
hashCode() |
InstrumentedType |
prepare(InstrumentedType instrumentedType)
During the preparation phase of an implementation, implementations are eligible to adding fields or methods
to the currently instrumented type.
|
static Implementation |
to(Object delegate)
Forwards all intercepted method invocations to the given instance which is stored in a
static field
of the instrumented class. |
static Implementation |
to(Object delegate,
String fieldName)
Forwards all intercepted method invocations to the given instance which is stored in a
static field
of the instrumented class. |
static Implementation |
toInstanceField(String fieldName,
Class<?> fieldType)
Forwards all intercepted method invocations to an instance field of the instrumented class.
|
static Implementation |
toInstanceField(String fieldName,
TypeDescription fieldType)
Forwards all intercepted method invocations to an instance field of the instrumented class.
|
static Implementation |
toStaticField(String fieldName,
Class<?> fieldType)
Forwards all intercepted method invocations to a
static field of the instrumented class. |
static Implementation |
toStaticField(String fieldName,
TypeDescription fieldType)
Forwards all intercepted method invocations to a
static field of the instrumented class. |
String |
toString() |
protected final String fieldName
protected final TypeDescription fieldType
protected final Forwarding.PreparationHandler preparationHandler
protected Forwarding(String fieldName, TypeDescription fieldType, Forwarding.PreparationHandler preparationHandler)
fieldName
- The name of the field.fieldType
- The type of the field.preparationHandler
- A handler for preparing the instrumented type and the field invocation operation.public static Implementation to(Object delegate)
static
field
of the instrumented class. The field name is generated from the instance's hash code.delegate
- The delegate to which all intercepted methods should be forwarded.public static Implementation to(Object delegate, String fieldName)
static
field
of the instrumented class.delegate
- The delegate to which all intercepted methods should be forwarded.fieldName
- The name of the field in which the delegate should be stored.public static Implementation toStaticField(String fieldName, Class<?> fieldType)
static
field of the instrumented class. The value
of this field must be set explicitly.fieldName
- The name of the field in which the delegate should be stored.fieldType
- The type of the field and thus the type of which the delegate is assumed to be of.public static Implementation toStaticField(String fieldName, TypeDescription fieldType)
static
field of the instrumented class. The value
of this field must be set explicitly.fieldName
- The name of the field in which the delegate should be stored.fieldType
- The type of the field and thus the type of which the delegate is assumed to be of.public static Implementation toInstanceField(String fieldName, Class<?> fieldType)
fieldName
- The name of the field in which the delegate should be stored.fieldType
- The type of the field and thus the type of which the delegate is assumed to be of.public static Implementation toInstanceField(String fieldName, TypeDescription fieldType)
fieldName
- The name of the field in which the delegate should be stored.fieldType
- The type of the field and thus the type of which the delegate is assumed to be of.public ByteCodeAppender appender(Implementation.Target implementationTarget)
Implementation
appender
in interface Implementation
implementationTarget
- The target of the current implementation.Implementation.prepare(InstrumentedType)
.public InstrumentedType prepare(InstrumentedType instrumentedType)
Implementation
ByteCodeAppender
that is emitted
on the call to
Implementation.appender(Implementation.Target)
call. On this method call, loaded type initializers can also be added to the instrumented type.prepare
in interface Implementation
instrumentedType
- The instrumented type that is the basis of the ongoing instrumentation.Copyright © 2014–2015. All rights reserved.