ru.yandex.qatools.camelot.common.PluginAnnotatedMethodInvoker Maven / Gradle / Ivy
package ru.yandex.qatools.camelot.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.yandex.qatools.camelot.config.Plugin;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import static ru.yandex.qatools.camelot.util.ExceptionUtil.formatStackTrace;
import static ru.yandex.qatools.camelot.util.ServiceUtil.forEachAnnotatedMethod;
/**
* @author Ilya Sadykov (mailto: [email protected])
*/
@SuppressWarnings("unchecked")
public class PluginAnnotatedMethodInvoker implements PluginMethodInvoker {
protected final Logger LOGGER = LoggerFactory.getLogger(getClass());
protected final Plugin plugin;
protected final Class anClass;
protected List methods = new ArrayList<>();
public PluginAnnotatedMethodInvoker(Plugin plugin, Class anClass) {
this.plugin = plugin;
this.anClass = anClass;
}
public PluginAnnotatedMethodInvoker process() throws Exception { //NOSONAR
return process(null);
}
public PluginAnnotatedMethodInvoker process(final FoundMethodProcessor proc) throws Exception { //NOSONAR
this.methods = new ArrayList<>();
Class aggClass = plugin.getContext().getClassLoader().loadClass(plugin.getContext().getPluginClass());
forEachAnnotatedMethod(aggClass, anClass, new AnnotatedMethodListener