Search in sources :

Example 1 with PluginConfig

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;
}
Also used : PluginConfig(com.navercorp.pinpoint.profiler.plugin.PluginConfig) PluginInstrumentContext(com.navercorp.pinpoint.profiler.plugin.PluginInstrumentContext) NamedClassPool(com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool) IsolateMultipleClassPool(com.navercorp.pinpoint.profiler.instrument.classpool.IsolateMultipleClassPool) MultipleClassPool(com.navercorp.pinpoint.profiler.instrument.classpool.MultipleClassPool)

Example 2 with PluginConfig

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);
}
Also used : PluginConfig(com.navercorp.pinpoint.profiler.plugin.PluginConfig) PinpointURLClassLoader(com.navercorp.pinpoint.bootstrap.PinpointURLClassLoader) ProfilerPlugin(com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin) PluginPackageFilter(com.navercorp.pinpoint.profiler.plugin.PluginPackageFilter) URL(java.net.URL) Test(org.junit.Test)

Aggregations

PluginConfig (com.navercorp.pinpoint.profiler.plugin.PluginConfig)2 PinpointURLClassLoader (com.navercorp.pinpoint.bootstrap.PinpointURLClassLoader)1 ProfilerPlugin (com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin)1 IsolateMultipleClassPool (com.navercorp.pinpoint.profiler.instrument.classpool.IsolateMultipleClassPool)1 MultipleClassPool (com.navercorp.pinpoint.profiler.instrument.classpool.MultipleClassPool)1 NamedClassPool (com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool)1 PluginInstrumentContext (com.navercorp.pinpoint.profiler.plugin.PluginInstrumentContext)1 PluginPackageFilter (com.navercorp.pinpoint.profiler.plugin.PluginPackageFilter)1 URL (java.net.URL)1 Test (org.junit.Test)1