use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.
the class ObjectBinderFactory method newAnnotatedInterceptorFactory.
public AnnotatedInterceptorFactory newAnnotatedInterceptorFactory(InstrumentContext pluginContext, boolean exceptionHandle) {
final TraceContext traceContext = this.traceContextProvider.get();
ApiMetaDataService apiMetaDataService = this.apiMetaDataServiceProvider.get();
return new AnnotatedInterceptorFactory(profilerConfig, traceContext, dataSourceMonitorRegistry, apiMetaDataService, pluginContext, exceptionHandle);
}
use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.
the class ASMEngine method getClass.
@Override
public InstrumentClass getClass(InstrumentContext instrumentContext, ClassLoader classLoader, String className, byte[] classFileBuffer) throws NotFoundInstrumentException {
if (className == null) {
throw new NullPointerException("class name must not be null.");
}
try {
if (classFileBuffer == null) {
ASMClassNodeAdapter classNode = ASMClassNodeAdapter.get(instrumentContext, classLoader, JavaAssistUtils.javaNameToJvmName(className));
if (classNode == null) {
return null;
}
ApiMetaDataService apiMetaDataService = this.apiMetaDataService.get();
return new ASMClass(objectBinderFactory, instrumentContext, interceptorRegistryBinder, apiMetaDataService, classLoader, classNode);
}
// Use ASM tree api.
final ClassReader classReader = new ClassReader(classFileBuffer);
final ClassNode classNode = new ClassNode();
classReader.accept(classNode, 0);
ApiMetaDataService apiMetaDataService = this.apiMetaDataService.get();
return new ASMClass(objectBinderFactory, instrumentContext, interceptorRegistryBinder, apiMetaDataService, classLoader, classNode);
} catch (Exception e) {
throw new NotFoundInstrumentException(e);
}
}
use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.
the class JavassistEngine method getClass.
@Override
public InstrumentClass getClass(InstrumentContext instrumentContext, ClassLoader classLoader, String jvmInternalClassName, byte[] classFileBuffer) throws NotFoundInstrumentException {
if (jvmInternalClassName == null) {
throw new NullPointerException("jvmInternalClassName must not be null");
}
if (isDebug) {
logger.debug("Get javassist class {}", jvmInternalClassName);
}
final CtClass cc = getCtClass(instrumentContext, classLoader, jvmInternalClassName, classFileBuffer);
final ApiMetaDataService apiMetaDataService = this.apiMetaDataService.get();
return new JavassistClass(objectBinderFactory, instrumentContext, interceptorRegistryBinder, apiMetaDataService, classLoader, cc);
}
use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.
the class InvokeAfterCodeGeneratorTest method testGenerate_AroundInterceptor3_NoCatchClause.
@Test
public void testGenerate_AroundInterceptor3_NoCatchClause() {
final Class<AroundInterceptor3> aroundInterceptor3Class = AroundInterceptor3.class;
final InterceptorDefinition interceptorDefinition = interceptorDefinitionFactory.createInterceptorDefinition(aroundInterceptor3Class);
final InstrumentClass mockClass = mock(InstrumentClass.class);
Mockito.when(mockClass.getName()).thenReturn("TestClass");
final InstrumentMethod mockMethod = mock(InstrumentMethod.class);
Mockito.when(mockMethod.getName()).thenReturn("TestMethod");
Mockito.when(mockMethod.getParameterTypes()).thenReturn(new String[] { "java.lang.Object", "java.lang.Object", "java.lang.Object" });
Mockito.when(mockMethod.getReturnType()).thenReturn("java.lang.Object");
ApiMetaDataService apiMetaDataService = mock(ApiMetaDataService.class);
final InvokeAfterCodeGenerator invokeAfterCodeGenerator = new InvokeAfterCodeGenerator(100, interceptorDefinition, mockClass, mockMethod, apiMetaDataService, false, false);
final String generate = invokeAfterCodeGenerator.generate();
logger.debug("testGenerate_AroundInterceptor3_NoCatchClause:{}", generate);
Assert.assertTrue(generate.contains("($w)$1"));
Assert.assertTrue(generate.contains("($w)$2"));
Assert.assertTrue(generate.contains("($w)$3"));
Assert.assertTrue(generate.contains("($w)$_"));
}
use of com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService in project pinpoint by naver.
the class JavassistClassTest method newJavassistEngine.
private InstrumentEngine newJavassistEngine() {
Instrumentation instrumentation = mock(Instrumentation.class);
ObjectBinderFactory objectBinderFactory = mock(ObjectBinderFactory.class);
Provider<ApiMetaDataService> apiMetaDataService = Providers.of(mock(ApiMetaDataService.class));
return new JavassistEngine(instrumentation, objectBinderFactory, new GlobalInterceptorRegistryBinder(), apiMetaDataService, null);
}
Aggregations