@HashCodeAndEqualsPlugin.Enhance public abstract class InvocationHandlerAdapter extends Object implements Implementation.Composable
InvocationHandler. The adapter allows the invocation handler
 to also intercept method calls to non-interface methods.| Modifier and Type | Class and Description | 
|---|---|
| static interface  | InvocationHandlerAdapter.AssignerConfigurableAllows for the configuration of an  Assignerof anInvocationHandlerAdapter. | 
| protected static class  | InvocationHandlerAdapter.ForFieldAn implementation of an  InvocationHandlerAdapterthat delegates method
 invocations to an adapter that is stored in an instance field. | 
| protected static class  | InvocationHandlerAdapter.ForInstanceAn implementation of an  InvocationHandlerAdapterthat delegates method
 invocations to an adapter that is stored in a static field. | 
| static interface  | InvocationHandlerAdapter.WithoutPrivilegeConfigurationAllows the configuration of privileged lookup for the resolution of  Methodconstants that are provided to the invocation handler. | 
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.TargetInstrumentedType.Prepareable.NoOp| Modifier and Type | Field and Description | 
|---|---|
| protected Assigner | assignerThe assigner that is used for assigning the return invocation handler's return value to the
 intercepted method's return value. | 
| protected boolean | cachedDetermines if the  Methodinstances that are handed to the intercepted methods are
 cached instaticfields. | 
| protected String | fieldNameThe name of the field for storing an invocation handler. | 
| protected boolean | privilegedDetermines if the  Methodinstances are retrieved by using anjava.security.AccessController. | 
| protected boolean | returningDetermines if this implementation is returning the result value or is dropping it. | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | InvocationHandlerAdapter(String fieldName,
                        boolean cached,
                        boolean privileged,
                        boolean returning,
                        Assigner assigner)Creates a new invocation handler for a given field. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected ByteCodeAppender.Size | apply(MethodVisitor methodVisitor,
     Implementation.Context implementationContext,
     MethodDescription instrumentedMethod,
     StackManipulation preparingManipulation,
     FieldDescription fieldDescription)Applies an implementation that delegates to a invocation handler. | 
| static InvocationHandlerAdapter | of(InvocationHandler invocationHandler)Creates an implementation for any instance of an  InvocationHandlerthat delegates
 all method interceptions to the given instance which will be stored in astaticfield. | 
| static InvocationHandlerAdapter | of(InvocationHandler invocationHandler,
  String fieldName)Creates an implementation for any instance of an  InvocationHandlerthat delegates
 all method interceptions to the given instance which will be stored in astaticfield. | 
| static InvocationHandlerAdapter | toField(String name)Creates an implementation for any  InvocationHandlerthat delegates
 all method interceptions to a field with the given name. | 
| static InvocationHandlerAdapter | toField(String name,
       FieldLocator.Factory fieldLocatorFactory)Creates an implementation for any  InvocationHandlerthat delegates
 all method interceptions to a field with the given name. | 
| abstract Implementation | withAssigner(Assigner assigner)Configures an assigner to use with this invocation handler adapter. | 
| abstract InvocationHandlerAdapter.WithoutPrivilegeConfiguration | withoutMethodCache()By default, any  Methodinstance that is handed over to anInvocationHandleris cached in a static field. | 
| abstract InvocationHandlerAdapter.AssignerConfigurable | withPrivilegedLookup()Configures that the method constants supplied to the invocation handler adapter are resolved using an  java.security.AccessController. | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitandThen, andThenappenderprepareprotected final String fieldName
protected final boolean cached
Method instances that are handed to the intercepted methods are
 cached in static fields.protected final boolean privileged
Method instances are retrieved by using an java.security.AccessController.protected final boolean returning
protected final Assigner assigner
protected InvocationHandlerAdapter(String fieldName, boolean cached, boolean privileged, boolean returning, Assigner assigner)
fieldName - The name of the field.cached - Determines if the Method instances that are handed to the
                   intercepted methods are cached in static fields.privileged - Determines if the Method instances are retrieved by using an java.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.public static InvocationHandlerAdapter of(InvocationHandler invocationHandler)
InvocationHandler that delegates
 all method interceptions to the given instance which will be stored in a static field.invocationHandler - The invocation handler to which all method calls are delegated.public static InvocationHandlerAdapter of(InvocationHandler invocationHandler, String fieldName)
InvocationHandler that delegates
 all method interceptions to the given instance which will be stored in a static field.invocationHandler - The invocation handler to which all method calls are delegated.fieldName - The name of the field.public static InvocationHandlerAdapter toField(String name)
InvocationHandler that delegates
 all method interceptions to a field with the given name. This field has to be of a subtype of invocation
 handler and needs to be set before any invocations are intercepted. Otherwise, a NullPointerException
 will be thrown.name - The name of the field.public static InvocationHandlerAdapter toField(String name, FieldLocator.Factory fieldLocatorFactory)
InvocationHandler that delegates
 all method interceptions to a field with the given name. This field has to be of a subtype of invocation
 handler and needs to be set before any invocations are intercepted. Otherwise, a NullPointerException
 will be thrown.name - The name of the field.fieldLocatorFactory - The field locator factorypublic abstract InvocationHandlerAdapter.WithoutPrivilegeConfiguration withoutMethodCache()
Method instance that is handed over to an
 InvocationHandler is cached in a static field. By invoking this method,
 this feature can be disabled.public abstract Implementation withAssigner(Assigner assigner)
assigner - The assigner to apply when defining this implementation.assigner configured.public abstract InvocationHandlerAdapter.AssignerConfigurable withPrivilegedLookup()
java.security.AccessController.protected ByteCodeAppender.Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod, StackManipulation preparingManipulation, FieldDescription fieldDescription)
methodVisitor - The method visitor for writing the byte code to.implementationContext - The implementation context for the current implementation.instrumentedMethod - The method that is instrumented.preparingManipulation - A stack manipulation that applies any preparation to the operand stack.fieldDescription - The field that contains the value for the invocation handler.Copyright © 2014–2023. All rights reserved.