diff options
-rw-r--r-- | pf4j/src/main/java/org/pf4j/AbstractPluginManager.java | 11 | ||||
-rw-r--r-- | pf4j/src/main/java/org/pf4j/PluginManager.java | 5 | ||||
-rw-r--r-- | pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java | 2 |
3 files changed, 18 insertions, 0 deletions
diff --git a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java index 5b8b82c..ea8d297 100644 --- a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java +++ b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java @@ -236,6 +236,17 @@ public abstract class AbstractPluginManager implements PluginManager { } /** + * Unload all plugins + */ + @Override + public void unloadPlugins() { + // wrap resolvedPlugins in new list because of concurrent modification + for (PluginWrapper pluginWrapper : new ArrayList<>(resolvedPlugins)) { + unloadPlugin(pluginWrapper.getPluginId()); + } + } + + /** * Unload the specified plugin and it's dependents. */ @Override diff --git a/pf4j/src/main/java/org/pf4j/PluginManager.java b/pf4j/src/main/java/org/pf4j/PluginManager.java index a937f22..248b1ac 100644 --- a/pf4j/src/main/java/org/pf4j/PluginManager.java +++ b/pf4j/src/main/java/org/pf4j/PluginManager.java @@ -101,6 +101,11 @@ public interface PluginManager { PluginState stopPlugin(String pluginId); /** + * Unload all plugins + */ + void unloadPlugins(); + + /** * Unload a plugin. * * @param pluginId the unique plugin identifier, specified in its metadata diff --git a/pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java b/pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java index d9ca90a..4eb2872 100644 --- a/pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java +++ b/pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java @@ -53,6 +53,8 @@ public class JarPluginManagerTest { @AfterEach public void tearDown() { + pluginManager.unloadPlugins(); + pluginJar = null; pluginManager = null; } |