A target method parameter that is annotated with this annotation allows to forward an intercepted method invocation to another instance. The instance to which a method call is forwarded must be of the most specific type that declares the intercepted method on the intercepted type.
Unfortunately, before Java 8, the Java Class Library does not define any interface type which takes a single
java.
type and returns another java.
type. For this reason, a
net.
needs to be installed explicitly
and registered on a net.
. The installed type is allowed to be an
interface without any super types that declares a single method which maps an java.
type to
a another java.
type as a result value. It is however not prohibited to use generics in the
process.
net.bytebuddy.implementation.MethodDelegation
, net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder
Modifier and Type | Class and Description |
---|---|
public static class |
Modifier and Type | Method and Description |
---|---|
public boolean |
serializableProxy | back to summary |
---|---|
public boolean serializableProxy() Determines if the generated proxy should be
|
net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder
for binding the net.bytebuddy.implementation.bind.annotation.Pipe
annotation.
Modifier and Type | Class and Description |
---|---|
protected static class | Pipe.Binder.RedirectionProxy
An auxiliary type for performing the redirection of a method invocation as requested by the
|
Modifier and Type | Field and Description |
---|---|
private final MethodDescription | forwardingMethod
The method which implements the behavior of forwarding a method invocation. |
private static final MethodDescription. | SERIALIZABLE_PROXY
A description of the |
Access | Constructor and Description |
---|---|
protected | Binder(MethodDescription
The method which implements the behavior of forwarding a method invocation. This
method needs to define a single non-static method with an forwardingMethod)java.
to java. mapping.Creates a new binder. |
Modifier and Type | Method and Description |
---|---|
public MethodDelegationBinder. | bind(AnnotationDescription.
The annotation that was cause for the delegation to this argument binder. annotation,The intercepted source method. source, ParameterDescription Tge target parameter that is subject to be bound to
intercepting the target, Implementation.source method.The target of the current implementation that is subject to this binding. implementationTarget,An assigner that can be used for applying the binding. assigner, Assigner.The typing to apply. typingImplements net. |
public Class | getHandledType()
The annotation type that is handled by this parameter binder.
|
public static TargetMethodAnnotationDrivenBinder. | Returns: A binder for thenet.
annotation.The type to install. type)Installs a given type for use on a |
public static TargetMethodAnnotationDrivenBinder. | Returns: A binder for thenet.
annotation.The type to install. typeDescription)Installs a given type for use on a |
private static MethodDescription | Returns: Its only method after validation.The type that is being installed. typeDescription)Locates the only method of a type that is compatible to being overridden for invoking the proxy. |
forwardingMethod | back to summary |
---|---|
private final MethodDescription forwardingMethod The method which implements the behavior of forwarding a method invocation. This method needs to define
a single non-static method with an |
SERIALIZABLE_PROXY | back to summary |
---|---|
private static final MethodDescription. A description of the |
Binder | back to summary |
---|---|
protected Binder(MethodDescription forwardingMethod) Creates a new binder. This constructor is not doing any validation of the forwarding method and its
declaring type. Such validation is normally performed by the
|
bind | back to summary |
---|---|
public MethodDelegationBinder. Implements net. Doc from net. Creates a parameter binding for the given target parameter.
|
getHandledType | back to summary |
---|---|
public Class The annotation type that is handled by this parameter binder.
|
install | back to summary |
---|---|
public static TargetMethodAnnotationDrivenBinder. Installs a given type for use on a
|
install | back to summary |
---|---|
public static TargetMethodAnnotationDrivenBinder. Installs a given type for use on a
|
onlyMethod | back to summary |
---|---|
private static MethodDescription onlyMethod(TypeDescription typeDescription) Locates the only method of a type that is compatible to being overridden for invoking the proxy.
|
net.bytebuddy.implementation.bind.annotation.Pipe
annotation.
Modifier and Type | Class and Description |
---|---|
protected static enum | Pipe.Binder.RedirectionProxy.ConstructorCall
The implementation to implement a |
protected static class | Pipe.Binder.RedirectionProxy.MethodCall
The implementation to implement a |
Modifier and Type | Field and Description |
---|---|
private final Assigner | assigner
The assigner to use. |
private static final String | FIELD_NAME_PREFIX
The prefix for naming fields to store method arguments. |
private final TypeDescription | forwardingType
The type that declares the method for forwarding a method invocation. |
private final boolean | serializableProxy
Determines if the generated proxy should be |
private final MethodDescription | sourceMethod
The method that is to be forwarded. |
Access | Constructor and Description |
---|---|
protected | RedirectionProxy(TypeDescription
The type that declares the method for forwarding a method invocation. forwardingType, MethodDescription The method that is to be forwarded. sourceMethod, Assigner The assigner to use. assigner, boolean Determines if the generated proxy should be serializableProxy)java. .Creates a new redirection. |
Modifier and Type | Method and Description |
---|---|
public StackManipulation. | apply(MethodVisitor
The method visitor used to write the method implementation to. methodVisitor, Implementation.The context of the current implementation. implementationContextImplements net. |
private static LinkedHashMap | Returns: A linked hash map of field names to the types of these fields representing all parameters of the given method.The method to extract the parameters from. methodDescription)Extracts all parameters of a method to fields. |
private static String | Returns: The field name that corresponds to the index.The index of the field. index)Creates a new field name. |
public String | getSuffix()
Implements net. |
public DynamicType | make(String
The fully qualified binary name for this auxiliary type. The type should be in
the same package than the instrumented type this auxiliary type is providing services
to in order to allow package-private access. auxiliaryTypeName, ClassFileVersion The class file version the auxiliary class should be written in. classFileVersion, MethodAccessorFactory A factory for accessor methods. methodAccessorFactory)Implements net. |
assigner | back to summary |
---|---|
private final Assigner assigner The assigner to use. |
FIELD_NAME_PREFIX | back to summary |
---|---|
private static final String FIELD_NAME_PREFIX The prefix for naming fields to store method arguments. |
forwardingType | back to summary |
---|---|
private final TypeDescription forwardingType The type that declares the method for forwarding a method invocation. |
serializableProxy | back to summary |
---|---|
private final boolean serializableProxy Determines if the generated proxy should be |
sourceMethod | back to summary |
---|---|
private final MethodDescription sourceMethod The method that is to be forwarded. |
RedirectionProxy | back to summary |
---|---|
protected RedirectionProxy(TypeDescription forwardingType, MethodDescription sourceMethod, Assigner assigner, boolean serializableProxy) Creates a new redirection.
|
apply | back to summary |
---|---|
public StackManipulation. Implements net. Doc from net. Applies the stack manipulation that is described by this instance.
|
extractFields | back to summary |
---|---|
private static LinkedHashMap Extracts all parameters of a method to fields.
|
fieldName | back to summary |
---|---|
private static String fieldName(int index) Creates a new field name.
|
getSuffix | back to summary |
---|---|
public String getSuffix() Implements net. Doc from net. Produces a suffix that gives this auxiliary type a stable name. A best effort is made that this suffix is unique.
|
make | back to summary |
---|---|
public DynamicType make(String auxiliaryTypeName, ClassFileVersion classFileVersion, MethodAccessorFactory methodAccessorFactory) Implements net. Doc from net. Creates a new auxiliary type.
|
RedirectionProxy
's constructor.
Modifier and Type | Class and Description |
---|---|
private static class | Pipe.Binder.RedirectionProxy.ConstructorCall.Appender
The appender for implementing the |
Modifier and Type | Field and Description |
---|---|
public static final Pipe. | INSTANCE
The singleton instance. |
private final transient MethodDescription. | objectTypeDefaultConstructor
A reference of the |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public ByteCodeAppender | appender(Implementation.
The target of the current implementation. implementationTargetImplements net. |
public InstrumentedType | prepare(InstrumentedType
The instrumented type in its current form. instrumentedType)Implements net. |
public static Pipe. | |
public static Pipe. |
INSTANCE | back to summary |
---|---|
public static final Pipe. The singleton instance. |
objectTypeDefaultConstructor | back to summary |
---|---|
private final transient MethodDescription. A reference of the |
ConstructorCall | back to summary |
---|---|
private ConstructorCall() Creates the constructor call singleton. |
appender | back to summary |
---|---|
public ByteCodeAppender appender(Implementation. Implements net. Doc from net. Creates a byte code appender that determines the implementation of the instrumented type's methods.
|
prepare | back to summary |
---|---|
public InstrumentedType prepare(InstrumentedType instrumentedType) Implements net. Doc from net. Prepares a given instrumented type.
|
valueOf | back to summary |
---|---|
public static Pipe. |
values | back to summary |
---|---|
public static Pipe. |
RedirectionProxy.ConstructorCall
.
Modifier and Type | Field and Description |
---|---|
private final TypeDescription | instrumentedType
The instrumented type being created. |
Access | Constructor and Description |
---|---|
private | Appender(TypeDescription
The instrumented type that is being created. instrumentedType)Creates a new appender. |
Modifier and Type | Method and Description |
---|---|
public ByteCodeAppender. | apply(MethodVisitor
The method visitor to which the byte code appender writes its code to. methodVisitor, Implementation.The implementation context of the current type creation process. implementationContext,The method that is the target of the instrumentation. instrumentedMethod)Implements net. |
instrumentedType | back to summary |
---|---|
private final TypeDescription instrumentedType The instrumented type being created. |
Appender | back to summary |
---|---|
private Appender(TypeDescription instrumentedType) Creates a new appender.
|
apply | back to summary |
---|---|
public ByteCodeAppender. Implements net. Doc from net. Applies this byte code appender to a type creation process.
|
RedirectionProxy
's forwarding method.
Modifier and Type | Class and Description |
---|---|
private class | Pipe.Binder.RedirectionProxy.MethodCall.Appender
The appender for implementing the |
Modifier and Type | Field and Description |
---|---|
private final Assigner | assigner
The assigner to be used for invoking the forwarded method. |
private final MethodDescription | redirectedMethod
The method that is invoked by the implemented method. |
Access | Constructor and Description |
---|---|
private | MethodCall(MethodDescription
The method that is invoked by the implemented method. redirectedMethod, Assigner The assigner to be used for invoking the forwarded method. assigner)Creates a new method call implementation. |
Modifier and Type | Method and Description |
---|---|
public ByteCodeAppender | appender(Implementation.
The target of the current implementation. implementationTargetImplements net. |
public InstrumentedType | prepare(InstrumentedType
The instrumented type in its current form. instrumentedType)Implements net. |
assigner | back to summary |
---|---|
private final Assigner assigner The assigner to be used for invoking the forwarded method. |
redirectedMethod | back to summary |
---|---|
private final MethodDescription redirectedMethod The method that is invoked by the implemented method. |
MethodCall | back to summary |
---|---|
private MethodCall(MethodDescription redirectedMethod, Assigner assigner) Creates a new method call implementation.
|
appender | back to summary |
---|---|
public ByteCodeAppender appender(Implementation. Implements net. Doc from net. Creates a byte code appender that determines the implementation of the instrumented type's methods.
|
prepare | back to summary |
---|---|
public InstrumentedType prepare(InstrumentedType instrumentedType) Implements net. Doc from net. Prepares a given instrumented type.
|
RedirectionProxy.MethodCall
.
Modifier and Type | Field and Description |
---|---|
private final TypeDescription | instrumentedType
The instrumented type that is implemented. |
Access | Constructor and Description |
---|---|
private | Appender(TypeDescription
The instrumented type to be implemented. instrumentedType)Creates a new appender. |
Modifier and Type | Method and Description |
---|---|
public ByteCodeAppender. | apply(MethodVisitor
The method visitor to which the byte code appender writes its code to. methodVisitor, Implementation.The implementation context of the current type creation process. implementationContext,The method that is the target of the instrumentation. instrumentedMethod)Implements net. |
instrumentedType | back to summary |
---|---|
private final TypeDescription instrumentedType The instrumented type that is implemented. |
Appender | back to summary |
---|---|
private Appender(TypeDescription instrumentedType) Creates a new appender.
|
apply | back to summary |
---|---|
public ByteCodeAppender. Implements net. Doc from net. Applies this byte code appender to a type creation process.
|