protected class AgentBuilder.Default.Matched extends Object implements AgentBuilder.Identified.Extendable
AgentBuilder.Default after supplying
a AgentBuilder.RawMatcher such that one or several
AgentBuilder.Transformers can be supplied.AgentBuilder.BinaryLocator, AgentBuilder.Default, AgentBuilder.Identified, AgentBuilder.InitializationStrategy, AgentBuilder.LambdaInstrumentationStrategy, AgentBuilder.Listener, AgentBuilder.RawMatcher, AgentBuilder.RedefinitionStrategy, AgentBuilder.Transformer, AgentBuilder.TypeStrategyAgentBuilder.Identified.Extendable| Modifier | Constructor and Description |
|---|---|
protected |
Matched(AgentBuilder.RawMatcher rawMatcher,
AgentBuilder.Transformer transformer)
Creates a new matched default agent builder.
|
| Modifier and Type | Method and Description |
|---|---|
AgentBuilder |
disableBootstrapInjection()
Disables injection of auxiliary classes into the bootstrap class path.
|
AgentBuilder |
disableNativeMethodPrefix()
Disables the use of a native method prefix for instrumented methods.
|
AgentBuilder |
enableBootstrapInjection(File folder,
Instrumentation instrumentation)
Enables class injection of auxiliary classes into the bootstrap class loader.
|
AgentBuilder |
enableNativeMethodPrefix(String prefix)
Enables the use of the given native method prefix for instrumented methods.
|
boolean |
equals(Object other) |
int |
hashCode() |
AgentBuilder |
ignore(ElementMatcher<? super TypeDescription> ignoredTypes)
Excludes any type that is matched by the provided matcher from instrumentation.
|
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. |
protected AgentBuilder |
materialize()
Materializes the currently described
AgentBuilder.Default.Transformation. |
String |
toString() |
AgentBuilder.Identified.Extendable |
transform(AgentBuilder.Transformer transformer)
Applies the given transformer for the already supplied matcher.
|
AgentBuilder.Identified |
type(AgentBuilder.RawMatcher matcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformers before loading this type. |
AgentBuilder.Identified |
type(ElementMatcher<? super TypeDescription> typeMatcher)
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformers 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.Transformers before loading this type. |
AgentBuilder |
with(AccessControlContext accessControlContext)
Defines classes to be loaded using the given access control context.
|
AgentBuilder |
with(AgentBuilder.BinaryLocator binaryLocator)
Defines the use of the given binary locator for locating binary data to given class names.
|
AgentBuilder |
with(AgentBuilder.InitializationStrategy initializationStrategy)
Defines a given initialization strategy to be applied to generated types.
|
AgentBuilder |
with(AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy)
Enables or disables management of the JVM's
LambdaMetafactory which is responsible for creating classes that
implement lambda expressions. |
AgentBuilder |
with(AgentBuilder.Listener listener)
Defines the given
AgentBuilder.Listener to be notified by the created agent. |
AgentBuilder |
with(AgentBuilder.RedefinitionStrategy redefinitionStrategy)
Specifies a strategy for modifying existing types.
|
AgentBuilder |
with(AgentBuilder.TypeStrategy typeStrategy)
Defines the use of the given definition handler that determines if a type should be rebased or redefined.
|
AgentBuilder |
with(ByteBuddy byteBuddy)
Defines the given
ByteBuddy instance to be used by the created agent. |
protected Matched(AgentBuilder.RawMatcher rawMatcher, AgentBuilder.Transformer transformer)
rawMatcher - The supplied raw matcher.transformer - The supplied transformer.public AgentBuilder.Identified.Extendable transform(AgentBuilder.Transformer transformer)
AgentBuilder.Identifiedtransform in interface AgentBuilder.Identifiedtransformer - The transformer to apply.public AgentBuilder.Identified type(AgentBuilder.RawMatcher matcher)
AgentBuilder
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformers before loading this type.
Note: When applying a matcher, regard the performance implications by
AgentBuilder.ignore(ElementMatcher). The former matcher is applied first such that it makes sense
to ignore name spaces that are irrelevant to instrumentation. If possible, it is also recommended, to
exclude class loaders such as for example the bootstrap class loader.
type in interface AgentBuildermatcher - A matcher that decides if the entailed
AgentBuilder.Transformers should be applied for a type that
is being loaded.AgentBuilder.Transformers to be applied when the given matcher
indicates a match.public AgentBuilder.Identified type(ElementMatcher<? super TypeDescription> typeMatcher)
AgentBuilder
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformers before loading this type.
Note: When applying a matcher, regard the performance implications by
AgentBuilder.ignore(ElementMatcher). The former matcher is applied first such that it makes sense
to ignore name spaces that are irrelevant to instrumentation. If possible, it is also recommended, to exclude
class loaders such as for example the bootstrap class loader by using
AgentBuilder.type(ElementMatcher, ElementMatcher) instead.
type in interface AgentBuildertypeMatcher - An ElementMatcher that is applied on the type being loaded that
decides if the entailed AgentBuilder.Transformers should
be applied for that type.AgentBuilder.Transformers to be applied when the given typeMatcher
indicates a match.public AgentBuilder.Identified type(ElementMatcher<? super TypeDescription> typeMatcher, ElementMatcher<? super ClassLoader> classLoaderMatcher)
AgentBuilder
Matches a type being loaded in order to apply the supplied
AgentBuilder.Transformers before loading this type.
Note: When applying a matcher, regard the performance implications by
AgentBuilder.ignore(ElementMatcher). The former matcher is applied first such that it makes sense
to ignore name spaces that are irrelevant to instrumentation.
type in interface AgentBuildertypeMatcher - An ElementMatcher that is applied on the type being
loaded that decides if the entailed
AgentBuilder.Transformers 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.Transformers to be applied when both the given
typeMatcher and classLoaderMatcher indicate a match.public AgentBuilder with(ByteBuddy byteBuddy)
AgentBuilderByteBuddy instance to be used by the created agent.with in interface AgentBuilderbyteBuddy - The Byte Buddy instance to be used.byteBuddy instance.public AgentBuilder with(AgentBuilder.Listener listener)
AgentBuilderAgentBuilder.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.with in interface AgentBuilderlistener - The listener to be notified.public AgentBuilder with(AgentBuilder.TypeStrategy typeStrategy)
AgentBuilderwith in interface AgentBuildertypeStrategy - The definition handler to use.public AgentBuilder with(AgentBuilder.BinaryLocator binaryLocator)
AgentBuilderwith in interface AgentBuilderbinaryLocator - The binary locator to use.public AgentBuilder with(AccessControlContext accessControlContext)
AgentBuilderwith in interface AgentBuilderaccessControlContext - The access control context to be used for loading classes.public AgentBuilder with(AgentBuilder.InitializationStrategy initializationStrategy)
AgentBuilderwith in interface AgentBuilderinitializationStrategy - The initialization strategy to use.public AgentBuilder with(AgentBuilder.RedefinitionStrategy redefinitionStrategy)
AgentBuilderwith in interface AgentBuilderredefinitionStrategy - The redefinition strategy to apply.public AgentBuilder with(AgentBuilder.LambdaInstrumentationStrategy lambdaInstrumentationStrategy)
AgentBuilder
Enables or disables management of the JVM's LambdaMetafactory which is responsible for creating classes that
implement lambda expressions. Without this feature enabled, classes that are represented by lambda expressions are
not instrumented by the JVM such that Java agents have no effect on them when a lambda expression's class is loaded
for the first time.
When activating this feature, Byte Buddy instruments the LambdaMetafactory and takes over the responsibility
of creating classes that represent lambda expressions. In doing so, Byte Buddy has the opportunity to apply the built
class file transformer. If the current VM does not support lambda expressions, activating this feature has no effect.
Important: If this feature is active, it is important to release the built class file transformer when
deactivating it. Normally, it is sufficient to call Instrumentation.removeTransformer(ClassFileTransformer).
When this feature is enabled, it is however also required to invoke
AgentBuilder.LambdaInstrumentationStrategy.release(ClassFileTransformer, Instrumentation). Otherwise, the executing VMs class
loader retains a reference to the class file transformer what can cause a memory leak.
with in interface AgentBuilderlambdaInstrumentationStrategy - true if this feature should be enabled.public AgentBuilder enableBootstrapInjection(File folder, Instrumentation instrumentation)
AgentBuilderenableBootstrapInjection in interface AgentBuilderfolder - 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()
AgentBuilderdisableBootstrapInjection in interface AgentBuilderpublic AgentBuilder enableNativeMethodPrefix(String prefix)
AgentBuilderInstrumentation.enableNativeMethodPrefix in interface AgentBuilderprefix - The prefix to be used.public AgentBuilder disableNativeMethodPrefix()
AgentBuilderdisableNativeMethodPrefix in interface AgentBuilderpublic AgentBuilder ignore(ElementMatcher<? super TypeDescription> ignoredTypes)
AgentBuilderExcludes any type that is matched by the provided matcher from instrumentation. By default, Byte Buddy does not instrument synthetic types.
Note: For performance reasons, it is recommended to always include a matcher that excludes as many namespaces as possible. Byte Buddy can determine a type's name without parsing its class file and can therefore discard such types prematurely. When a different property of a type - such as for example its modifiers or its annotations is accessed - Byte Buddy parses the class file lazily in order to allow for such a matching. Therefore, any exclusion of a name should always be done as a first step and even if it does not influence the selection of what types are matched. Without changing this property, the class file of every type is being parsed!
ignore in interface AgentBuilderignoredTypes - A matcher that identifies types that should not be instrumented.public ClassFileTransformer makeRaw()
AgentBuilderClassFileTransformer that implements the configuration of this
agent builder.makeRaw in interface AgentBuilderpublic ClassFileTransformer installOn(Instrumentation instrumentation)
AgentBuilderClassFileTransformer 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 AgentBuilderinstrumentation - The instrumentation on which this agent builder's configuration is to be installed.public ClassFileTransformer installOnByteBuddyAgent()
AgentBuilderClassFileTransformer 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 AgentBuilderprotected AgentBuilder materialize()
AgentBuilder.Default.Transformation.Copyright © 2014–2016. All rights reserved.