use of com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory in project pinpoint by naver.
the class ASMClass method addInterceptor0.
private int addInterceptor0(TargetFilter annotation, String interceptorClassName, InterceptorScope scope, ExecutionPolicy executionPolicy, Object[] constructorArgs) throws InstrumentException {
final String filterTypeName = annotation.type();
Asserts.notNull(filterTypeName, "type of @TargetFilter");
final InterceptorArgumentProvider interceptorArgumentProvider = objectBinderFactory.newInterceptorArgumentProvider(this);
final AutoBindingObjectFactory filterFactory = objectBinderFactory.newAutoBindingObjectFactory(pluginContext, classLoader, 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(interceptorClassName, constructorArgs, scope, executionPolicy);
}
}
if (interceptorId == -1) {
logger.warn("No methods are intercepted. target: " + this.classNode.getInternalName(), ", interceptor: " + interceptorClassName + ", methodFilter: " + filterTypeName);
}
return interceptorId;
}
use of com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory in project pinpoint by naver.
the class AnnotatedInterceptorFactory method getInterceptor.
@Override
public Interceptor getInterceptor(ClassLoader classLoader, String interceptorClassName, Object[] providedArguments, InterceptorScope scope, ExecutionPolicy policy, InstrumentClass target, InstrumentMethod targetMethod) {
Class<? extends Interceptor> interceptorType = pluginContext.injectClass(classLoader, interceptorClassName);
if (scope == null) {
Scope interceptorScope = interceptorType.getAnnotation(Scope.class);
if (interceptorScope != null) {
String scopeName = interceptorScope.value();
scope = pluginContext.getInterceptorScope(scopeName);
policy = interceptorScope.executionPolicy();
}
}
AutoBindingObjectFactory factory = new AutoBindingObjectFactory(profilerConfig, traceContext, pluginContext, classLoader);
ObjectFactory objectFactory = ObjectFactory.byConstructor(interceptorClassName, providedArguments);
InterceptorArgumentProvider interceptorArgumentProvider = new InterceptorArgumentProvider(dataSourceMonitorRegistry, apiMetaDataService, scope, target, targetMethod);
Interceptor interceptor = (Interceptor) factory.createInstance(objectFactory, interceptorArgumentProvider);
if (scope != null) {
if (exceptionHandle) {
interceptor = wrapByExceptionHandleScope(interceptor, scope, policy == null ? ExecutionPolicy.BOUNDARY : policy);
} else {
interceptor = wrapByScope(interceptor, scope, policy == null ? ExecutionPolicy.BOUNDARY : policy);
}
} else {
if (exceptionHandle) {
interceptor = wrapByExceptionHandle(interceptor);
}
}
return interceptor;
}
use of com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory in project pinpoint by naver.
the class JavassistClass method addInterceptor0.
private int addInterceptor0(TargetFilter annotation, String interceptorClassName, InterceptorScope scope, ExecutionPolicy executionPolicy, Object[] constructorArgs) throws InstrumentException {
String filterTypeName = annotation.type();
Asserts.notNull(filterTypeName, "type of @TargetFilter");
InterceptorArgumentProvider interceptorArgumentProvider = this.objectBinderFactory.newInterceptorArgumentProvider(this);
AutoBindingObjectFactory filterFactory = this.objectBinderFactory.newAutoBindingObjectFactory(pluginContext, classLoader, interceptorArgumentProvider);
final ObjectFactory objectFactory = ObjectFactory.byConstructor(filterTypeName, (Object[]) annotation.constructorArguments());
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 = ((JavassistMethod) m).addInterceptorInternal(interceptorClassName, constructorArgs, scope, executionPolicy);
}
}
if (interceptorId == -1) {
logger.warn("No methods are intercepted. target: " + ctClass.getName(), ", interceptor: " + interceptorClassName + ", methodFilter: " + filterTypeName);
}
return interceptorId;
}
use of com.navercorp.pinpoint.profiler.objectfactory.AutoBindingObjectFactory in project pinpoint by naver.
the class TargetAnnotatedInterceptorInjector method createFilteredMethodEditor.
private MethodTransformer createFilteredMethodEditor(TargetFilter annotation, InstrumentClass targetClass, AnnotatedInterceptorInjector injector, ClassLoader classLoader) {
String type = annotation.type();
if (type == null) {
throw new PinpointException("type of @TargetFilter is null: " + interceptorClassName);
}
final InterceptorArgumentProvider interceptorArgumentProvider = new InterceptorArgumentProvider(dataSourceMonitorRegistry, apiMetaDataService, targetClass);
AutoBindingObjectFactory filterFactory = new AutoBindingObjectFactory(profilerConfig, traceContext, pluginContext, classLoader, interceptorArgumentProvider);
MethodFilter filter = (MethodFilter) filterFactory.createInstance(ObjectFactory.byConstructor(type, (Object[]) annotation.constructorArguments()));
MethodRecipe recipe = annotation.singleton() ? new SharedAnnotatedInterceptorInjector(injector) : injector;
return new FilteringMethodTransformer(new MethodFilter[] { filter }, Arrays.<MethodRecipe>asList(recipe), null);
}
Aggregations