diff options
author | decebal <decebal.suiu@asf.ro> | 2016-07-01 18:15:43 +0300 |
---|---|---|
committer | decebal <decebal.suiu@asf.ro> | 2016-07-01 18:15:43 +0300 |
commit | f67d85feed7be08fe2f93e66b2b773e7823e397a (patch) | |
tree | 3deb666a538c83fb23612f6d1288fc437cc27621 | |
parent | 502d661310e9b03cc61977ce3b38c115795cd558 (diff) | |
download | pf4j-f67d85feed7be08fe2f93e66b2b773e7823e397a.tar.gz pf4j-f67d85feed7be08fe2f93e66b2b773e7823e397a.zip |
Improve debugging for no extensions found
-rw-r--r-- | pf4j/src/main/java/ro/fortsoft/pf4j/AbstractExtensionFinder.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractExtensionFinder.java index 1be5b8b..5791cb3 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractExtensionFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractExtensionFinder.java @@ -51,6 +51,10 @@ public abstract class AbstractExtensionFinder implements ExtensionFinder, Plugin List<ExtensionWrapper<T>> result = new ArrayList<>(); for (Map.Entry<String, Set<String>> entry : entries.entrySet()) { + if (entry.getValue().isEmpty()) { + continue; + } + String pluginId = entry.getKey(); if (pluginId != null) { @@ -62,6 +66,20 @@ public abstract class AbstractExtensionFinder implements ExtensionFinder, Plugin ClassLoader classLoader = (pluginId != null) ? pluginManager.getPluginClassLoader(pluginId) : getClass().getClassLoader(); + // performs some check + if (log.isTraceEnabled()) { // an alternative may be the use of a system property + ClassLoader typeClassLoader = type.getClassLoader(); + if (!classLoader.equals(typeClassLoader)) + { + // in this scenario the method 'isAssignableFrom' returns only FALSE + // see http://www.coderanch.com/t/557846/java/java/FWIW-FYI-isAssignableFrom-isInstance-differing + log.error("Different class loaders: '{}' and '{}'", classLoader, typeClassLoader); + + // below line is commented because I wish to see the next log.trace line +// continue; + } + } + for (String className : entry.getValue()) { try { log.debug("Loading class '{}' using class loader '{}'", className, classLoader); @@ -81,13 +99,8 @@ public abstract class AbstractExtensionFinder implements ExtensionFinder, Plugin extensionWrapper.setExtensionFactory(pluginManager.getExtensionFactory()); result.add(extensionWrapper); log.debug("Added extension '{}' with ordinal {}", className, ordinal); - } else if (log.isTraceEnabled()) { // an alternative may be the use of a system property + } else { log.trace("'{}' is not an extension for extension point '{}'", className, type.getName()); - ClassLoader extensionClassLoader = extensionClass.getClassLoader(); - ClassLoader typeClassLoader = type.getClassLoader(); - if (!extensionClassLoader.equals(typeClassLoader)) { - log.trace("Different class loaders: '{}' and '{}'", extensionClassLoader, typeClassLoader); - } } } catch (ClassNotFoundException e) { log.error(e.getMessage(), e); |