use of org.apache.jmeter.report.processor.AbstractSampleConsumer 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.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);
}
// Choose which entry point to use to plug the graph
AbstractSampleConsumer entryPoint = graphConfiguration.excludesControllers() ? excludeControllerFilter : nameFilter;
entryPoint.addSampleConsumer(graph);
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | ClassCastException ex) {
String error = String.format(INVALID_CLASS_FMT, className);
log.error(error, ex);
throw new GenerationException(error, ex);
}
}
Aggregations