public interface AgentBuilder
An agent builder provides a convenience API for defining a
Java agent using
Byte Buddy's
ByteBuddy.rebase(TypeDescription, ClassFileLocator)
.
When defining several AgentBuilder.Transformer
s, the agent builder always
applies the transformers that were supplied with the last applicable matcher. Therefore, more general transfromers
should be defined first.
Modifier and Type | Interface and Description |
---|---|
static interface |
AgentBuilder.BinaryLocator
A binary locator allows to specify how binary data is located by an
AgentBuilder . |
static class |
AgentBuilder.Default
The default implementation of an
AgentBuilder . |
static interface |
AgentBuilder.Identified
Describes an
AgentBuilder which was handed a matcher for identifying
types to instrumented in order to supply one or several
AgentBuilder.Transformer s. |
static interface |
AgentBuilder.Listener
A listener that is informed about events that occur during an instrumentation process.
|
static interface |
AgentBuilder.RawMatcher
A matcher that allows to determine if a
AgentBuilder.Transformer
should be applied during the execution of a ClassFileTransformer that was
generated by an AgentBuilder . |
static interface |
AgentBuilder.Transformer
A transformer allows to apply modifications to a
DynamicType . |
Modifier and Type | Method and Description |
---|---|
AgentBuilder |
allowRetransformation()
Enables retransformation when this agent is installed.
|
AgentBuilder |
disableSelfInitialization()
Disables the execution of any
LoadedTypeInitializer s that are registered
with a DynamicType . |
AgentBuilder |
enableBootstrapInjection(File folder,
Instrumentation instrumentation)
Enables class injection of auxiliary classes into the bootstrap class loader.
|
ClassFileTransformer |
installOn(Instrumentation instrumentation)
Creates and installs a
ClassFileTransformer that implements the configuration of
this agent builder with a given Instrumentation . |
ClassFileTransformer |
installOnByteBuddyAgent()
Creates and installs a
ClassFileTransformer that implements the configuration of
this agent builder with the Byte Buddy-agent which must be installed prior to calling this method. |
ClassFileTransformer |
makeRaw()
Creates a
ClassFileTransformer that implements the configuration of this
agent builder. |
AgentBuilder.Identified |
rebase(AgentBuilder.RawMatcher matcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformer s before loading this type. |
AgentBuilder.Identified |
rebase(ElementMatcher<? super TypeDescription> typeMatcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformer s before loading this type. |
AgentBuilder.Identified |
rebase(ElementMatcher<? super TypeDescription> typeMatcher,
ElementMatcher<? super ClassLoader> classLoaderMatcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformer s before loading this type. |
AgentBuilder |
withBinaryLocator(AgentBuilder.BinaryLocator binaryLocator)
Defines the use of the given binary locator for locating binary data to given class names.
|
AgentBuilder |
withByteBuddy(ByteBuddy byteBuddy)
Defines the given
ByteBuddy instance to be used by the created agent. |
AgentBuilder |
withListener(AgentBuilder.Listener listener)
Defines the given
AgentBuilder.Listener to be notified by the created agent. |
AgentBuilder |
withNativeMethodPrefix(String prefix)
Enables the use of the given native method prefix for instrumented methods.
|
AgentBuilder.Identified rebase(AgentBuilder.RawMatcher matcher)
AgentBuilder.Transformer
s before loading this type.matcher
- A matcher that decides if the entailed
AgentBuilder.Transformer
s should be applied for a type that
is being loaded.AgentBuilder.Transformer
s to be applied when the given matcher
indicates a match.AgentBuilder.Identified rebase(ElementMatcher<? super TypeDescription> typeMatcher)
AgentBuilder.Transformer
s before loading this type.typeMatcher
- An ElementMatcher
that is applied on the type being loaded that
decides if the entailed
AgentBuilder.Transformer
s should be applied for that
type.AgentBuilder.Transformer
s to be applied when the given typeMatcher
indicates a match.AgentBuilder.Identified rebase(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher)
AgentBuilder.Transformer
s before loading this type.typeMatcher
- An ElementMatcher
that is applied on the type being
loaded that decides if the entailed
AgentBuilder.Transformer
s should be applied for
that type.classLoaderMatcher
- An ElementMatcher
that is applied to the
ClassLoader
that is loading the type being loaded. This matcher
is always applied first where the type matcher is not applied in case that this
matcher does not indicate a match.AgentBuilder.Transformer
s to be applied when both the given
typeMatcher
and classLoaderMatcher
indicate a match.AgentBuilder withByteBuddy(ByteBuddy byteBuddy)
ByteBuddy
instance to be used by the created agent.byteBuddy
- The Byte Buddy instance to be used.byteBuddy
instance.AgentBuilder withListener(AgentBuilder.Listener listener)
AgentBuilder.Listener
to be notified by the created agent.
The given listener is notified after any other listener that is already registered. If a listener is registered
twice, it is also notified twice.listener
- The listener to be notified.AgentBuilder withBinaryLocator(AgentBuilder.BinaryLocator binaryLocator)
binaryLocator
- The binary locator to use.AgentBuilder withNativeMethodPrefix(String prefix)
Instrumentation
.prefix
- The prefix to be used.AgentBuilder disableSelfInitialization()
Disables the execution of any LoadedTypeInitializer
s that are registered
with a DynamicType
. This might cause the dynamic type to malfunction if the
LoadedTypeInitializer
are not executed elsewhere before an instrumented
type is put in use for the first time.
In order to execute a self initialization, Byte Buddy adds a call back into any dynamic type's type initializer.
This call back requires the injection of a call back dispatcher into the system class loader what might not
be a feasible solution on distributed applications where classes are shared among different JVMs where a
different strategy for executing LoadedTypeInitializer
s might be
more appropriate.
AgentBuilder allowRetransformation()
AgentBuilder enableBootstrapInjection(File folder, Instrumentation instrumentation)
folder
- The folder in which jar files of the injected classes are to be stored.instrumentation
- The instrumentation instance that is used for appending jar files to the
bootstrap class path.ClassFileTransformer makeRaw()
ClassFileTransformer
that implements the configuration of this
agent builder.ClassFileTransformer installOn(Instrumentation instrumentation)
ClassFileTransformer
that implements the configuration of
this agent builder with a given Instrumentation
.instrumentation
- The instrumentation on which this agent builder's configuration is to be installed.ClassFileTransformer installOnByteBuddyAgent()
ClassFileTransformer
that implements the configuration of
this agent builder with the Byte Buddy-agent which must be installed prior to calling this method.Copyright © 2014–2015. All rights reserved.