Search in sources :

Example 1 with ObjectBinderFactory

use of com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory in project pinpoint by naver.

the class ASMClass method addInterceptor0.

private int addInterceptor0(TargetFilter annotation, Class<? extends Interceptor> interceptorClass, InterceptorScope scope, ExecutionPolicy executionPolicy, Object[] constructorArgs) throws InstrumentException {
    final String filterTypeName = annotation.type();
    Objects.requireNonNull(filterTypeName, "type of @TargetFilter");
    ObjectBinderFactory objectBinderFactory = engineComponent.getObjectBinderFactory();
    final InterceptorArgumentProvider interceptorArgumentProvider = objectBinderFactory.newInterceptorArgumentProvider(this);
    final AutoBindingObjectFactory filterFactory = objectBinderFactory.newAutoBindingObjectFactory(pluginContext, classNode.getClassLoader(), interceptorArgumentProvider);
    final ObjectFactory objectFactory = ObjectFactory.byConstructor(filterTypeName, (Object[]) annotation.constructorArguments());
    final MethodFilter filter = (MethodFilter) filterFactory.createInstance(objectFactory);
    boolean singleton = annotation.singleton();
    int interceptorId = -1;
    for (InstrumentMethod m : getDeclaredMethods(filter)) {
        if (singleton && interceptorId != -1) {
            m.addInterceptor(interceptorId);
        } else {
            // TODO casting fix
            interceptorId = ((ASMMethod) m).addInterceptorInternal(interceptorClass, constructorArgs, scope, executionPolicy);
        }
    }
    if (interceptorId == -1) {
        logger.warn("No methods are intercepted. target:{}, interceptor:{}, methodFilter:{} ", this.classNode.getInternalName(), interceptorClass, filterTypeName);
    }
    return interceptorId;
}
Also used : AutoBindingObjectFactory(com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory) ObjectFactory(com.navercorp.pinpoint.bootstrap.plugin.ObjectFactory) AutoBindingObjectFactory(com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory) MethodFilter(com.navercorp.pinpoint.bootstrap.instrument.MethodFilter) ObjectBinderFactory(com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory) InterceptorArgumentProvider(com.navercorp.pinpoint.profiler.objectfactory.InterceptorArgumentProvider) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)

Example 2 with ObjectBinderFactory

use of com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory in project pinpoint by naver.

the class ASMMethod method createInterceptor.

private Interceptor createInterceptor(Class<? extends Interceptor> interceptorClass, Object[] constructorArgs, ScopeInfo scopeInfo) {
    // exception handling.
    ObjectBinderFactory objectBinderFactory = this.engineComponent.getObjectBinderFactory();
    final AnnotatedInterceptorFactory factory = objectBinderFactory.newAnnotatedInterceptorFactory(this.pluginContext);
    final Interceptor interceptor = factory.newInterceptor(interceptorClass, constructorArgs, scopeInfo, this.declaringClass, this);
    return interceptor;
}
Also used : ObjectBinderFactory(com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory) Interceptor(com.navercorp.pinpoint.bootstrap.interceptor.Interceptor) AnnotatedInterceptorFactory(com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory)

Example 3 with ObjectBinderFactory

use of com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory 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);
}
Also used : JavassistEngine(com.navercorp.pinpoint.profiler.instrument.JavassistEngine) Instrumentation(java.lang.instrument.Instrumentation) ObjectBinderFactory(com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService) GlobalInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.GlobalInterceptorRegistryBinder)

Example 4 with ObjectBinderFactory

use of com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory in project pinpoint by naver.

the class JavassistEngineTest method newJavassistEngine.

private InstrumentEngine newJavassistEngine() {
    Instrumentation instrumentation = mock(Instrumentation.class);
    ObjectBinderFactory objectBinderFactory = mock(ObjectBinderFactory.class);
    Provider<ApiMetaDataService> apiMetaDataService = Providers.of(mock(ApiMetaDataService.class));
    InterceptorRegistryBinder binder = new TestInterceptorRegistryBinder();
    return new JavassistEngine(instrumentation, objectBinderFactory, binder, apiMetaDataService, null);
}
Also used : TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) TestInterceptorRegistryBinder(com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder) Instrumentation(java.lang.instrument.Instrumentation) ObjectBinderFactory(com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory) ApiMetaDataService(com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService)

Aggregations

ObjectBinderFactory (com.navercorp.pinpoint.profiler.objectfactory.ObjectBinderFactory)4 ApiMetaDataService (com.navercorp.pinpoint.profiler.metadata.ApiMetaDataService)2 Instrumentation (java.lang.instrument.Instrumentation)2 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)1 MethodFilter (com.navercorp.pinpoint.bootstrap.instrument.MethodFilter)1 Interceptor (com.navercorp.pinpoint.bootstrap.interceptor.Interceptor)1 ObjectFactory (com.navercorp.pinpoint.bootstrap.plugin.ObjectFactory)1 JavassistEngine (com.navercorp.pinpoint.profiler.instrument.JavassistEngine)1 AnnotatedInterceptorFactory (com.navercorp.pinpoint.profiler.interceptor.factory.AnnotatedInterceptorFactory)1 GlobalInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.GlobalInterceptorRegistryBinder)1 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)1 AutoBindingObjectFactory (com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory)1 InterceptorArgumentProvider (com.navercorp.pinpoint.profiler.objectfactory.InterceptorArgumentProvider)1 TestInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder)1