Class InvocationHandlerAdapter.ForInstance
java.lang.Object
net.bytebuddy.implementation.InvocationHandlerAdapter
net.bytebuddy.implementation.InvocationHandlerAdapter.ForInstance
- All Implemented Interfaces:
InstrumentedType.Prepareable, Implementation, Implementation.Composable, InvocationHandlerAdapter.AssignerConfigurable, InvocationHandlerAdapter.WithoutPrivilegeConfiguration
- Enclosing class:
InvocationHandlerAdapter
@Enhance
protected static class InvocationHandlerAdapter.ForInstance
extends InvocationHandlerAdapter
implements InvocationHandlerAdapter.WithoutPrivilegeConfiguration
An implementation of an
InvocationHandlerAdapter that delegates method
invocations to an adapter that is stored in a static field.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classAn appender for implementing theInvocationHandlerAdapter.ForInstance.Nested classes/interfaces inherited from class InvocationHandlerAdapter
InvocationHandlerAdapter.AssignerConfigurable, InvocationHandlerAdapter.ForField, InvocationHandlerAdapter.ForInstance, InvocationHandlerAdapter.WithoutPrivilegeConfigurationNested classes/interfaces inherited from interface Implementation
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.TargetNested classes/interfaces inherited from interface InstrumentedType.Prepareable
InstrumentedType.Prepareable.NoOp -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final InvocationHandlerThe invocation handler to which method interceptions are to be delegated.private static final StringThe prefix for field that are created for storing the instrumented value.Fields inherited from class InvocationHandlerAdapter
assigner, cached, fieldName, privileged, returning -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedForInstance(String fieldName, boolean cached, boolean privileged, boolean returning, Assigner assigner, InvocationHandler invocationHandler) Creates a new invocation handler adapter for delegating invocations to an invocation handler that is stored in a static field. -
Method Summary
Modifier and TypeMethodDescriptionandThen(Implementation implementation) Appends the supplied implementation to this implementation.andThen(Implementation.Composable implementation) Appends the supplied composable implementation to this implementation.appender(Implementation.Target implementationTarget) Creates a byte code appender that determines the implementation of the instrumented type's methods.prepare(InstrumentedType instrumentedType) Prepares a given instrumented type.withAssigner(Assigner assigner) Configures an assigner to use with this invocation handler adapter.By default, anyMethodinstance that is handed over to anInvocationHandleris cached in a static field.Configures that the method constants supplied to the invocation handler adapter are resolved using anjava.security.AccessController.
-
Field Details
-
PREFIX
The prefix for field that are created for storing the instrumented value.- See Also:
-
invocationHandler
The invocation handler to which method interceptions are to be delegated.
-
-
Constructor Details
-
ForInstance
protected ForInstance(String fieldName, boolean cached, boolean privileged, boolean returning, Assigner assigner, 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 theMethodinstances that are handed to the intercepted methods are cached instaticfields.privileged- Determines if theMethodinstances are retrieved by using anjava.security.AccessController.returning- Determines if this implementation is returning the result value or is dropping it.assigner- The assigner to apply when defining this implementation.invocationHandler- The invocation handler to which all method calls are delegated.
-
-
Method Details
-
withoutMethodCache
Description copied from class:InvocationHandlerAdapterBy default, anyMethodinstance that is handed over to anInvocationHandleris cached in a static field. By invoking this method, this feature can be disabled.- Specified by:
withoutMethodCachein classInvocationHandlerAdapter- Returns:
- A similar invocation handler adapter that applies caching.
-
withAssigner
Description copied from class:InvocationHandlerAdapterConfigures an assigner to use with this invocation handler adapter.- Specified by:
withAssignerin interfaceInvocationHandlerAdapter.AssignerConfigurable- Specified by:
withAssignerin classInvocationHandlerAdapter- Parameters:
assigner- The assigner to apply when defining this implementation.- Returns:
- This instrumentation with the given
assignerconfigured.
-
withPrivilegedLookup
Description copied from class:InvocationHandlerAdapterConfigures that the method constants supplied to the invocation handler adapter are resolved using anjava.security.AccessController.- Specified by:
withPrivilegedLookupin interfaceInvocationHandlerAdapter.WithoutPrivilegeConfiguration- Specified by:
withPrivilegedLookupin classInvocationHandlerAdapter- Returns:
- This instrumentation with a privileged lookup configured.
-
andThen
Appends the supplied implementation to this implementation.- Specified by:
andThenin interfaceImplementation.Composable- Parameters:
implementation- The subsequent implementation.- Returns:
- An implementation that combines this implementation with the provided one.
-
andThen
Appends the supplied composable implementation to this implementation.- Specified by:
andThenin interfaceImplementation.Composable- Parameters:
implementation- The subsequent composable implementation.- Returns:
- A composable implementation that combines this implementation with the provided one.
-
prepare
Prepares a given instrumented type.- Specified by:
preparein interfaceInstrumentedType.Prepareable- Parameters:
instrumentedType- The instrumented type in its current form.- Returns:
- The prepared instrumented type.
-
appender
Creates a byte code appender that determines the implementation of the instrumented type's methods.- Specified by:
appenderin 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).
-