use of com.navercorp.pinpoint.bootstrap.LibClass in project pinpoint by naver.
the class JarProfilerPluginClassInjectorTest method createContextTypeMatchClassLoader.
private ClassLoader createContextTypeMatchClassLoader(URL[] urlArray) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, java.lang.reflect.InvocationTargetException {
final ClassLoader classLoader = this.getClass().getClassLoader();
final Class<ClassLoader> aClass = (Class<ClassLoader>) classLoader.loadClass(CONTEXT_TYPE_MATCH_CLASS_LOADER);
final Constructor<ClassLoader> constructor = aClass.getConstructor(ClassLoader.class);
ReflectionUtils.makeAccessible(constructor);
final LibClass libClassFilter = new LibClass() {
@Override
public boolean onLoadClass(String clazzName) {
if (clazzName.startsWith(LOG4_IMPL)) {
logger.debug("Loading {}", clazzName);
return ON_LOAD_CLASS;
}
return DELEGATE_PARENT;
}
};
PinpointURLClassLoader testClassLoader = new PinpointURLClassLoader(urlArray, ClassLoader.getSystemClassLoader(), libClassFilter);
final ClassLoader contextTypeMatchClassLoader = constructor.newInstance(testClassLoader);
logger.debug("cl:{}", contextTypeMatchClassLoader);
return contextTypeMatchClassLoader;
}
Aggregations