Class DataAccessor
- java.lang.Object
-
- software.amazon.disco.agent.interception.templates.DataAccessor
-
- All Implemented Interfaces:
Installable
public class DataAccessor extends java.lang.Object implements Installable
A generic template for creating efficient reflection-free accessors onto Objects for interceptors, where no compile-time dependency on the Object's class can safely be taken (which is most or all of the time). This mechanism may make mocking the target objects harder in tests, because the inserted Accessor interface will also have its methods mocked. Test authors may prefer to construct real objects instead of mocks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDataAccessor.ExceptionSafetyAn Advice class to wrap generated methods in catch-all exception safety.
-
Constructor Summary
Constructors Modifier Constructor Description protectedDataAccessor(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> typeImplementingAccessor, net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> typesImplementingAccessMethods, java.lang.Class<?> accessor)Protected constructor for factory access
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataAccessorforClassNamed(java.lang.String className, java.lang.Class<?> accessor)Factory method to create a DataAccessor which allows access to corresponding methods of the given exact classstatic DataAccessorforConcreteSubclassesOfInterface(java.lang.String interfaceName, java.lang.Class<?> accessor)Factory method to create a DataAccessor which allows access to the corresponding methods of any concrete subclasses of the given interfacenet.bytebuddy.agent.builder.AgentBuilderinstall(net.bytebuddy.agent.builder.AgentBuilder agentBuilder)Install the necessary hooks for this piece of DiSCo functionality.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface software.amazon.disco.agent.interception.Installable
handleArguments
-
-
-
-
Constructor Detail
-
DataAccessor
protected DataAccessor(net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> typeImplementingAccessor, net.bytebuddy.matcher.ElementMatcher<net.bytebuddy.description.type.TypeDescription> typesImplementingAccessMethods, java.lang.Class<?> accessor)Protected constructor for factory access- Parameters:
typeImplementingAccessor- ElementMatcher describing the class to implement the accessor, usually some lowest-common denominator base or interfaceaccessor- Accessor interface declaring the methods to use for access
-
-
Method Detail
-
forClassNamed
public static DataAccessor forClassNamed(java.lang.String className, java.lang.Class<?> accessor)
Factory method to create a DataAccessor which allows access to corresponding methods of the given exact class- Parameters:
className- the exact className to project data access ontoaccessor- the accessor defining the access methods- Returns:
- a constructed DataAccessor
-
forConcreteSubclassesOfInterface
public static DataAccessor forConcreteSubclassesOfInterface(java.lang.String interfaceName, java.lang.Class<?> accessor)
Factory method to create a DataAccessor which allows access to the corresponding methods of any concrete subclasses of the given interface- Parameters:
interfaceName- the name of the interface, for which implementing classes will have access methods definedaccessor- the accessor defining the access methods- Returns:
- a constructed DataAccessor
-
install
public net.bytebuddy.agent.builder.AgentBuilder install(net.bytebuddy.agent.builder.AgentBuilder agentBuilder)
Install the necessary hooks for this piece of DiSCo functionality.- Specified by:
installin interfaceInstallable- Parameters:
agentBuilder- - an AgentBuilder to append instructions to- Returns:
- - the same AgentBuilder instance, for continuation/chaining, or null to prevent installation of the agentBuilder, in case the Installable instance does not require this instrumentation to take place.
-
-