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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations