log.info("Start plugin '{}'", getPluginLabel(pluginWrapper.getDescriptor()));
pluginWrapper.getPlugin().start();
pluginWrapper.setPluginState(PluginState.STARTED);
+ pluginWrapper.setFailedException(null);
startedPlugins.add(pluginWrapper);
-
- firePluginStateEvent(new PluginStateEvent(this, pluginWrapper, pluginState));
} catch (Exception e) {
+ pluginWrapper.setPluginState(PluginState.FAILED);
+ pluginWrapper.setFailedException(e);
log.error(e.getMessage(), e);
+ } finally {
+ firePluginStateEvent(new PluginStateEvent(this, pluginWrapper, pluginState));
}
}
}
* The runtime knows the plugin is there. It knows about the plugin path, the plugin descriptor.
*/
CREATED("CREATED"),
-
+
/**
* The plugin cannot be used.
*/
DISABLED("DISABLED"),
-
+
/**
* The plugin is created. All the dependencies are created and resolved.
* The plugin is ready to be started.
/**
* The {@link Plugin#stop()} has executed.
*/
- STOPPED("STOPPED");
+ STOPPED("STOPPED"),
+
+ /**
+ * Plugin failed to start.
+ */
+ FAILED("FAILED");
private String status;
private PluginState pluginState;
private RuntimeMode runtimeMode;
+ private Exception failedException;
+
Plugin plugin; // cache
public PluginWrapper(PluginManager pluginManager, PluginDescriptor descriptor, Path pluginPath, ClassLoader pluginClassLoader) {
this.pluginFactory = pluginFactory;
}
+ /**
+ * Returns the exception with which the plugin fails to start.
+ * See @{link PluginStatus#FAILED}.
+ */
+ public Exception getFailedException() {
+ return failedException;
+ }
+
+ public void setFailedException(Exception failedException) {
+ this.failedException = failedException;
+ }
+
}