public abstract class InvocationHandlerAdapter extends Object implements Implementation
InvocationHandler. The adapter allows the invocation handler
 to also intercept method calls to non-interface methods.| Modifier and Type | Class and Description | 
|---|---|
| protected static interface  | InvocationHandlerAdapter.AssignerConfigurableAllows for the configuration of an  Assignerof anInvocationHandlerAdapter. | 
| protected static class  | InvocationHandlerAdapter.ForInstanceDelegationAn implementation of an  InvocationHandlerAdapterthat delegates method
 invocations to an adapter that is stored in an instance field. | 
| protected static class  | InvocationHandlerAdapter.ForStaticDelegationAn implementation of an  InvocationHandlerAdapterthat delegates method
 invocations to an adapter that is stored in a static field. | 
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.Target| 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 | cacheMethodsDetermines if the  Methodinstances that are handed to the intercepted methods are
 cached instaticfields. | 
| protected static boolean | CACHINGIndicates that a  Methodshould be cached. | 
| protected String | fieldNameThe name of the field for storing an invocation handler. | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | InvocationHandlerAdapter(String fieldName,
                        boolean cacheMethods,
                        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,
     TypeDescription instrumentedType,
     StackManipulation preparingManipulation)Applies an implementation that delegates to a invocation handler. | 
| boolean | equals(Object other) | 
| int | hashCode() | 
| 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 | toInstanceField(String fieldName)Creates an implementation for any  InvocationHandlerthat delegates
 all method interceptions to apublicinstance field with the given name. | 
| abstract InvocationHandlerAdapter.AssignerConfigurable | withMethodCache()By default, any  Methodinstance that is handed over to anInvocationHandleris created on each invocation of the method. | 
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitappenderprepareprotected static final boolean CACHING
Method should be cached.protected final String fieldName
protected final Assigner assigner
protected final boolean cacheMethods
Method instances that are handed to the intercepted methods are
 cached in static fields.protected InvocationHandlerAdapter(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 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 toInstanceField(String fieldName)
InvocationHandler that delegates
 all method interceptions to a public instance field with the given name. This field has to be
 set before any invocations are intercepted. Otherwise, a NullPointerException will be
 thrown.fieldName - The name of the field.public abstract InvocationHandlerAdapter.AssignerConfigurable withMethodCache()
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.Method instance
 in form of a static field.protected ByteCodeAppender.Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod, TypeDescription instrumentedType, StackManipulation preparingManipulation)
methodVisitor - The method visitor for writing the byte code to.implementationContext - The implementation context for the current implementation.instrumentedMethod - The method that is instrumented.instrumentedType - The type that is instrumented.preparingManipulation - A stack manipulation that applies any preparation to the operand stack.Copyright © 2014–2016. All rights reserved.