summaryrefslogtreecommitdiffstats
path: root/pf4j/src/main
diff options
context:
space:
mode:
authorSebastian Lövdahl <slovdahl@hibox.fi>2024-02-20 09:16:09 +0200
committerGitHub <noreply@github.com>2024-02-20 09:16:09 +0200
commitb92ec9ed53f69638c9726c29bc25a780a8eb7a17 (patch)
tree2ed482861cd85536e76dc8409e22722ccae015d8 /pf4j/src/main
parent5a73e6a1b3d45167281c806e06bfeb0fcd1bdb25 (diff)
downloadpf4j-b92ec9ed53f69638c9726c29bc25a780a8eb7a17.tar.gz
pf4j-b92ec9ed53f69638c9726c29bc25a780a8eb7a17.zip
Post `PluginState.UNLOADED` event when plugins are unloaded (#567)
Diffstat (limited to 'pf4j/src/main')
-rw-r--r--pf4j/src/main/java/org/pf4j/AbstractPluginManager.java1
-rw-r--r--pf4j/src/main/java/org/pf4j/PluginState.java11
2 files changed, 10 insertions, 2 deletions
diff --git a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
index f3a7231..78c261c 100644
--- a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
+++ b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
@@ -311,6 +311,7 @@ public abstract class AbstractPluginManager implements PluginManager {
}
// remove the plugin
+ pluginWrapper.setPluginState(PluginState.UNLOADED);
plugins.remove(pluginId);
getResolvedPlugins().remove(pluginWrapper);
getUnresolvedPlugins().remove(pluginWrapper);
diff --git a/pf4j/src/main/java/org/pf4j/PluginState.java b/pf4j/src/main/java/org/pf4j/PluginState.java
index 989157f..6a6c1f9 100644
--- a/pf4j/src/main/java/org/pf4j/PluginState.java
+++ b/pf4j/src/main/java/org/pf4j/PluginState.java
@@ -20,7 +20,7 @@ package org.pf4j;
* <p>
* Lifecycle of a plugin:
* <pre>
- * CREATED -> RESOLVED -> STARTED -> STOPPED
+ * CREATED -> RESOLVED -> STARTED -> STOPPED -> UNLOADED
* CREATED -> DISABLED
* CREATED -> FAILED
*
@@ -57,7 +57,14 @@ public enum PluginState {
/**
* Plugin failed to start.
*/
- FAILED("FAILED");
+ FAILED("FAILED"),
+
+ /**
+ * The plugin has been unloaded. After this event has been completed, the plugin's
+ * {@link ClassLoader} will be closed.
+ */
+ UNLOADED("UNLOADED"),
+ ;
private final String status;