Package net.bytebuddy.build
Class Plugin.Engine.Default
- java.lang.Object
-
- net.bytebuddy.build.Plugin.Engine.AbstractBase
-
- net.bytebuddy.build.Plugin.Engine.Default
-
- All Implemented Interfaces:
Plugin.Engine
- Enclosing interface:
- Plugin.Engine
@Enhance public static class Plugin.Engine.Default extends Plugin.Engine.AbstractBase
A default implementation of a plugin engine.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
Plugin.Engine.Default.Preprocessor
A preprocessor for a parallel plugin engine.protected static class
Plugin.Engine.Default.SourceEntryPrependingClassFileLocator
A class file locator that shadows a givenPlugin.Engine.Source.Element
's type with the explicit element.-
Nested classes/interfaces inherited from interface net.bytebuddy.build.Plugin.Engine
Plugin.Engine.AbstractBase, Plugin.Engine.Default, Plugin.Engine.Dispatcher, Plugin.Engine.ErrorHandler, Plugin.Engine.Listener, Plugin.Engine.PoolStrategy, Plugin.Engine.Source, Plugin.Engine.Summary, Plugin.Engine.Target, Plugin.Engine.TypeStrategy
-
-
Field Summary
Fields Modifier and Type Field Description private ByteBuddy
byteBuddy
The Byte Buddy instance to use.private ClassFileLocator
classFileLocator
The class file locator to use.private ClassFileVersion
classFileVersion
The class file version to use for multi-release jars, ornull
.private Plugin.Engine.Dispatcher.Factory
dispatcherFactory
The dispatcher factory to use.private Plugin.Engine.ErrorHandler
errorHandler
The error handler to use.private ElementMatcher.Junction<? super TypeDescription>
ignoredTypeMatcher
A matcher for types to exclude from transformation.private Plugin.Engine.Listener
listener
The listener to use.private Plugin.Engine.PoolStrategy
poolStrategy
The pool strategy to use.private Plugin.Engine.TypeStrategy
typeStrategy
The type strategy to use.-
Fields inherited from interface net.bytebuddy.build.Plugin.Engine
MODULE_INFO, PACKAGE_INFO, PLUGIN_FILE
-
-
Constructor Summary
Constructors Modifier Constructor Description Default()
Creates a new default plugin engine that rebases types and fails fast and on unresolved types and on live initializers.Default(ByteBuddy byteBuddy)
Creates a new default plugin engine that rebases types and fails fast and on unresolved types and on live initializers.protected
Default(ByteBuddy byteBuddy, Plugin.Engine.TypeStrategy typeStrategy)
Creates a new default plugin engine.protected
Default(ByteBuddy byteBuddy, Plugin.Engine.TypeStrategy typeStrategy, Plugin.Engine.PoolStrategy poolStrategy, ClassFileLocator classFileLocator, ClassFileVersion classFileVersion, Plugin.Engine.Listener listener, Plugin.Engine.ErrorHandler errorHandler, Plugin.Engine.Dispatcher.Factory dispatcherFactory, ElementMatcher.Junction<? super TypeDescription> ignoredTypeMatcher)
Creates a new default plugin engine.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Plugin.Engine.Summary
apply(Plugin.Engine.Source source, Plugin.Engine.Target target, java.util.List<? extends Plugin.Factory> factories)
Applies this plugin engine onto a given source and target.Plugin.Engine
ignore(ElementMatcher<? super TypeDescription> matcher)
Ignores all types that are matched by this matcher or any previously registered ignore matcher.static void
main(java.lang.String... argument)
Runs a plugin engine using the first and second argument as source and target file location and any additional argument as the fully qualified name of any plugin to apply.static Plugin.Engine
of(EntryPoint entryPoint, ClassFileVersion classFileVersion, MethodNameTransformer methodNameTransformer)
Creates a plugin engine from anEntryPoint
.static java.util.Set<java.lang.String>
scan(java.lang.ClassLoader classLoader)
Scans a class loader for plugins declared in a META-INF/net.bytebuddy/build.plugins file.Plugin.Engine
with(Plugin.Engine.Dispatcher.Factory dispatcherFactory)
Replaces the dispatcher factory of this plugin engine with the supplied dispatcher factory.Plugin.Engine
with(Plugin.Engine.Listener listener)
Appends the supplied listener to this engine.Plugin.Engine
with(Plugin.Engine.PoolStrategy poolStrategy)
Defines a new pool strategy that determines how types are being described.Plugin.Engine
with(Plugin.Engine.TypeStrategy typeStrategy)
Defines a new type strategy which determines the transformation mode for any instrumented type.Plugin.Engine
with(ByteBuddy byteBuddy)
Defines a new Byte Buddy instance for usage for type creation.Plugin.Engine
with(ClassFileVersion classFileVersion)
Uses the suppliedClassFileVersion
as a base for resolving multi-release jars, ornull
if multi-release jars should not be resolved but be treated as regular jar files.Plugin.Engine
with(ClassFileLocator classFileLocator)
Appends the supplied class file locator to be queried for class files additionally to any previously registered class file locators.Plugin.Engine
withErrorHandlers(java.util.List<? extends Plugin.Engine.ErrorHandler> errorHandlers)
Replaces the error handlers of this plugin engine with the supplied error handlers.Plugin.Engine
withoutErrorHandlers()
Replaces the error handlers of this plugin engine without applying any error handlers.-
Methods inherited from class net.bytebuddy.build.Plugin.Engine.AbstractBase
apply, apply, apply, withErrorHandlers, withParallelTransformation
-
-
-
-
Field Detail
-
byteBuddy
private final ByteBuddy byteBuddy
The Byte Buddy instance to use.
-
typeStrategy
private final Plugin.Engine.TypeStrategy typeStrategy
The type strategy to use.
-
poolStrategy
private final Plugin.Engine.PoolStrategy poolStrategy
The pool strategy to use.
-
classFileLocator
private final ClassFileLocator classFileLocator
The class file locator to use.
-
classFileVersion
@MaybeNull @ValueHandling(REVERSE_NULLABILITY) private final ClassFileVersion classFileVersion
The class file version to use for multi-release jars, ornull
.
-
listener
private final Plugin.Engine.Listener listener
The listener to use.
-
errorHandler
private final Plugin.Engine.ErrorHandler errorHandler
The error handler to use.
-
dispatcherFactory
private final Plugin.Engine.Dispatcher.Factory dispatcherFactory
The dispatcher factory to use.
-
ignoredTypeMatcher
private final ElementMatcher.Junction<? super TypeDescription> ignoredTypeMatcher
A matcher for types to exclude from transformation.
-
-
Constructor Detail
-
Default
public Default()
Creates a new default plugin engine that rebases types and fails fast and on unresolved types and on live initializers.
-
Default
public Default(ByteBuddy byteBuddy)
Creates a new default plugin engine that rebases types and fails fast and on unresolved types and on live initializers.- Parameters:
byteBuddy
- The Byte Buddy instance to use.
-
Default
protected Default(ByteBuddy byteBuddy, Plugin.Engine.TypeStrategy typeStrategy)
Creates a new default plugin engine.- Parameters:
byteBuddy
- The Byte Buddy instance to use.typeStrategy
- The type strategy to use.
-
Default
protected Default(ByteBuddy byteBuddy, Plugin.Engine.TypeStrategy typeStrategy, Plugin.Engine.PoolStrategy poolStrategy, ClassFileLocator classFileLocator, @MaybeNull ClassFileVersion classFileVersion, Plugin.Engine.Listener listener, Plugin.Engine.ErrorHandler errorHandler, Plugin.Engine.Dispatcher.Factory dispatcherFactory, ElementMatcher.Junction<? super TypeDescription> ignoredTypeMatcher)
Creates a new default plugin engine.- Parameters:
byteBuddy
- The Byte Buddy instance to use.typeStrategy
- The type strategy to use.poolStrategy
- The pool strategy to use.classFileLocator
- The class file locator to use.classFileVersion
- The class file version to use for multi-release jars, ornull
.listener
- The listener to use.errorHandler
- The error handler to use.dispatcherFactory
- The dispatcher factory to use.ignoredTypeMatcher
- A matcher for types to exclude from transformation.
-
-
Method Detail
-
of
public static Plugin.Engine of(EntryPoint entryPoint, ClassFileVersion classFileVersion, MethodNameTransformer methodNameTransformer)
Creates a plugin engine from anEntryPoint
.- Parameters:
entryPoint
- The entry point to resolve into a plugin engine.classFileVersion
- The class file version to assume.methodNameTransformer
- The method name transformer to use.- Returns:
- An appropriate plugin engine.
-
scan
public static java.util.Set<java.lang.String> scan(java.lang.ClassLoader classLoader) throws java.io.IOException
Scans a class loader for plugins declared in a META-INF/net.bytebuddy/build.plugins file.- Parameters:
classLoader
- The class loader to scan.- Returns:
- A set containing all plugins that were found.
- Throws:
java.io.IOException
- If an I/O exception occurred.
-
main
public static void main(java.lang.String... argument) throws java.lang.ClassNotFoundException, java.io.IOException
Runs a plugin engine using the first and second argument as source and target file location and any additional argument as the fully qualified name of any plugin to apply.- Parameters:
argument
- The arguments for running the plugin engine.- Throws:
java.lang.ClassNotFoundException
- If a plugin class cannot be found on the system class loader.java.io.IOException
- If an I/O exception occurs.
-
with
public Plugin.Engine with(ByteBuddy byteBuddy)
Defines a new Byte Buddy instance for usage for type creation.- Parameters:
byteBuddy
- The Byte Buddy instance to use.- Returns:
- A new plugin engine that is equal to this engine but uses the supplied Byte Buddy instance.
-
with
public Plugin.Engine with(Plugin.Engine.TypeStrategy typeStrategy)
Defines a new type strategy which determines the transformation mode for any instrumented type.- Parameters:
typeStrategy
- The type stategy to use.- Returns:
- A new plugin engine that is equal to this engine but uses the supplied type strategy.
-
with
public Plugin.Engine with(Plugin.Engine.PoolStrategy poolStrategy)
Defines a new pool strategy that determines how types are being described.- Parameters:
poolStrategy
- The pool strategy to use.- Returns:
- A new plugin engine that is equal to this engine but uses the supplied pool strategy.
-
with
public Plugin.Engine with(ClassFileLocator classFileLocator)
Appends the supplied class file locator to be queried for class files additionally to any previously registered class file locators.- Parameters:
classFileLocator
- The class file locator to append.- Returns:
- A new plugin engine that is equal to this engine but with the supplied class file locator being appended.
-
with
public Plugin.Engine with(@MaybeNull ClassFileVersion classFileVersion)
Uses the suppliedClassFileVersion
as a base for resolving multi-release jars, ornull
if multi-release jars should not be resolved but be treated as regular jar files. This property might not be applied if the underlying location mechanism does not supply manual resource resolution. Note that classes that are of newer class file versions than the specified version are not resolved and simply copied.- Parameters:
classFileVersion
- The class file version to use ornull
if multi-release jars should be ignored.- Returns:
- A new plugin engine that is equal to this engine but with the supplied class file version being used.
-
with
public Plugin.Engine with(Plugin.Engine.Listener listener)
Appends the supplied listener to this engine.- Parameters:
listener
- The listener to append.- Returns:
- A new plugin engine that is equal to this engine but with the supplied listener being appended.
-
withoutErrorHandlers
public Plugin.Engine withoutErrorHandlers()
Replaces the error handlers of this plugin engine without applying any error handlers.- Returns:
- A new plugin engine that is equal to this engine but without any error handlers being registered.
-
withErrorHandlers
public Plugin.Engine withErrorHandlers(java.util.List<? extends Plugin.Engine.ErrorHandler> errorHandlers)
Replaces the error handlers of this plugin engine with the supplied error handlers.- Parameters:
errorHandlers
- The error handlers to apply.- Returns:
- A new plugin engine that is equal to this engine but with only the supplied error handlers being applied.
-
with
public Plugin.Engine with(Plugin.Engine.Dispatcher.Factory dispatcherFactory)
Replaces the dispatcher factory of this plugin engine with the supplied dispatcher factory.- Parameters:
dispatcherFactory
- The dispatcher factory to use.- Returns:
- A new plugin engine that is equal to this engine but with the supplied dispatcher factory being used.
-
ignore
public Plugin.Engine ignore(ElementMatcher<? super TypeDescription> matcher)
Ignores all types that are matched by this matcher or any previously registered ignore matcher.- Parameters:
matcher
- The ignore matcher to append.- Returns:
- A new plugin engine that is equal to this engine but which ignores any type that is matched by the supplied matcher.
-
apply
public Plugin.Engine.Summary apply(Plugin.Engine.Source source, Plugin.Engine.Target target, java.util.List<? extends Plugin.Factory> factories) throws java.io.IOException
Applies this plugin engine onto a given source and target.- Parameters:
source
- The source to use.target
- The target to use.factories
- A list of plugin factories to a apply.- Returns:
- A summary of the applied transformation.
- Throws:
java.io.IOException
- If an I/O error occurs.
-
-