Fix issue when disabling/enabling plugins manually

I4100cd9df4ebfac87b2099ef2c916b99ef55c978 introduced two minor bugs with
the plugin loader.  Manually enabling a plugin by renaming it from
<name>.jar.disabled to <name>.jar caused it to show up twice on the
plugin list, once as disabled and once as enabled.  Manually disabling
a plugin by appending .disabled to the file name wasn't recognized at
all and no change took place in the backend to disable the plugin.

Both of these issues are now fixed.

Change-Id: I810a7f0f163fd22c8fb9324476c853c2cc04fcb2
Signed-off-by: Brad Larson <bklarson@gmail.com>
This commit is contained in:
Brad Larson
2012-07-16 15:19:26 -05:00
parent 0d26889a45
commit 359666f23f

View File

@@ -336,7 +336,9 @@ public class PluginLoader implements LifecycleListener {
private void stopRemovedPlugins(List<File> jars) { private void stopRemovedPlugins(List<File> jars) {
Set<String> unload = Sets.newHashSet(running.keySet()); Set<String> unload = Sets.newHashSet(running.keySet());
for (File jar : jars) { for (File jar : jars) {
unload.remove(nameOf(jar)); if (!jar.getName().endsWith(".disabled")) {
unload.remove(nameOf(jar));
}
} }
for (String name : unload){ for (String name : unload){
log.info(String.format("Unloading plugin %s", name)); log.info(String.format("Unloading plugin %s", name));
@@ -347,7 +349,9 @@ public class PluginLoader implements LifecycleListener {
private void dropRemovedDisabledPlugins(List<File> jars) { private void dropRemovedDisabledPlugins(List<File> jars) {
Set<String> unload = Sets.newHashSet(disabled.keySet()); Set<String> unload = Sets.newHashSet(disabled.keySet());
for (File jar : jars) { for (File jar : jars) {
unload.remove(nameOf(jar)); if (jar.getName().endsWith(".disabled")) {
unload.remove(nameOf(jar));
}
} }
for (String name : unload) { for (String name : unload) {
disabled.remove(name); disabled.remove(name);