aboutsummaryrefslogtreecommitdiffstats
path: root/pf4j/src/main
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2024-06-23 13:17:41 +0300
committerDecebal Suiu <decebal.suiu@gmail.com>2024-06-23 13:17:41 +0300
commitf1620f7f8aac25eda45d4a4084cefb015bd8c47a (patch)
treecdc3dff881b5edf947dc315deeacfe5258bd6972 /pf4j/src/main
parent1a16be8ad024d3c5fac380ec819bf6e17644c375 (diff)
downloadpf4j-#576.tar.gz
pf4j-#576.zip
Don't force resolve dependencies when unload a transitive plugin#576
Diffstat (limited to 'pf4j/src/main')
-rw-r--r--pf4j/src/main/java/org/pf4j/AbstractPluginManager.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
index d602abf..699a7fd 100644
--- a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
+++ b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
@@ -282,11 +282,23 @@ public abstract class AbstractPluginManager implements PluginManager {
* @return true if the plugin was unloaded, otherwise false
*/
protected boolean unloadPlugin(String pluginId, boolean unloadDependents) {
+ return unloadPlugin(pluginId, unloadDependents, true);
+ }
+
+ /**
+ * Unload the specified plugin and it's dependents.
+ *
+ * @param pluginId the pluginId of the plugin to unload
+ * @param unloadDependents if true, unload dependents
+ * @param resolveDependencies if true, resolve dependencies
+ * @return true if the plugin was unloaded, otherwise false
+ */
+ protected boolean unloadPlugin(String pluginId, boolean unloadDependents, boolean resolveDependencies) {
if (unloadDependents) {
List<String> dependents = dependencyResolver.getDependents(pluginId);
while (!dependents.isEmpty()) {
String dependent = dependents.remove(0);
- unloadPlugin(dependent, false);
+ unloadPlugin(dependent, false, false);
dependents.addAll(0, dependencyResolver.getDependents(dependent));
}
}
@@ -332,7 +344,9 @@ public abstract class AbstractPluginManager implements PluginManager {
}
// resolve the plugins again (update plugins graph)
- resolveDependencies();
+ if (resolveDependencies) {
+ resolveDependencies();
+ }
return true;
}
@@ -920,7 +934,7 @@ public abstract class AbstractPluginManager implements PluginManager {
pluginId = pluginDescriptor.getPluginId();
// add plugin to the list with plugins
- plugins.put(pluginId, pluginWrapper);
+ addPlugin(pluginWrapper);
getUnresolvedPlugins().add(pluginWrapper);
// add plugin class loader to the list with class loaders
@@ -1117,6 +1131,10 @@ public abstract class AbstractPluginManager implements PluginManager {
this.resolveRecoveryStrategy = resolveRecoveryStrategy;
}
+ void addPlugin(PluginWrapper pluginWrapper) {
+ plugins.put(pluginWrapper.getPluginId(), pluginWrapper);
+ }
+
/**
* Strategy for handling the recovery of a plugin that could not be resolved
* (loaded) due to a dependency problem.