use of org.apache.jmeter.report.processor.graph.AbstractGraphConsumer in project jmeter by apache.
the class ReportGenerator method addGraphConsumer.
private void addGraphConsumer(FilterConsumer nameFilter, FilterConsumer excludeControllerFilter, Map.Entry<String, GraphConfiguration> entryGraphCfg) throws GenerationException {
String graphName = entryGraphCfg.getKey();
GraphConfiguration graphConfiguration = entryGraphCfg.getValue();
// Instantiate the class from the classname
String className = graphConfiguration.getClassName();
try {
Class<?> clazz = Class.forName(className);
Object obj = clazz.getDeclaredConstructor().newInstance();
AbstractGraphConsumer graph = (AbstractGraphConsumer) obj;
graph.setName(graphName);
// Set the graph title
graph.setTitle(graphConfiguration.getTitle());
// Set graph properties using reflection
Method[] methods = clazz.getMethods();
for (Map.Entry<String, String> entryProperty : graphConfiguration.getProperties().entrySet()) {
String propertyName = entryProperty.getKey();
String propertyValue = entryProperty.getValue();
String setterName = getSetterName(propertyName);
setProperty(className, obj, methods, propertyName, propertyValue, setterName);
}
graph.initialize();
// Choose which entry point to use to plug the graph
AbstractSampleConsumer entryPoint = graphConfiguration.excludesControllers() ? excludeControllerFilter : nameFilter;
entryPoint.addSampleConsumer(graph);
} catch (ClassNotFoundException ex) {
log.warn("Unable to add class:{} as consumer for HTML report generation, " + "check class name or that the plugin that contains it is on classpath", className, ex);
} catch (ClassCastException | IllegalArgumentException | ReflectiveOperationException | SecurityException ex) {
String error = String.format(INVALID_CLASS_FMT, className);
throw new GenerationException(error, ex);
}
}
Aggregations