use of com.navercorp.pinpoint.profiler.plugin.MatchableClassFileTransformer in project pinpoint by naver.
the class DefaultTranslator method customTransformer.
private byte[] customTransformer(String jvmClassName) {
logger.info("Modify find classname:{}, loader:{}", jvmClassName, loader);
MatchableClassFileTransformer transformer = transformerMap.get(jvmClassName);
if (transformer == null) {
return null;
}
logger.info("Modify jvmClassName:{}, modifier{}, loader:{}", jvmClassName, transformer, loader);
final Thread thread = Thread.currentThread();
final ClassLoader beforeClassLoader = thread.getContextClassLoader();
thread.setContextClassLoader(loader);
try {
String javaClassName = JavaAssistUtils.jvmNameToJavaName(jvmClassName);
byte[] transformBytes = transformer.transform(loader, javaClassName, null, null, null);
return transformBytes;
} catch (IllegalClassFormatException e) {
throw new RuntimeException(jvmClassName + " transform fail", e);
} finally {
thread.setContextClassLoader(beforeClassLoader);
}
}
use of com.navercorp.pinpoint.profiler.plugin.MatchableClassFileTransformer in project pinpoint by naver.
the class JavassistTranslator method addTransformer0.
private void addTransformer0(MatchableClassFileTransformer transformer, String className) {
final String checkClassInternalName = JavaAssistUtils.javaNameToJvmName(className);
MatchableClassFileTransformer old = transformerMap.put(checkClassInternalName, transformer);
if (old != null) {
throw new IllegalStateException("Modifier already exist new:" + transformer.getClass() + " old:" + old.getMatcher());
}
}
use of com.navercorp.pinpoint.profiler.plugin.MatchableClassFileTransformer in project pinpoint by naver.
the class JavassistTranslator method customTransformer.
private byte[] customTransformer(ClassPool pool, String jvmClassName) {
logger.info("Modify find classname:{}, loader:{}", jvmClassName, loader);
MatchableClassFileTransformer transformer = transformerMap.get(jvmClassName);
if (transformer == null) {
return null;
}
logger.info("Modify jvmClassName:{}, modifier{}, loader:{}", jvmClassName, transformer, loader);
final Thread thread = Thread.currentThread();
final ClassLoader beforeClassLoader = thread.getContextClassLoader();
thread.setContextClassLoader(loader);
try {
String javaClassName = JavaAssistUtils.jvmNameToJavaName(jvmClassName);
byte[] transformBytes = transformer.transform(loader, javaClassName, null, null, null);
makeClass(pool, transformBytes, jvmClassName);
return transformBytes;
} catch (IllegalClassFormatException e) {
throw new RuntimeException(jvmClassName + " transform fail", e);
} finally {
thread.setContextClassLoader(beforeClassLoader);
}
}
use of com.navercorp.pinpoint.profiler.plugin.MatchableClassFileTransformer in project pinpoint by naver.
the class DefaultTranslator method addTransformer0.
private void addTransformer0(MatchableClassFileTransformer transformer, String className) {
final String checkClassInternalName = JavaAssistUtils.javaNameToJvmName(className);
MatchableClassFileTransformer old = transformerMap.put(checkClassInternalName, transformer);
if (old != null) {
throw new IllegalStateException("Modifier already exist new:" + transformer.getClass() + " old:" + old.getMatcher());
}
}
use of com.navercorp.pinpoint.profiler.plugin.MatchableClassFileTransformer in project pinpoint by naver.
the class DefaultClassFileTransformerDispatcher method createTransformerRegistry.
private TransformerRegistry createTransformerRegistry(PluginContextLoadResult pluginContexts) {
DefaultTransformerRegistry registry = new DefaultTransformerRegistry();
for (ClassFileTransformer transformer : pluginContexts.getClassFileTransformer()) {
if (transformer instanceof MatchableClassFileTransformer) {
MatchableClassFileTransformer t = (MatchableClassFileTransformer) transformer;
logger.info("Registering class file transformer {} for {} ", t, t.getMatcher());
registry.addTransformer(t.getMatcher(), t);
} else {
logger.warn("Ignore class file transformer {}", transformer);
}
}
return registry;
}
Aggregations