com.appland.appmap.util.AppMapClassPool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of appmap-agent Show documentation
Show all versions of appmap-agent Show documentation
Inspect and record the execution of Java for use with App Land
The newest version!
package com.appland.appmap.util;
import java.util.ArrayDeque;
import java.util.Deque;
import javassist.ClassPool;
import javassist.LoaderClassPath;
public class AppMapClassPool {
private static final ThreadLocal> threadPoolQueue =
ThreadLocal.withInitial(() -> new ArrayDeque());
public static ClassPool acquire(ClassLoader classLoader) {
ClassPool ret = new ClassPool();
ret.appendClassPath(new LoaderClassPath(classLoader));
threadPoolQueue.get().push(ret);
return ret;
}
public static ClassPool get() {
ClassPool ret = threadPoolQueue.get().peek();
if (ret == null) {
throw new InternalError("not acquired");
}
return ret;
}
public static void release() {
threadPoolQueue.get().pop();
}
}