public static class AgentBuilder.Default extends Object implements AgentBuilder
AgentBuilder
.Modifier and Type | Class and Description |
---|---|
protected static interface |
AgentBuilder.Default.BootstrapInjectionStrategy
An injection strategy for injecting classes into the bootstrap class loader.
|
protected static class |
AgentBuilder.Default.ExecutingTransformer
A
ClassFileTransformer that implements the enclosing agent builder's
configuration. |
protected class |
AgentBuilder.Default.Matched
A helper class that describes a
AgentBuilder.Default after supplying
a AgentBuilder.RawMatcher such that one or several
AgentBuilder.Transformer s can be supplied. |
protected static interface |
AgentBuilder.Default.NativeMethodStrategy
A strategy for determining if a native method name prefix should be used when rebasing methods.
|
protected static interface |
AgentBuilder.Default.Transformation
A transformation serves as a handler for modifying a class.
|
AgentBuilder.BinaryLocator, AgentBuilder.Default, AgentBuilder.Identified, AgentBuilder.InitializationStrategy, AgentBuilder.Listener, AgentBuilder.RawMatcher, AgentBuilder.RedefinitionStrategy, AgentBuilder.Transformer, AgentBuilder.TypeStrategy
Modifier | Constructor and Description |
---|---|
|
Default()
Creates a new default agent builder that uses a default
ByteBuddy instance for
creating classes. |
|
Default(ByteBuddy byteBuddy)
Creates a new agent builder with default settings.
|
protected |
Default(ByteBuddy byteBuddy,
AgentBuilder.BinaryLocator binaryLocator,
AgentBuilder.TypeStrategy typeStrategy,
AgentBuilder.Listener listener,
AgentBuilder.Default.NativeMethodStrategy nativeMethodStrategy,
AccessControlContext accessControlContext,
AgentBuilder.InitializationStrategy initializationStrategy,
AgentBuilder.RedefinitionStrategy redefinitionStrategy,
AgentBuilder.Default.BootstrapInjectionStrategy bootstrapInjectionStrategy,
AgentBuilder.Default.Transformation transformation)
Creates a new default agent builder.
|
Modifier and Type | Method and Description |
---|---|
AgentBuilder |
disableBootstrapInjection()
Disables injection of auxiliary classes into the bootstrap class path.
|
AgentBuilder |
enableBootstrapInjection(File folder,
Instrumentation instrumentation)
Enables class injection of auxiliary classes into the bootstrap class loader.
|
boolean |
equals(Object other) |
int |
hashCode() |
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. |
String |
toString() |
AgentBuilder.Identified |
type(AgentBuilder.RawMatcher matcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformer s before loading this type. |
AgentBuilder.Identified |
type(ElementMatcher<? super TypeDescription> typeMatcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformer s before loading this type. |
AgentBuilder.Identified |
type(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 |
withAccessControlContext(AccessControlContext accessControlContext)
Defines classes to be loaded using the given access control context.
|
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 |
withInitializationStrategy(AgentBuilder.InitializationStrategy initializationStrategy)
Defines a given initialization strategy to be applied to generated types.
|
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 |
withoutNativeMethodPrefix()
Disables the use of a native method prefix for instrumented methods.
|
AgentBuilder |
withRedefinitionStrategy(AgentBuilder.RedefinitionStrategy redefinitionStrategy)
Specifies a strategy for modifying existing types.
|
AgentBuilder |
withTypeStrategy(AgentBuilder.TypeStrategy typeStrategy)
Defines the use of the given definition handler that determines if a type should be rebased or redefined.
|
public Default()
ByteBuddy
instance for
creating classes.public Default(ByteBuddy byteBuddy)
byteBuddy
- The Byte Buddy instance to be used.protected Default(ByteBuddy byteBuddy, AgentBuilder.BinaryLocator binaryLocator, AgentBuilder.TypeStrategy typeStrategy, AgentBuilder.Listener listener, AgentBuilder.Default.NativeMethodStrategy nativeMethodStrategy, AccessControlContext accessControlContext, AgentBuilder.InitializationStrategy initializationStrategy, AgentBuilder.RedefinitionStrategy redefinitionStrategy, AgentBuilder.Default.BootstrapInjectionStrategy bootstrapInjectionStrategy, AgentBuilder.Default.Transformation transformation)
byteBuddy
- The Byte Buddy instance to be used.binaryLocator
- The binary locator to use.typeStrategy
- The definition handler to use.listener
- The listener to notify on transformations.nativeMethodStrategy
- The native method strategy to apply.accessControlContext
- The access control context to use for loading classes.initializationStrategy
- The initialization strategy to use for transformed types.redefinitionStrategy
- The redefinition strategy to apply.bootstrapInjectionStrategy
- The injection strategy for injecting classes into the bootstrap class loader.transformation
- The transformation object for handling type transformations.public AgentBuilder.Identified type(AgentBuilder.RawMatcher matcher)
AgentBuilder
AgentBuilder.Transformer
s before loading this type.type
in interface AgentBuilder
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.public AgentBuilder.Identified type(ElementMatcher<? super TypeDescription> typeMatcher)
AgentBuilder
AgentBuilder.Transformer
s before loading this type.type
in interface AgentBuilder
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.public AgentBuilder.Identified type(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher)
AgentBuilder
AgentBuilder.Transformer
s before loading this type.type
in interface AgentBuilder
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.public AgentBuilder withByteBuddy(ByteBuddy byteBuddy)
AgentBuilder
ByteBuddy
instance to be used by the created agent.withByteBuddy
in interface AgentBuilder
byteBuddy
- The Byte Buddy instance to be used.byteBuddy
instance.public AgentBuilder withListener(AgentBuilder.Listener listener)
AgentBuilder
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.withListener
in interface AgentBuilder
listener
- The listener to be notified.public AgentBuilder withTypeStrategy(AgentBuilder.TypeStrategy typeStrategy)
AgentBuilder
withTypeStrategy
in interface AgentBuilder
typeStrategy
- The definition handler to use.public AgentBuilder withBinaryLocator(AgentBuilder.BinaryLocator binaryLocator)
AgentBuilder
withBinaryLocator
in interface AgentBuilder
binaryLocator
- The binary locator to use.public AgentBuilder withNativeMethodPrefix(String prefix)
AgentBuilder
Instrumentation
.withNativeMethodPrefix
in interface AgentBuilder
prefix
- The prefix to be used.public AgentBuilder withoutNativeMethodPrefix()
AgentBuilder
withoutNativeMethodPrefix
in interface AgentBuilder
public AgentBuilder withAccessControlContext(AccessControlContext accessControlContext)
AgentBuilder
withAccessControlContext
in interface AgentBuilder
accessControlContext
- The access control context to be used for loading classes.public AgentBuilder withRedefinitionStrategy(AgentBuilder.RedefinitionStrategy redefinitionStrategy)
AgentBuilder
withRedefinitionStrategy
in interface AgentBuilder
redefinitionStrategy
- The redefinition strategy to apply.public AgentBuilder withInitializationStrategy(AgentBuilder.InitializationStrategy initializationStrategy)
AgentBuilder
withInitializationStrategy
in interface AgentBuilder
initializationStrategy
- The initialization strategy to use.public AgentBuilder enableBootstrapInjection(File folder, Instrumentation instrumentation)
AgentBuilder
enableBootstrapInjection
in interface AgentBuilder
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.public AgentBuilder disableBootstrapInjection()
AgentBuilder
disableBootstrapInjection
in interface AgentBuilder
public ClassFileTransformer makeRaw()
AgentBuilder
ClassFileTransformer
that implements the configuration of this
agent builder.makeRaw
in interface AgentBuilder
public ClassFileTransformer installOn(Instrumentation instrumentation)
AgentBuilder
ClassFileTransformer
that implements the configuration of
this agent builder with a given Instrumentation
. If retransformation is enabled,
the installation also causes all loaded types to be retransformed.installOn
in interface AgentBuilder
instrumentation
- The instrumentation on which this agent builder's configuration is to be installed.public ClassFileTransformer installOnByteBuddyAgent()
AgentBuilder
ClassFileTransformer
that implements the configuration of
this agent builder with the Byte Buddy-agent which must be installed prior to calling this method.installOnByteBuddyAgent
in interface AgentBuilder
Copyright © 2014–2015. All rights reserved.