Search in sources :

Example 1 with DefaultInterceptorRegistryBinder

use of com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder in project pinpoint by naver.

the class ASMMethodVariablesTest method hasInterceptor.

@Test
public void hasInterceptor() throws Exception {
    InterceptorRegistryBinder interceptorRegistryBinder = new DefaultInterceptorRegistryBinder();
    int interceptorId = interceptorRegistryBinder.getInterceptorRegistryAdaptor().addInterceptor(new ArgsArrayInterceptor());
    final InterceptorDefinition interceptorDefinition = new InterceptorDefinitionFactory().createInterceptorDefinition(ArgsArrayInterceptor.class);
    final ClassNode classNode = ASMClassNodeLoader.get("com.navercorp.pinpoint.profiler.instrument.mock.ArgsClass");
    List<MethodNode> methodNodes = classNode.methods;
    for (MethodNode methodNode : methodNodes) {
        ASMMethodNodeAdapter methodNodeAdapter = new ASMMethodNodeAdapter(classNode.name, methodNode);
        assertEquals(false, methodNodeAdapter.hasInterceptor());
        methodNodeAdapter.addBeforeInterceptor(interceptorId, interceptorDefinition, -1);
        assertEquals(true, methodNodeAdapter.hasInterceptor());
    }
}
Also used : InterceptorDefinition(com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinition) DefaultInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) DefaultInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder) ArgsArrayInterceptor(com.navercorp.pinpoint.profiler.instrument.mock.ArgsArrayInterceptor) InterceptorDefinitionFactory(com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinitionFactory) Test(org.junit.Test)

Example 2 with DefaultInterceptorRegistryBinder

use of com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder in project pinpoint by naver.

the class ASMMethodVariablesTest method initInterceptorLocalVariables.

@Test
public void initInterceptorLocalVariables() 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);
    assertNull(variables.getEnterInsnNode());
    assertNull(variables.getEnterInsnNode());
    InterceptorRegistryBinder interceptorRegistryBinder = new DefaultInterceptorRegistryBinder();
    int interceptorId = interceptorRegistryBinder.getInterceptorRegistryAdaptor().addInterceptor(new ArgsArrayInterceptor());
    final InterceptorDefinition interceptorDefinition = new InterceptorDefinitionFactory().createInterceptorDefinition(ArgsArrayInterceptor.class);
    InsnList instructions = new InsnList();
    boolean first = variables.initInterceptorLocalVariables(instructions, interceptorId, interceptorDefinition, -1);
    assertEquals(true, first);
    assertNotNull(variables.getEnterInsnNode());
    assertNotNull(variables.getEnterInsnNode());
}
Also used : InterceptorDefinition(com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinition) DefaultInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) DefaultInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder) ArgsArrayInterceptor(com.navercorp.pinpoint.profiler.instrument.mock.ArgsArrayInterceptor) InterceptorDefinitionFactory(com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinitionFactory) Test(org.junit.Test)

Aggregations

InterceptorDefinition (com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinition)2 InterceptorDefinitionFactory (com.navercorp.pinpoint.profiler.instrument.interceptor.InterceptorDefinitionFactory)2 ArgsArrayInterceptor (com.navercorp.pinpoint.profiler.instrument.mock.ArgsArrayInterceptor)2 DefaultInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.DefaultInterceptorRegistryBinder)2 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)2 Test (org.junit.Test)2