diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2018-01-29 21:34:34 +0200 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2018-01-29 21:34:34 +0200 |
commit | c4e5635212aef4a01a81006405dcb0cf5d4920a2 (patch) | |
tree | acf2d56547b7ee3dc0fb3d3d58d5d3a4d9895dbb | |
parent | b1c0b021e1b3e46b4b2962db710436b41aa650c5 (diff) | |
download | pf4j-c4e5635212aef4a01a81006405dcb0cf5d4920a2.tar.gz pf4j-c4e5635212aef4a01a81006405dcb0cf5d4920a2.zip |
Add RESOLVED as plugin state
-rw-r--r-- | pf4j/src/main/java/org/pf4j/AbstractPluginManager.java | 5 | ||||
-rw-r--r-- | pf4j/src/main/java/org/pf4j/PluginState.java | 27 |
2 files changed, 28 insertions, 4 deletions
diff --git a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java index ed4aef0..18913d5 100644 --- a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java +++ b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java @@ -787,8 +787,13 @@ public abstract class AbstractPluginManager implements PluginManager { for (String pluginId : sortedPlugins) { PluginWrapper pluginWrapper = plugins.get(pluginId); if (unresolvedPlugins.remove(pluginWrapper)) { + PluginState pluginState = pluginWrapper.getPluginState(); + pluginWrapper.setPluginState(PluginState.RESOLVED); + resolvedPlugins.add(pluginWrapper); log.info("Plugin '{}' resolved", getPluginLabel(pluginWrapper.getDescriptor())); + + firePluginStateEvent(new PluginStateEvent(this, pluginWrapper, pluginState)); } } } diff --git a/pf4j/src/main/java/org/pf4j/PluginState.java b/pf4j/src/main/java/org/pf4j/PluginState.java index 2de2523..def9136 100644 --- a/pf4j/src/main/java/org/pf4j/PluginState.java +++ b/pf4j/src/main/java/org/pf4j/PluginState.java @@ -20,10 +20,31 @@ package org.pf4j; */ public class PluginState { + /** + * The runtime knows the plugin is there. It knows about the plugin path, the plugin descriptor. + */ public static final PluginState CREATED = new PluginState("CREATED"); + + /** + * The plugin cannot be used. + */ public static final PluginState DISABLED = new PluginState("DISABLED"); + + /** + * The plugin is created. All the dependencies are created and resolved. + * The plugin is ready to be started. + */ + public static final PluginState RESOLVED = new PluginState("RESOLVED"); + + /** + * The {@link Plugin#start()} has executed. A started plugin may contribute extensions. + */ public static final PluginState STARTED = new PluginState("STARTED"); - public static final PluginState STOPPED = new PluginState("STOPPED"); + + /** + * The {@link Plugin#stop()} has executed. + */ + public static final PluginState STOPPED = new PluginState("STOPPED"); private String status; @@ -38,9 +59,7 @@ public class PluginState { PluginState that = (PluginState) o; - if (!status.equals(that.status)) return false; - - return true; + return status.equals(that.status); } @Override |