protected static class InvocationHandlerAdapter.ForInstanceDelegation extends InvocationHandlerAdapter implements InvocationHandlerAdapter.AssignerConfigurable
InvocationHandlerAdapter
that delegates method
invocations to an adapter that is stored in an instance field.Modifier and Type | Class and Description |
---|---|
protected class |
InvocationHandlerAdapter.ForInstanceDelegation.Appender
An appender for implementing the
InvocationHandlerAdapter.ForInstanceDelegation . |
InvocationHandlerAdapter.AssignerConfigurable, InvocationHandlerAdapter.ForInstanceDelegation, InvocationHandlerAdapter.ForStaticDelegation
Instrumentation.Compound, Instrumentation.Context, Instrumentation.ForAbstractMethod, Instrumentation.Simple, Instrumentation.SpecialMethodInvocation, Instrumentation.Target
assigner, cacheMethods, fieldName
Modifier | Constructor and Description |
---|---|
protected |
ForInstanceDelegation(String fieldName,
boolean cacheMethods,
Assigner assigner)
Creates a new invocation handler adapter for delegating invocations to an invocation handler that is stored
in an instance field.
|
Modifier and Type | Method and Description |
---|---|
ByteCodeAppender |
appender(Instrumentation.Target instrumentationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.
|
InstrumentedType |
prepare(InstrumentedType instrumentedType)
During the preparation phase of an instrumentation, implementations are eligible to adding fields or methods
to the currently instrumented type.
|
String |
toString() |
Instrumentation |
withAssigner(Assigner assigner)
Configures an assigner to use with this invocation handler adapter.
|
InvocationHandlerAdapter.AssignerConfigurable |
withMethodCache()
By default, any
Method instance that is handed over to an
InvocationHandler is created on each invocation of the method. |
apply, equals, hashCode, of, of, toInstanceField
protected ForInstanceDelegation(String fieldName, boolean cacheMethods, Assigner assigner)
fieldName
- The name of the field.cacheMethods
- Determines if the Method
instances that are handed to the
intercepted methods are cached in static
fields.assigner
- The assigner to apply when defining this instrumentation.public InvocationHandlerAdapter.AssignerConfigurable withMethodCache()
InvocationHandlerAdapter
Method
instance that is handed over to an
InvocationHandler
is created on each invocation of the method.
Method
look-ups are normally cached by its defining Class
what
makes a repeated look-up of a method little expensive. However, because Method
instances are mutable by their AccessibleObject
contact, any looked-up instance
needs to be copied by its defining Class
before exposing it. This can cause performance
deficits when a method is for example called repeatedly in a loop. By enabling the method cache, this
performance penalty can be avoided by caching a single Method
instance for
any intercepted method as a static
field in the instrumented type.withMethodCache
in class InvocationHandlerAdapter
Method
instance
in form of a static
field.public Instrumentation withAssigner(Assigner assigner)
InvocationHandlerAdapter.AssignerConfigurable
withAssigner
in interface InvocationHandlerAdapter.AssignerConfigurable
assigner
- The assigner to apply when defining this instrumentation.assigner
configured.public InstrumentedType prepare(InstrumentedType instrumentedType)
Instrumentation
ByteCodeAppender
that is emitted
on the call to
Instrumentation.appender(net.bytebuddy.instrumentation.Instrumentation.Target)
call. On this method call, loaded type initializers can also be added to the instrumented type.prepare
in interface Instrumentation
instrumentedType
- The instrumented type that is the basis of the ongoing instrumentation.public ByteCodeAppender appender(Instrumentation.Target instrumentationTarget)
Instrumentation
appender
in interface Instrumentation
instrumentationTarget
- The target of the current instrumentation.Instrumentation.prepare(net.bytebuddy.instrumentation.type.InstrumentedType)
.Copyright © 2014–2015. All rights reserved.