Commit 5d184015 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

1) Fixed issue in available plugins.

2) Added getMinServerVersion to PluginManager.
3) Switched calls to check database schema before calling initilize plugin.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4135 b35dd754-fafc-0310-a699-88a17e54d16e
parent 76c7517a
...@@ -15,6 +15,7 @@ import org.jivesoftware.util.Log; ...@@ -15,6 +15,7 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.XMPPServer; import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.container.Plugin; import org.jivesoftware.wildfire.container.Plugin;
import org.jivesoftware.wildfire.container.PluginManager; import org.jivesoftware.wildfire.container.PluginManager;
import org.jivesoftware.wildfire.container.PluginClassLoader;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
...@@ -102,8 +103,9 @@ public class SchemaManager { ...@@ -102,8 +103,9 @@ public class SchemaManager {
con = DbConnectionManager.getConnection(); con = DbConnectionManager.getConnection();
return checkSchema(con, schemaKey, schemaVersion, new ResourceLoader() { return checkSchema(con, schemaKey, schemaVersion, new ResourceLoader() {
public InputStream loadResource(String resourceName) { public InputStream loadResource(String resourceName) {
return pluginManager.getPluginClassloader( PluginClassLoader pluginClassLoader = pluginManager.getPluginClassloader(plugin);
plugin).getClassLoader().getResourceAsStream( resourceName); ClassLoader classLoader = pluginClassLoader.getClassLoader();
return classLoader.getResourceAsStream(resourceName);
} }
}); });
} }
...@@ -306,7 +308,7 @@ public class SchemaManager { ...@@ -306,7 +308,7 @@ public class SchemaManager {
in.close(); in.close();
} }
catch (Exception e) { catch (Exception e) {
// Ignore. Log.error(e);
} }
} }
} }
......
...@@ -340,7 +340,7 @@ public class PluginManager { ...@@ -340,7 +340,7 @@ public class PluginManager {
} }
} }
plugin.initializePlugin(this, pluginDir);
plugins.put(pluginDir.getName(), plugin); plugins.put(pluginDir.getName(), plugin);
pluginDirs.put(plugin, pluginDir); pluginDirs.put(plugin, pluginDir);
...@@ -382,6 +382,9 @@ public class PluginManager { ...@@ -382,6 +382,9 @@ public class PluginManager {
// Check the plugin's database schema (if it requires one). // Check the plugin's database schema (if it requires one).
DbConnectionManager.getSchemaManager().checkPluginSchema(plugin); DbConnectionManager.getSchemaManager().checkPluginSchema(plugin);
plugin.initializePlugin(this, pluginDir);
// If there a <adminconsole> section defined, register it. // If there a <adminconsole> section defined, register it.
Element adminElement = (Element)pluginXML.selectSingleNode("/plugin/adminconsole"); Element adminElement = (Element)pluginXML.selectSingleNode("/plugin/adminconsole");
if (adminElement != null) { if (adminElement != null) {
...@@ -587,6 +590,17 @@ public class PluginManager { ...@@ -587,6 +590,17 @@ public class PluginManager {
return getElementValue(plugin, "/plugin/version"); return getElementValue(plugin, "/plugin/version");
} }
/**
* Returns the minimum server version this plugin can run within. The value is retrieved from the plugin.xml file
* of the plugin. If the value could not be found, <tt>null</tt> will be returned.
*
* @param plugin the plugin.
* @return the plugin's version.
*/
public String getMinServerVersion(Plugin plugin) {
return getElementValue(plugin, "/plugin/minServerVersion");
}
/** /**
* Returns the database schema key of a plugin, if it exists. The value is retrieved * Returns the database schema key of a plugin, if it exists. The value is retrieved
* from the plugin.xml file of the plugin. If the value could not be found, <tt>null</tt> * from the plugin.xml file of the plugin. If the value could not be found, <tt>null</tt>
......
...@@ -380,7 +380,7 @@ ...@@ -380,7 +380,7 @@
Version version = server.getServerInfo().getVersion(); Version version = server.getServerInfo().getVersion();
List<Plugin> outdatedPlugins = new ArrayList<Plugin>(); List<Plugin> outdatedPlugins = new ArrayList<Plugin>();
for (Plugin plugin : server.getPluginManager().getPlugins()) { for (Plugin plugin : server.getPluginManager().getPlugins()) {
String pluginVersion = server.getPluginManager().getVersion(plugin); String pluginVersion = server.getPluginManager().getMinServerVersion(plugin);
if (pluginVersion != null && pluginVersion.compareTo(version.getVersionString()) > 0) { if (pluginVersion != null && pluginVersion.compareTo(version.getVersionString()) > 0) {
outdatedPlugins.add(plugin); outdatedPlugins.add(plugin);
} }
......
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