Package net.bytebuddy.agent.builder
Class AgentBuilder.InstallationListener.StreamWriting
- java.lang.Object
-
- net.bytebuddy.agent.builder.AgentBuilder.InstallationListener.StreamWriting
-
- All Implemented Interfaces:
AgentBuilder.InstallationListener
- Enclosing interface:
- AgentBuilder.InstallationListener
@Enhance public static class AgentBuilder.InstallationListener.StreamWriting extends java.lang.Object implements AgentBuilder.InstallationListener
This installation listener prints the status of any installation to aPrintStream.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder.InstallationListener
AgentBuilder.InstallationListener.Adapter, AgentBuilder.InstallationListener.Compound, AgentBuilder.InstallationListener.ErrorSuppressing, AgentBuilder.InstallationListener.NoOp, AgentBuilder.InstallationListener.StreamWriting
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringPREFIXThe prefix prepended to any message written.private java.io.PrintStreamprintStreamThe print stream to write to.-
Fields inherited from interface net.bytebuddy.agent.builder.AgentBuilder.InstallationListener
SUPPRESS_ERROR
-
-
Constructor Summary
Constructors Constructor Description StreamWriting(java.io.PrintStream printStream)Creates a new stream writing installation listener.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonBeforeInstall(java.lang.instrument.Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer)Invoked prior to the installation of a class file transformer.java.lang.ThrowableonError(java.lang.instrument.Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer, java.lang.Throwable throwable)Invoked if an installation causes an error.voidonInstall(java.lang.instrument.Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer)Invoked upon the successful installation of a class file transformer.voidonReset(java.lang.instrument.Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer)Invoked if an installation is reset.static AgentBuilder.InstallationListenertoSystemError()Creates a stream writing installation listener that prints toSystem.err.static AgentBuilder.InstallationListenertoSystemOut()Creates a stream writing installation listener that prints toSystem.out.
-
-
-
Field Detail
-
PREFIX
protected static final java.lang.String PREFIX
The prefix prepended to any message written.- See Also:
- Constant Field Values
-
printStream
private final java.io.PrintStream printStream
The print stream to write to.
-
-
Method Detail
-
toSystemOut
public static AgentBuilder.InstallationListener toSystemOut()
Creates a stream writing installation listener that prints toSystem.out.- Returns:
- An installation listener that prints to
System.out.
-
toSystemError
public static AgentBuilder.InstallationListener toSystemError()
Creates a stream writing installation listener that prints toSystem.err.- Returns:
- An installation listener that prints to
System.err.
-
onBeforeInstall
public void onBeforeInstall(java.lang.instrument.Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer)Invoked prior to the installation of a class file transformer.- Specified by:
onBeforeInstallin interfaceAgentBuilder.InstallationListener- Parameters:
instrumentation- The instrumentation on which the class file transformer is installed.classFileTransformer- The class file transformer that is being installed.
-
onInstall
public void onInstall(java.lang.instrument.Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer)Invoked upon the successful installation of a class file transformer. This method is only invoked if no error occurred during the installation or if such an error was handled byAgentBuilder.InstallationListener.onError(Instrumentation, ResettableClassFileTransformer, Throwable).- Specified by:
onInstallin interfaceAgentBuilder.InstallationListener- Parameters:
instrumentation- The instrumentation on which the class file transformer is installed.classFileTransformer- The class file transformer that is being installed.
-
onError
public java.lang.Throwable onError(java.lang.instrument.Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer, java.lang.Throwable throwable)Invoked if an installation causes an error. The listener has an opportunity to handle the error. This method is invoked prior toAgentBuilder.InstallationListener.onInstall(Instrumentation, ResettableClassFileTransformer).- Specified by:
onErrorin interfaceAgentBuilder.InstallationListener- Parameters:
instrumentation- The instrumentation on which the class file transformer is installed.classFileTransformer- The class file transformer that is being installed.throwable- The throwable that causes the error.- Returns:
- The error to propagate or
nullif the error is handled. Any subsequent listeners are not called if the exception is handled.
-
onReset
public void onReset(java.lang.instrument.Instrumentation instrumentation, ResettableClassFileTransformer classFileTransformer)Invoked if an installation is reset.- Specified by:
onResetin interfaceAgentBuilder.InstallationListener- Parameters:
instrumentation- The instrumentation on which the class file transformer is installed.classFileTransformer- The class file transformer that is being installed.
-
-