Java Code Examples for net.bytebuddy.agent.builder.ResettableClassFileTransformer

The following examples show how to use net.bytebuddy.agent.builder.ResettableClassFileTransformer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: apm-agent-java   Source File: ElasticApmAgent.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Reverts instrumentation of classes and re-transforms them to their state without the agent.
 * <p>
 * NOTE: THIS IS ONLY TO BE USED FOR UNIT TESTS
 * NOTE2: THIS METHOD MUST BE CALLED AFTER AGENT WAS INITIALIZED
 * </p>
 */
public static synchronized void reset() {
    if (instrumentation == null) {
        return;
    }

    if (resettableClassFileTransformer == null) {
        throw new IllegalStateException("Reset was called before init");
    }
    dynamicallyInstrumentedClasses.clear();
    resettableClassFileTransformer.reset(instrumentation, RedefinitionStrategy.RETRANSFORMATION);
    resettableClassFileTransformer = null;
    for (ResettableClassFileTransformer transformer : dynamicClassFileTransformers) {
        transformer.reset(instrumentation, RedefinitionStrategy.RETRANSFORMATION);
    }
    dynamicClassFileTransformers.clear();
    instrumentation = null;
}
 
Example 2
Source Project: garmadon   Source File: Tracer.java    License: Apache License 2.0 4 votes vote down vote up
public ResettableClassFileTransformer installOnByteBuddyAgent() {
    return this.agentBuilder.installOnByteBuddyAgent();
}