Search in sources :

Example 1 with PluginParameter

use of com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginParameter in project CFLint by cflint.

the class ConfigUtils method loadPlugin.

public static CFLintScanner loadPlugin(final PluginInfoRule ruleInfo) {
    final String shortClassName = ruleInfo.getClassName() != null && ruleInfo.getClassName().trim().length() > 0 ? ruleInfo.getClassName() : ruleInfo.getName();
    final String className = PLUGIN_PACKAGE + "." + shortClassName.trim();
    try {
        final Class<?> pluginClass = Class.forName(className);
        final CFLintScanner plugin = (CFLintScanner) pluginClass.newInstance();
        for (final PluginParameter param : ruleInfo.getParameters()) {
            plugin.setParameter(param.getName(), param.getValue());
        }
        ruleInfo.setPluginInstance(plugin);
        return plugin;
    } catch (final Exception e) {
        log.error("Could not load plugin " + className, e);
    }
    return null;
}
Also used : CFLintScanner(com.cflint.plugins.CFLintScanner) PluginParameter(com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginParameter) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonParseException(com.fasterxml.jackson.core.JsonParseException)

Aggregations

PluginParameter (com.cflint.config.CFLintPluginInfo.PluginInfoRule.PluginParameter)1 CFLintScanner (com.cflint.plugins.CFLintScanner)1 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)1 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 IOException (java.io.IOException)1 JAXBException (javax.xml.bind.JAXBException)1