Search in sources :

Example 6 with InterceptorDefinitionFactory

use of com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinitionFactory in project pinpoint by naver.

the class ASMMethodVariablesTest method getInterceptorParameterCount.

@Test
public void getInterceptorParameterCount() throws Exception {
    MethodNode methodNode = ASMClassNodeLoader.get("com.navercorp.pinpoint.profiler.instrument.mock.ConstructorChildClass", "<init>");
    ASMMethodVariables variables = new ASMMethodVariables("com/navercorp/pinpoint/profiler/instrument/mock/ConstructorChildClass", methodNode);
    assertEquals(1, variables.getInterceptorParameterCount(new InterceptorDefinitionFactory().createInterceptorDefinition(ArgsArrayInterceptor.class)));
    assertEquals(4, variables.getInterceptorParameterCount(new InterceptorDefinitionFactory().createInterceptorDefinition(StaticInterceptor.class)));
    assertEquals(2, variables.getInterceptorParameterCount(new InterceptorDefinitionFactory().createInterceptorDefinition(ApiIdAwareInterceptor.class)));
    assertEquals(5, variables.getInterceptorParameterCount(new InterceptorDefinitionFactory().createInterceptorDefinition(BasicInterceptor.class)));
}
Also used : InterceptorDefinitionFactory(com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinitionFactory) Test(org.junit.Test)

Example 7 with InterceptorDefinitionFactory

use of com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinitionFactory in project pinpoint by naver.

the class ASMMethodNodeAdapterTest method isVisited.

@Test
public void isVisited() throws Exception {
    // init
    final int interceptorId = interceptorRegistryBinder.getInterceptorRegistryAdaptor().addInterceptor(new ArgsArrayInterceptor());
    final InterceptorDefinition interceptorDefinition = new InterceptorDefinitionFactory().createInterceptorDefinition(ArgsArrayInterceptor.class);
    final String targetClassName = "com.navercorp.pinpoint.profiler.instrument.mock.ArgsClass";
    final MethodNode methodNode = ASMClassNodeLoader.get(targetClassName, "arg");
    ASMMethodNodeAdapter adapter = new ASMMethodNodeAdapter(JavaAssistUtils.javaNameToJvmName(targetClassName), methodNode);
    assertEquals(false, adapter.hasInterceptor());
    adapter.addBeforeInterceptor(interceptorId, interceptorDefinition, -1);
    assertEquals(true, adapter.hasInterceptor());
}
Also used : InterceptorDefinition(com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinition) MethodNode(org.objectweb.asm.tree.MethodNode) ArgsArrayInterceptor(com.navercorp.pinpoint.profiler.instrument.mock.ArgsArrayInterceptor) JointPoint(com.navercorp.pinpoint.bootstrap.instrument.aspect.JointPoint) InterceptorDefinitionFactory(com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinitionFactory) Test(org.junit.Test)

Aggregations

InterceptorDefinitionFactory (com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinitionFactory)7 InterceptorDefinition (com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinition)5 Test (org.junit.Test)5 ArgsArrayInterceptor (com.navercorp.pinpoint.profiler.instrument.mock.ArgsArrayInterceptor)3 MethodNode (org.objectweb.asm.tree.MethodNode)3 DefaultInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder)2 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)2 List (java.util.List)2 ClassNode (org.objectweb.asm.tree.ClassNode)2 JointPoint (com.navercorp.pinpoint.bootstrap.instrument.aspect.JointPoint)1 ASMEngine (com.navercorp.pinpoint.profiler.instrument.ASMEngine)1 ASMMethodNodeAdapter (com.navercorp.pinpoint.profiler.instrument.ASMMethodNodeAdapter)1 DefaultEngineComponent (com.navercorp.pinpoint.profiler.instrument.DefaultEngineComponent)1 EngineComponent (com.navercorp.pinpoint.profiler.instrument.EngineComponent)1 ScopeFactory (com.navercorp.pinpoint.profiler.instrument.ScopeFactory)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1