Skip to content

Commit

Permalink
allow implementor to skip reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
tulinkry committed Feb 8, 2019
1 parent ac79fa4 commit fc2c391
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ private String getClassName(JarEntry f) {

/**
* Perform custom operations before the plugins are loaded.
* <p>
* If this function returns {@code null}, the reloading is completely skipped and {@link #afterReload(Object)}
* is never called.
*
* @return the implementor can generate custom data which will be later passed to {@link #afterReload(Object)}
*/
Expand All @@ -347,6 +350,9 @@ private String getClassName(JarEntry f) {
* <p>
* When this is invoked, all plugins has been loaded into the memory and for each available plugin
* the {@link #classLoaded(Object, Object)} was invoked.
* <p>
* When {@link #beforeReload()} returns {@code null}, the reloading is skipped, and this method is
* never called.
*
* @param data a custom data created with {@link #beforeReload()}
*/
Expand All @@ -363,6 +369,12 @@ public final void reload() {
// notify the implementing class that the reload is about to begin
final DataType localData = beforeReload();

if (localData == null) {
// the implementor does not want to reload the plugins
LOGGER.log(Level.WARNING, "Loading plugins from {0} as instructed by the implementer's class", pluginDirectory);
return;
}

try {
if (pluginDirectory == null || !pluginDirectory.isDirectory() || !pluginDirectory.canRead()) {
LOGGER.log(Level.WARNING, "Plugin directory not found or not readable: {0}.", pluginDirectory);
Expand Down

0 comments on commit fc2c391

Please sign in to comment.