use of com.navercorp.pinpoint.bootstrap.interceptor.Interceptor in project pinpoint by naver.
the class ASMMethodVariables method initInterceptorVar.
private void initInterceptorVar(final InsnList instructions, final int interceptorId) {
assertInitializedInterceptorLocalVariables();
this.interceptorVarIndex = addInterceptorLocalVariable("_$PINPOINT$_interceptor", "Lcom/navercorp/pinpoint/bootstrap/interceptor/Interceptor;");
push(instructions, interceptorId);
instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Type.getInternalName(InterceptorRegistry.class), "getInterceptor", "(I)" + Type.getDescriptor(Interceptor.class), false));
storeVar(instructions, this.interceptorVarIndex);
this.resultVarIndex = addInterceptorLocalVariable("_$PINPOINT$_result", "Ljava/lang/Object;");
loadNull(instructions);
storeVar(instructions, this.resultVarIndex);
this.throwableVarIndex = addInterceptorLocalVariable("_$PINPOINT$_throwable", "Ljava/lang/Throwable;");
loadNull(instructions);
storeVar(instructions, this.throwableVarIndex);
}
use of com.navercorp.pinpoint.bootstrap.interceptor.Interceptor in project pinpoint by naver.
the class ASMMethod method createInterceptor.
private Interceptor createInterceptor(String interceptorClassName, ScopeInfo scopeInfo, Object[] constructorArgs) {
final ClassLoader classLoader = this.declaringClass.getClassLoader();
// exception handling.
final AnnotatedInterceptorFactory factory = objectBinderFactory.newAnnotatedInterceptorFactory(this.pluginContext, true);
final Interceptor interceptor = factory.getInterceptor(classLoader, interceptorClassName, constructorArgs, scopeInfo.getScope(), scopeInfo.getPolicy(), this.declaringClass, this);
return interceptor;
}
use of com.navercorp.pinpoint.bootstrap.interceptor.Interceptor 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.bootstrap.interceptor.Interceptor in project pinpoint by naver.
the class JavassistMethod method createInterceptor.
private Interceptor createInterceptor(String interceptorClassName, ScopeInfo scopeInfo, Object[] constructorArgs) {
ClassLoader classLoader = declaringClass.getClassLoader();
AnnotatedInterceptorFactory factory = objectBinderFactory.newAnnotatedInterceptorFactory(pluginContext, false);
Interceptor interceptor = factory.getInterceptor(classLoader, interceptorClassName, constructorArgs, scopeInfo.getScope(), scopeInfo.getPolicy(), declaringClass, this);
return interceptor;
}
use of com.navercorp.pinpoint.bootstrap.interceptor.Interceptor in project pinpoint by naver.
the class SampleClass method voidMethod.
public void voidMethod() {
Interceptor interceptor = new ArgsArrayInterceptor();
Object[] args = null;
Object result = null;
Throwable throwable = null;
try {
((ArgsArrayInterceptor) interceptor).before(this, args);
((ArgsArrayInterceptor) interceptor).after(this, args, result, throwable);
} catch (Throwable t) {
throwable = t;
((ArgsArrayInterceptor) interceptor).after(this, args, result, t);
}
}
Aggregations