use of com.navercorp.pinpoint.bootstrap.plugin.ObjectFactory.ByStaticFactoryMethod 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);
}
}
Aggregations