aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValeriy Kucherenko <valeriy.kucherenko@gmail.com>2020-07-17 19:51:43 +0300
committerGitHub <noreply@github.com>2020-07-17 19:51:43 +0300
commit58d3c8e183c44fda43adb61ff4b0dba0ca0b3cc0 (patch)
tree942ce7c0e97e2005d87bd7b983d2227e9916ff7a
parent4d08bc8c51386ee6bdde1322b6b291db1196b4b2 (diff)
downloadpf4j-58d3c8e183c44fda43adb61ff4b0dba0ca0b3cc0.tar.gz
pf4j-58d3c8e183c44fda43adb61ff4b0dba0ca0b3cc0.zip
Fix for problem with file lock on Windows platform. Introduce unloadPlugins method. (#387)
Thanks for your contribution!
-rw-r--r--pf4j/src/main/java/org/pf4j/AbstractPluginManager.java11
-rw-r--r--pf4j/src/main/java/org/pf4j/PluginManager.java5
-rw-r--r--pf4j/src/test/java/org/pf4j/JarPluginManagerTest.java2
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;
}