use of com.navercorp.pinpoint.exception.PinpointException in project pinpoint by naver.
the class URLClassLoaderHandler method injectClass.
@Override
@SuppressWarnings("unchecked")
public <T> Class<? extends T> injectClass(ClassLoader classLoader, String className) {
try {
if (classLoader instanceof URLClassLoader) {
final URLClassLoader urlClassLoader = (URLClassLoader) classLoader;
addPluginURLIfAbsent(urlClassLoader);
return (Class<T>) urlClassLoader.loadClass(className);
}
} catch (Exception e) {
logger.warn("Failed to load plugin class {} with classLoader {}", className, classLoader, e);
throw new PinpointException("Failed to load plugin class " + className + " with classLoader " + classLoader, e);
}
throw new PinpointException("invalid ClassLoader");
}
use of com.navercorp.pinpoint.exception.PinpointException in project pinpoint by naver.
the class AutoBindingObjectFactory method byConstructor.
private Object byConstructor(Class<?> type, ByConstructor byConstructor, ArgumentsResolver argumentsResolver) {
final ConstructorResolver resolver = new ConstructorResolver(type, argumentsResolver);
if (!resolver.resolve()) {
throw new PinpointException("Cannot find suitable constructor for " + type.getName());
}
final Constructor<?> constructor = resolver.getResolvedConstructor();
final Object[] resolvedArguments = resolver.getResolvedArguments();
if (isDebug) {
logger.debug("Create instance by constructor {}, with arguments {}", constructor, Arrays.toString(resolvedArguments));
}
try {
return constructor.newInstance(resolvedArguments);
} catch (Exception e) {
throw new PinpointException("Fail to invoke constructor: " + constructor + ", arguments: " + Arrays.toString(resolvedArguments), e);
}
}
use of com.navercorp.pinpoint.exception.PinpointException in project pinpoint by naver.
the class AutoBindingObjectFactory method byStaticFactoryMethod.
private Object byStaticFactoryMethod(Class<?> type, ByStaticFactoryMethod staticFactoryMethod, ArgumentsResolver argumentsResolver) {
StaticMethodResolver resolver = new StaticMethodResolver(type, staticFactoryMethod.getFactoryMethodName(), argumentsResolver);
if (!resolver.resolve()) {
throw new PinpointException("Cannot find suitable factory method " + type.getName() + "." + staticFactoryMethod.getFactoryMethodName());
}
final Method method = resolver.getResolvedMethod();
final Object[] resolvedArguments = resolver.getResolvedArguments();
if (isDebug) {
logger.debug("Create instance by static factory method {}, with arguments {}", method, Arrays.toString(resolvedArguments));
}
try {
return method.invoke(null, resolvedArguments);
} catch (Exception e) {
throw new PinpointException("Fail to invoke factory method: " + type.getName() + "." + staticFactoryMethod.getFactoryMethodName() + ", arguments: " + Arrays.toString(resolvedArguments), e);
}
}
use of com.navercorp.pinpoint.exception.PinpointException 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