From 0dd5e53dffbf246742a67d8072bc69da08b45773 Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Mon, 28 Dec 2015 22:35:34 +0200 Subject: [PATCH] Add getExtensionFactory in PluginManager interface --- .../main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java | 6 ++---- .../main/java/ro/fortsoft/pf4j/DefaultPluginManager.java | 7 ++++++- pf4j/src/main/java/ro/fortsoft/pf4j/PluginManager.java | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java index 8525e8c..9ff571a 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java @@ -43,12 +43,10 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe private static final Logger log = LoggerFactory.getLogger(DefaultExtensionFinder.class); protected PluginManager pluginManager; - protected ExtensionFactory extensionFactory; protected volatile Map> entries; // cache by pluginId - public DefaultExtensionFinder(PluginManager pluginManager, ExtensionFactory extensionFactory) { + public DefaultExtensionFinder(PluginManager pluginManager) { this.pluginManager = pluginManager; - this.extensionFactory = extensionFactory; } @Override @@ -93,7 +91,7 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe descriptor.setExtensionClass(extensionClass); ExtensionWrapper extensionWrapper = new ExtensionWrapper<>(descriptor); - extensionWrapper.setExtensionFactory(extensionFactory); + extensionWrapper.setExtensionFactory(pluginManager.getExtensionFactory()); result.add(extensionWrapper); log.debug("Added extension '{}' with ordinal {}", className, extension.ordinal()); } else { diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java index e3943f2..bdedc88 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java @@ -566,6 +566,11 @@ public class DefaultPluginManager implements PluginManager { return extensionFinder.findClassNames(pluginId); } + @Override + public ExtensionFactory getExtensionFactory() { + return extensionFactory; + } + @Override public RuntimeMode getRuntimeMode() { if (runtimeMode == null) { @@ -631,7 +636,7 @@ public class DefaultPluginManager implements PluginManager { * Add the possibility to override the ExtensionFinder. */ protected ExtensionFinder createExtensionFinder() { - DefaultExtensionFinder extensionFinder = new DefaultExtensionFinder(this, extensionFactory); + DefaultExtensionFinder extensionFinder = new DefaultExtensionFinder(this); addPluginStateListener(extensionFinder); return extensionFinder; diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginManager.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginManager.java index 9792979..2cb2adb 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginManager.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginManager.java @@ -136,6 +136,8 @@ public interface PluginManager { public Set getExtensionClassNames(String pluginId); + public ExtensionFactory getExtensionFactory(); + /** * The runtime mode. Must currently be either DEVELOPMENT or DEPLOYMENT. */ -- 2.39.5