net.bytebuddy.agent.builder.ResettableClassFileTransformer Java Examples

The following examples show how to use net.bytebuddy.agent.builder.ResettableClassFileTransformer. 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 File: ElasticApmAgent.java    From apm-agent-java with 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 File: Tracer.java    From garmadon with Apache License 2.0 4 votes vote down vote up
public ResettableClassFileTransformer installOnByteBuddyAgent() {
    return this.agentBuilder.installOnByteBuddyAgent();
}