Search in sources :

Example 1 with JqassistantPlugin

use of com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin in project jqa-core-framework by buschmais.

the class RulePluginRepositoryImpl method getRuleSources.

private List<RuleSource> getRuleSources(List<JqassistantPlugin> plugins) {
    List<RuleSource> sources = new ArrayList<>();
    for (JqassistantPlugin plugin : plugins) {
        RulesType rulesType = plugin.getRules();
        if (rulesType != null) {
            for (String resource : rulesType.getResource()) {
                String resourceName = RULE_RESOURCE_PATH + resource;
                sources.add(new ClasspathRuleSource(classLoader, resourceName));
            }
        }
    }
    return sources;
}
Also used : ClasspathRuleSource(com.buschmais.jqassistant.core.rule.api.source.ClasspathRuleSource) RuleSource(com.buschmais.jqassistant.core.rule.api.source.RuleSource) JqassistantPlugin(com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin) ClasspathRuleSource(com.buschmais.jqassistant.core.rule.api.source.ClasspathRuleSource) ArrayList(java.util.ArrayList) RulesType(com.buschmais.jqassistant.core.plugin.schema.v1.RulesType)

Example 2 with JqassistantPlugin

use of com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin in project jqa-core-framework by buschmais.

the class ScannerPluginRepositoryImpl method getScannerPlugins.

private <T extends ScannerPlugin> Map<String, T> getScannerPlugins(List<JqassistantPlugin> plugins) throws PluginRepositoryException {
    Map<String, T> scannerPlugins = new HashMap<>();
    for (JqassistantPlugin plugin : plugins) {
        ScannerType scannerType = plugin.getScanner();
        if (scannerType != null) {
            for (IdClassType classType : scannerType.getClazz()) {
                T scannerPlugin = createInstance(classType.getValue());
                if (scannerPlugin != null) {
                    scannerPlugin.initialize();
                    String id = classType.getId();
                    if (id == null) {
                        id = scannerPlugin.getClass().getSimpleName();
                    }
                    scannerPlugins.put(id, scannerPlugin);
                }
            }
        }
    }
    return scannerPlugins;
}
Also used : IdClassType(com.buschmais.jqassistant.core.plugin.schema.v1.IdClassType) HashMap(java.util.HashMap) JqassistantPlugin(com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin) ScannerType(com.buschmais.jqassistant.core.plugin.schema.v1.ScannerType)

Example 3 with JqassistantPlugin

use of com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin in project jqa-core-framework by buschmais.

the class ScopePluginRepositoryImpl method getScopes.

private Map<String, Scope> getScopes(List<JqassistantPlugin> plugins) throws PluginRepositoryException {
    Map<String, Scope> scopes = new HashMap<>();
    for (JqassistantPlugin plugin : plugins) {
        ScopeType scopeType = plugin.getScope();
        if (scopeType != null) {
            for (String scopePluginName : scopeType.getClazz()) {
                Class<? extends Enum<?>> type = getType(scopePluginName);
                for (Enum enumConstant : type.getEnumConstants()) {
                    Scope scope = (Scope) enumConstant;
                    String scopeName = scope.getPrefix() + ":" + scope.getName();
                    scopes.put(scopeName.toLowerCase(), scope);
                }
            }
        }
    }
    return scopes;
}
Also used : ScopeType(com.buschmais.jqassistant.core.plugin.schema.v1.ScopeType) Scope(com.buschmais.jqassistant.core.scanner.api.Scope) HashMap(java.util.HashMap) JqassistantPlugin(com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin)

Example 4 with JqassistantPlugin

use of com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin in project jqa-core-framework by buschmais.

the class PluginConfigurationReaderImpl method getPlugins.

/**
     * Returns an {@link Iterable} over all plugins which can be resolved from
     * the current classpath.
     *
     * @return The plugins which can be resolved from the current classpath.
     */
@Override
public List<JqassistantPlugin> getPlugins() {
    if (this.plugins == null) {
        final Enumeration<URL> resources;
        try {
            resources = pluginClassLoader.getResources(PLUGIN_RESOURCE);
        } catch (IOException e) {
            throw new IllegalStateException("Cannot get plugin resources.", e);
        }
        this.plugins = new ArrayList<>();
        while (resources.hasMoreElements()) {
            URL url = resources.nextElement();
            LOGGER.debug("Reading plugin descriptor from '{}'.", url);
            this.plugins.add(readPlugin(url));
        }
        SortedSet<String> pluginNames = new TreeSet<>();
        for (JqassistantPlugin plugin : plugins) {
            pluginNames.add(plugin.getName());
        }
        LOGGER.info("Loaded jQAssistant plugins {}.", pluginNames);
    }
    return this.plugins;
}
Also used : JqassistantPlugin(com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin) IOException(java.io.IOException) URL(java.net.URL)

Example 5 with JqassistantPlugin

use of com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin in project jqa-core-framework by buschmais.

the class ReportPluginRepositoryImpl method getReportPlugins.

private Map<String, ReportPlugin> getReportPlugins(List<JqassistantPlugin> plugins) throws PluginRepositoryException {
    Map<String, ReportPlugin> reportPlugins = new HashMap<>();
    for (JqassistantPlugin plugin : plugins) {
        ReportType reportType = plugin.getReport();
        if (reportType != null) {
            for (IdClassType classType : reportType.getClazz()) {
                ReportPlugin reportPlugin = createInstance(classType.getValue());
                if (reportPlugin != null) {
                    try {
                        reportPlugin.initialize();
                    } catch (ReportException e) {
                        throw new PluginRepositoryException("Cannot initialize report plugin " + reportPlugin, e);
                    }
                    String id = classType.getId();
                    if (id == null) {
                        id = reportPlugin.getClass().getSimpleName();
                    }
                    reportPlugins.put(id, reportPlugin);
                }
            }
        }
    }
    return reportPlugins;
}
Also used : IdClassType(com.buschmais.jqassistant.core.plugin.schema.v1.IdClassType) PluginRepositoryException(com.buschmais.jqassistant.core.plugin.api.PluginRepositoryException) ReportPlugin(com.buschmais.jqassistant.core.report.api.ReportPlugin) HashMap(java.util.HashMap) JqassistantPlugin(com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin) ReportException(com.buschmais.jqassistant.core.report.api.ReportException) ReportType(com.buschmais.jqassistant.core.plugin.schema.v1.ReportType)

Aggregations

JqassistantPlugin (com.buschmais.jqassistant.core.plugin.schema.v1.JqassistantPlugin)5 HashMap (java.util.HashMap)3 IdClassType (com.buschmais.jqassistant.core.plugin.schema.v1.IdClassType)2 PluginRepositoryException (com.buschmais.jqassistant.core.plugin.api.PluginRepositoryException)1 ReportType (com.buschmais.jqassistant.core.plugin.schema.v1.ReportType)1 RulesType (com.buschmais.jqassistant.core.plugin.schema.v1.RulesType)1 ScannerType (com.buschmais.jqassistant.core.plugin.schema.v1.ScannerType)1 ScopeType (com.buschmais.jqassistant.core.plugin.schema.v1.ScopeType)1 ReportException (com.buschmais.jqassistant.core.report.api.ReportException)1 ReportPlugin (com.buschmais.jqassistant.core.report.api.ReportPlugin)1 ClasspathRuleSource (com.buschmais.jqassistant.core.rule.api.source.ClasspathRuleSource)1 RuleSource (com.buschmais.jqassistant.core.rule.api.source.RuleSource)1 Scope (com.buschmais.jqassistant.core.scanner.api.Scope)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1