Commit 0685be33 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Attempted plugin fixes.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@474 b35dd754-fafc-0310-a699-88a17e54d16e
parent 2370055a
......@@ -12,7 +12,6 @@
package org.jivesoftware.messenger.container;
import org.jivesoftware.util.Log;
import org.jivesoftware.util.XMLProperties;
import org.jivesoftware.messenger.JiveGlobals;
import org.jivesoftware.admin.AdminConsole;
import org.dom4j.Document;
......@@ -39,6 +38,7 @@ public class PluginManager {
private File pluginDirectory;
private Map<String,Plugin> plugins;
private Map<Plugin,PluginClassLoader> classloaders;
private boolean setupMode = !(Boolean.valueOf(JiveGlobals.getXMLProperty("setup")).booleanValue());
private ScheduledExecutorService executor = null;
......@@ -50,6 +50,7 @@ public class PluginManager {
public PluginManager(File pluginDir) {
this.pluginDirectory = pluginDir;
plugins = new HashMap<String,Plugin>();
classloaders = new HashMap<Plugin,PluginClassLoader>();
}
/**
......@@ -114,10 +115,11 @@ public class PluginManager {
plugin = (Plugin)pluginLoader.loadClass(className).newInstance();
plugin.initialize(this, pluginDir);
plugins.put(pluginDir.getName(), plugin);
classloaders.put(plugin, pluginLoader);
// Load any JSP's defined by the plugin.
File webXML = new File(pluginDir, "web" + File.separator + "web.xml");
if (webXML.exists()) {
PluginServlet.registerServlets(plugin, webXML);
PluginServlet.registerServlets(this, plugin, webXML);
}
// If there a <adminconsole> section defined, register it.
Element adminElement = (Element)pluginXML.selectSingleNode("/plugin/adminconsole");
......@@ -141,6 +143,13 @@ public class PluginManager {
}
}
public Class loadClass(String className, Plugin plugin) throws ClassNotFoundException,
IllegalAccessException, InstantiationException
{
PluginClassLoader loader = classloaders.get(plugin);
return loader.loadClass(className);
}
/**
* A service that monitors the plugin directory for plugins. It periodically
* checks for new plugin JAR files and extracts them if they haven't already
......
......@@ -93,7 +93,7 @@ public class PluginServlet extends HttpServlet {
* @param webXML the web.xml file containing JSP page names to servlet class file
* mappings.
*/
public static void registerServlets(Plugin plugin, File webXML) {
public static void registerServlets(PluginManager manager, Plugin plugin, File webXML) {
if (!webXML.exists()) {
Log.error("Could not register plugin servlets, file " + webXML.getAbsolutePath() +
" does not exist.");
......@@ -112,7 +112,7 @@ public class PluginServlet extends HttpServlet {
Element servletElement = (Element)classes.get(i);
String name = servletElement.element("servlet-name").getTextTrim();
String className = servletElement.element("servlet-class").getTextTrim();
classMap.put(name, plugin.getClass().getClassLoader().loadClass(className));
classMap.put(name, manager.loadClass(className, plugin));
}
// Find all <servelt-mapping> entries to discover name to URL mapping.
List names = doc.selectNodes("//servlet-mapping");
......
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