use of com.navercorp.pinpoint.profiler.plugin.PluginConfig in project pinpoint by naver.
the class JavassistEngine method getContextClassPool.
private ClassPool getContextClassPool(InstrumentContext instrumentContext, NamedClassPool parent, String jvmInternalClassName, byte[] classfileBuffer) throws NotFoundException {
final ClassPool contextCassPool = new ClassPool(parent);
contextCassPool.childFirstLookup = true;
final String javaName = JavaAssistUtils.jvmNameToJavaName(jvmInternalClassName);
if (isDebug) {
logger.debug("getContextClassPool() className={}", javaName);
}
final ClassPath byteArrayClassPath = new ByteArrayClassPath(javaName, classfileBuffer);
contextCassPool.insertClassPath(byteArrayClassPath);
// plugin class not found in jboss classLoader
if (instrumentContext instanceof PluginInstrumentContext) {
final PluginConfig pluginConfig = ((PluginInstrumentContext) instrumentContext).getPluginConfig();
if (pluginConfig != null) {
String jarPath = pluginConfig.getPluginJar().getPath();
contextCassPool.appendClassPath(jarPath);
}
}
return contextCassPool;
}
use of com.navercorp.pinpoint.profiler.plugin.PluginConfig in project pinpoint by naver.
the class JarProfilerPluginClassInjectorTest method testInjectClass.
@Test
public void testInjectClass() throws Exception {
final URL sampleJar = getSampleJar("org.slf4j.impl.Log4jLoggerAdapter");
final ClassLoader contextTypeMatchClassLoader = createContextTypeMatchClassLoader(new URL[] { sampleJar });
final ProfilerPlugin profilerPlugin = Mockito.mock(ProfilerPlugin.class);
final PluginPackageFilter pluginPackageFilter = new PluginPackageFilter(Arrays.asList(LOG4_IMPL));
PluginConfig pluginConfig = new PluginConfig(sampleJar, pluginPackageFilter);
logger.debug("pluginConfig:{}", pluginConfig);
PlainClassLoaderHandler injector = new PlainClassLoaderHandler(pluginConfig);
final Class<?> loggerClass = injector.injectClass(contextTypeMatchClassLoader, logger.getClass().getName());
logger.debug("ClassLoader{}", loggerClass.getClassLoader());
Assert.assertEquals("check className", loggerClass.getName(), "org.slf4j.impl.Log4jLoggerAdapter");
Assert.assertEquals("check ClassLoader", loggerClass.getClassLoader().getClass().getName(), CONTEXT_TYPE_MATCH_CLASS_LOADER);
}
Aggregations