Package net.bytebuddy.implementation
Class InvocationHandlerAdapter.ForInstance
- java.lang.Object
-
- net.bytebuddy.implementation.InvocationHandlerAdapter
-
- net.bytebuddy.implementation.InvocationHandlerAdapter.ForInstance
-
- All Implemented Interfaces:
InstrumentedType.Prepareable
,Implementation
,InvocationHandlerAdapter.AssignerConfigurable
,InvocationHandlerAdapter.WithoutPrivilegeConfiguration
- Enclosing class:
- InvocationHandlerAdapter
@Enhance protected static class InvocationHandlerAdapter.ForInstance extends InvocationHandlerAdapter implements InvocationHandlerAdapter.WithoutPrivilegeConfiguration
An implementation of anInvocationHandlerAdapter
that delegates method invocations to an adapter that is stored in a static field.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
InvocationHandlerAdapter.ForInstance.Appender
An appender for implementing theInvocationHandlerAdapter.ForInstance
.-
Nested classes/interfaces inherited from class net.bytebuddy.implementation.InvocationHandlerAdapter
InvocationHandlerAdapter.AssignerConfigurable, InvocationHandlerAdapter.ForField, InvocationHandlerAdapter.ForInstance, InvocationHandlerAdapter.WithoutPrivilegeConfiguration
-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.Implementation
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.reflect.InvocationHandler
invocationHandler
The invocation handler to which method interceptions are to be delegated.private static java.lang.String
PREFIX
The prefix for field that are created for storing the instrumented value.-
Fields inherited from class net.bytebuddy.implementation.InvocationHandlerAdapter
assigner, cached, fieldName, privileged
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ForInstance(java.lang.String fieldName, boolean cached, boolean privileged, Assigner assigner, java.lang.reflect.InvocationHandler invocationHandler)
Creates a new invocation handler adapter for delegating invocations to an invocation handler that is stored in a static field.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteCodeAppender
appender(Implementation.Target implementationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.InstrumentedType
prepare(InstrumentedType instrumentedType)
Prepares a given instrumented type.Implementation
withAssigner(Assigner assigner)
Configures an assigner to use with this invocation handler adapter.InvocationHandlerAdapter.WithoutPrivilegeConfiguration
withoutMethodCache()
By default, anyMethod
instance that is handed over to anInvocationHandler
is cached in a static field.InvocationHandlerAdapter.AssignerConfigurable
withPrivilegedLookup()
Configures that the method constants supplied to the invocation handler adapter are resolved using anAccessController
.
-
-
-
Field Detail
-
PREFIX
private static final java.lang.String PREFIX
The prefix for field that are created for storing the instrumented value.- See Also:
- Constant Field Values
-
invocationHandler
protected final java.lang.reflect.InvocationHandler invocationHandler
The invocation handler to which method interceptions are to be delegated.
-
-
Constructor Detail
-
ForInstance
protected ForInstance(java.lang.String fieldName, boolean cached, boolean privileged, Assigner assigner, java.lang.reflect.InvocationHandler invocationHandler)
Creates a new invocation handler adapter for delegating invocations to an invocation handler that is stored in a static field.- Parameters:
fieldName
- The name of the field.cached
- Determines if theMethod
instances that are handed to the intercepted methods are cached instatic
fields.privileged
- Determines if theMethod
instances are retrieved by using anAccessController
.assigner
- The assigner to apply when defining this implementation.invocationHandler
- The invocation handler to which all method calls are delegated.
-
-
Method Detail
-
withoutMethodCache
public InvocationHandlerAdapter.WithoutPrivilegeConfiguration withoutMethodCache()
Description copied from class:InvocationHandlerAdapter
By default, anyMethod
instance that is handed over to anInvocationHandler
is cached in a static field. By invoking this method, this feature can be disabled.- Specified by:
withoutMethodCache
in classInvocationHandlerAdapter
- Returns:
- A similar invocation handler adapter that applies caching.
-
withAssigner
public Implementation withAssigner(Assigner assigner)
Description copied from class:InvocationHandlerAdapter
Configures an assigner to use with this invocation handler adapter.- Specified by:
withAssigner
in interfaceInvocationHandlerAdapter.AssignerConfigurable
- Specified by:
withAssigner
in classInvocationHandlerAdapter
- Parameters:
assigner
- The assigner to apply when defining this implementation.- Returns:
- This instrumentation with the given
assigner
configured.
-
withPrivilegedLookup
public InvocationHandlerAdapter.AssignerConfigurable withPrivilegedLookup()
Description copied from class:InvocationHandlerAdapter
Configures that the method constants supplied to the invocation handler adapter are resolved using anAccessController
.- Specified by:
withPrivilegedLookup
in interfaceInvocationHandlerAdapter.WithoutPrivilegeConfiguration
- Specified by:
withPrivilegedLookup
in classInvocationHandlerAdapter
- Returns:
- This instrumentation with a privileged lookup configured.
-
prepare
public InstrumentedType prepare(InstrumentedType instrumentedType)
Prepares a given instrumented type.- Specified by:
prepare
in interfaceInstrumentedType.Prepareable
- Parameters:
instrumentedType
- The instrumented type in its current form.- Returns:
- The prepared instrumented type.
-
appender
public ByteCodeAppender appender(Implementation.Target implementationTarget)
Creates a byte code appender that determines the implementation of the instrumented type's methods.- Specified by:
appender
in interfaceImplementation
- Parameters:
implementationTarget
- The target of the current implementation.- Returns:
- A byte code appender for implementing methods delegated to this implementation. This byte code appender
is also responsible for handling methods that were added by this implementation on the call to
InstrumentedType.Prepareable.prepare(InstrumentedType)
.
-
-