summaryrefslogtreecommitdiffstats
path: root/pf4j
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2017-09-07 23:05:24 +0300
committerDecebal Suiu <decebal.suiu@gmail.com>2017-09-07 23:05:24 +0300
commitc4bf168259f7492df57af69a8c2ff7a3a7662ba3 (patch)
treea75a3aa0003f786c32af7530bc45b6cb4f26afea /pf4j
parentc35a4f63b4ccc97cbfde330ab36595a22ce2b7cf (diff)
downloadpf4j-c4bf168259f7492df57af69a8c2ff7a3a7662ba3.tar.gz
pf4j-c4bf168259f7492df57af69a8c2ff7a3a7662ba3.zip
Fix #161
Diffstat (limited to 'pf4j')
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java30
1 files changed, 20 insertions, 10 deletions
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java
index 4d0cca6..94fee2f 100644
--- a/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java
+++ b/pf4j/src/main/java/ro/fortsoft/pf4j/AbstractPluginManager.java
@@ -241,22 +241,32 @@ public abstract class AbstractPluginManager implements PluginManager {
}
}
+ /**
+ * Unload the specified plugin and it's dependents.
+ */
@Override
public boolean unloadPlugin(String pluginId) {
+ return unloadPlugin(pluginId, true);
+ }
+
+ private boolean unloadPlugin(String pluginId, boolean unloadDependents) {
try {
- PluginState pluginState = stopPlugin(pluginId);
+ if (unloadDependents) {
+ List<String> dependents = dependencyResolver.getDependents(pluginId);
+ while (!dependents.isEmpty()) {
+ String dependent = dependents.remove(0);
+ unloadPlugin(dependent, false);
+ dependents.addAll(0, dependencyResolver.getDependents(dependent));
+ }
+ }
+
+ PluginState pluginState = stopPlugin(pluginId, false);
if (PluginState.STARTED == pluginState) {
return false;
}
PluginWrapper pluginWrapper = getPlugin(pluginId);
- PluginDescriptor descriptor = pluginWrapper.getDescriptor();
- List<PluginDependency> dependencies = descriptor.getDependencies();
- for (PluginDependency dependency : dependencies) {
- if (!unloadPlugin(dependency.getPluginId())) {
- return false;
- }
- }
+ log.info("Unload plugin '{}'", getPluginLabel(pluginWrapper.getDescriptor()));
// remove the plugin
plugins.remove(pluginId);
@@ -409,7 +419,7 @@ public abstract class AbstractPluginManager implements PluginManager {
PluginDescriptor pluginDescriptor = pluginWrapper.getDescriptor();
PluginState pluginState = pluginWrapper.getPluginState();
if (PluginState.STOPPED == pluginState) {
- log.debug("Already stopped plugin '{}:{}'", pluginDescriptor.getPluginId(), pluginDescriptor.getVersion());
+ log.debug("Already stopped plugin '{}'", getPluginLabel(pluginDescriptor));
return PluginState.STOPPED;
}
@@ -429,7 +439,7 @@ public abstract class AbstractPluginManager implements PluginManager {
}
try {
- log.info("Stop plugin '{}:{}'", pluginDescriptor.getPluginId(), pluginDescriptor.getVersion());
+ log.info("Stop plugin '{}'", getPluginLabel(pluginDescriptor));
pluginWrapper.getPlugin().stop();
pluginWrapper.setPluginState(PluginState.STOPPED);
startedPlugins.remove(pluginWrapper);