All Downloads are FREE. Search and download functionalities are using the official Maven repository.

perfcharts.perftest.parser.DataParserFactoryImpl Maven / Gradle / Ivy

Go to download

Perfcharts is a free software written in Java, which reads performance testing and system monitoring results from Jmeter, NMON, and/or other applications to produce charts for further analysis.

The newest version!
package perfcharts.perftest.parser;

import java.io.IOException;
import java.lang.reflect.Executable;
import java.lang.reflect.InvocationTargetException;
import java.security.InvalidParameterException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
 * Created by vfreex on 1/20/16.
 */
public class DataParserFactoryImpl implements DataParserFactory {

    private static final Map> parserClasses;

    static {
        parserClasses = new HashMap<>();
        parserClasses.put("jtl", JmeterParser.class);
        parserClasses.put("nmon", NMONParser.class);
        parserClasses.put("load", CPULoadParser.class);
        parserClasses.put("perfcmp", PerformanceComparisonParser.class);
        parserClasses.put("perftrend", PerfTrendParser.class);
    }

    private Map parsers = new HashMap<>();

    @Override
    public DataParser createParser(String inputType) throws IOException, InterruptedException {
        DataParser parser = null;
        if (parsers.containsKey(inputType))
            parser = parsers.get(inputType);
        if (parser == null) {
            if (!parserClasses.containsKey(inputType))
                throw new InvalidParameterException("Cannot find a parser to parse '" + inputType + "' files");
            Class parserClass = parserClasses.get(inputType);
            try {
                parser = parserClass.getConstructor(new Class[0]).newInstance();
            } catch (Exception e) {
                throw new IOException(e);
            }
        }
        return parser;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy