Commit e525380f authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Added support to retrieve JAR/WAR file that created a plugin. JM-1051

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8191 b35dd754-fafc-0310-a699-88a17e54d16e
parent cceee678
...@@ -49,6 +49,7 @@ public class PluginManager { ...@@ -49,6 +49,7 @@ public class PluginManager {
private Map<String, Plugin> plugins; private Map<String, Plugin> plugins;
private Map<Plugin, PluginClassLoader> classloaders; private Map<Plugin, PluginClassLoader> classloaders;
private Map<Plugin, File> pluginDirs; private Map<Plugin, File> pluginDirs;
private Map<String, File> pluginFiles;
private ScheduledExecutorService executor = null; private ScheduledExecutorService executor = null;
private Map<Plugin, PluginDevEnvironment> pluginDevelopment; private Map<Plugin, PluginDevEnvironment> pluginDevelopment;
private Map<Plugin, List<String>> parentPluginMap; private Map<Plugin, List<String>> parentPluginMap;
...@@ -66,6 +67,7 @@ public class PluginManager { ...@@ -66,6 +67,7 @@ public class PluginManager {
this.pluginDirectory = pluginDir; this.pluginDirectory = pluginDir;
plugins = new ConcurrentHashMap<String, Plugin>(); plugins = new ConcurrentHashMap<String, Plugin>();
pluginDirs = new HashMap<Plugin, File>(); pluginDirs = new HashMap<Plugin, File>();
pluginFiles = new HashMap<String, File>();
classloaders = new HashMap<Plugin, PluginClassLoader>(); classloaders = new HashMap<Plugin, PluginClassLoader>();
pluginDevelopment = new HashMap<Plugin, PluginDevEnvironment>(); pluginDevelopment = new HashMap<Plugin, PluginDevEnvironment>();
parentPluginMap = new HashMap<Plugin, List<String>>(); parentPluginMap = new HashMap<Plugin, List<String>>();
...@@ -108,6 +110,7 @@ public class PluginManager { ...@@ -108,6 +110,7 @@ public class PluginManager {
} }
plugins.clear(); plugins.clear();
pluginDirs.clear(); pluginDirs.clear();
pluginFiles.clear();
classloaders.clear(); classloaders.clear();
pluginDevelopment.clear(); pluginDevelopment.clear();
childPluginMap.clear(); childPluginMap.clear();
...@@ -189,6 +192,16 @@ public class PluginManager { ...@@ -189,6 +192,16 @@ public class PluginManager {
return pluginDirs.get(plugin); return pluginDirs.get(plugin);
} }
/**
* Returns the JAR or WAR file that created the plugin.
*
* @param name the name of the plugin.
* @return the plugin JAR or WAR file.
*/
public File getPluginFile(String name) {
return pluginFiles.get(name);
}
/** /**
* Loads a plug-in module into the container. Loading consists of the * Loads a plug-in module into the container. Loading consists of the
* following steps:<ul> * following steps:<ul>
...@@ -971,6 +984,9 @@ public class PluginManager { ...@@ -971,6 +984,9 @@ public class PluginManager {
// The lib directory of the plugin may contain Pack200 versions of the JAR // The lib directory of the plugin may contain Pack200 versions of the JAR
// file. If so, unpack them. // file. If so, unpack them.
unpackArchives(new File(dir, "lib")); unpackArchives(new File(dir, "lib"));
// Store the JAR/WAR file that created the plugin folder
pluginFiles.put(pluginName, file);
} }
catch (Exception e) { catch (Exception e) {
Log.error(e); Log.error(e);
...@@ -1060,7 +1076,12 @@ public class PluginManager { ...@@ -1060,7 +1076,12 @@ public class PluginManager {
} }
} }
} }
return dir.delete(); boolean deleted = dir.delete();
if (deleted) {
// Remove the JAR/WAR file that created the plugin folder
pluginFiles.remove(dir.getName());
}
return deleted;
} }
} }
......
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