Commit 2a0dfd05 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Improved plugin unloading.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1717 b35dd754-fafc-0310-a699-88a17e54d16e
parent a8d33dc5
...@@ -572,40 +572,43 @@ public class PluginManager { ...@@ -572,40 +572,43 @@ public class PluginManager {
} }
}); });
for (int i = 0; i < dirs.length; i++) {
File dirFile = dirs[i];
// If the plugin hasn't already been started, start it.
if (!plugins.containsKey(dirFile.getName())) {
loadPlugin(dirFile);
}
}
// See if any currently running plugins need to be unloaded // See if any currently running plugins need to be unloaded
// due to its JAR file being deleted (ignore admin plugin). // due to the JAR file being deleted (ignore admin plugin).
if (plugins.size() > jars.length + 1) { // Build a list of plugins to delete first so that the plugins
// Build a list of plugins to delete first so that the plugins // keyset isn't modified as we're iterating through it.
// keyset is modified as we're iterating through it. List<String> toDelete = new ArrayList<String>();
List<String> toDelete = new ArrayList<String>(); for (File pluginDir : dirs) {
for (String pluginName : plugins.keySet()) { String pluginName = pluginDir.getName();
if (pluginName.equals("admin")) { if (pluginName.equals("admin")) {
continue; continue;
} }
File file = new File(pluginDirectory, pluginName + ".jar"); File file = new File(pluginDirectory, pluginName + ".jar");
if (!file.exists()) {
file = new File(pluginDirectory, pluginName + ".war");
if (!file.exists()) { if (!file.exists()) {
toDelete.add(pluginName); toDelete.add(pluginName);
} }
} }
for (String pluginName : toDelete) { }
unloadPlugin(pluginName); for (String pluginName : toDelete) {
System.gc(); unloadPlugin(pluginName);
int count = 0; System.gc();
File dir = new File(pluginDirectory, pluginName); int count = 0;
while (!deleteDir(dir) && count < 5) { File dir = new File(pluginDirectory, pluginName);
Log.error("Error unloading plugin " + pluginName + ". " + while (!deleteDir(dir) && count < 5) {
"Will attempt again momentarily."); Log.error("Error unloading plugin " + pluginName + ". " +
Thread.sleep(5000); "Will attempt again momentarily.");
count++; Thread.sleep(5000);
} count++;
}
}
// Load all plugins that need to be loaded.
for (int i = 0; i < dirs.length; i++) {
File dirFile = dirs[i];
// If the plugin hasn't already been started, start it.
if (dirFile.exists() && !plugins.containsKey(dirFile.getName())) {
loadPlugin(dirFile);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment