Author: toad
Date: 2008-11-06 17:49:08 +0000 (Thu, 06 Nov 2008)
New Revision: 23356
Modified:
trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
trunk/freenet/src/freenet/pluginmanager/PluginManager.java
Log:
If a plugin fails to load, remember that we tried to load it, and try again on
next startup.
Change the useralert to have its dismiss button cause the plugin to NOT be
attempted to load again on next startup.
Modified: trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties
===================================================================
--- trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-11-06
17:44:39 UTC (rev 23355)
+++ trunk/freenet/src/freenet/l10n/freenet.l10n.en.properties 2008-11-06
17:49:08 UTC (rev 23356)
@@ -859,6 +859,7 @@
PluginConfig.installDir=Plugins installation directory
PluginConfig.installDirLong=Directory where to install the plugins
PluginManager.cannotSetOnceLoaded=Cannot set the plugins list once loaded
+PluginManager.deleteFailedPluginButton=Don't try again on next startup
PluginManager.loadedOnStartup=Plugins to load on startup
PluginManager.loadedOnStartupLong=Classpath, name and location for plugins to
load when node starts up
PluginManager.loadedPlugins=Plugins to load on start up
Modified: trunk/freenet/src/freenet/pluginmanager/PluginManager.java
===================================================================
--- trunk/freenet/src/freenet/pluginmanager/PluginManager.java 2008-11-06
17:44:39 UTC (rev 23355)
+++ trunk/freenet/src/freenet/pluginmanager/PluginManager.java 2008-11-06
17:49:08 UTC (rev 23356)
@@ -63,6 +63,7 @@
/* All currently starting plugins. */
private final Set<PluginProgress> startingPlugins = new
HashSet<PluginProgress>();
private final Vector<PluginInfoWrapper> pluginWrappers;
+ private final Vector<String> pluginsFailedLoad;
final Node node;
private final NodeClientCore core;
SubConfig pmconfig;
@@ -83,6 +84,7 @@
toadletList = new HashMap<String, FredPlugin>();
pluginWrappers = new Vector<PluginInfoWrapper>();
+ pluginsFailedLoad = new Vector<String>();
this.node = node;
this.core = node.clientCore;
@@ -166,6 +168,9 @@
for(PluginInfoWrapper pi : pluginWrappers) {
v.add(pi.getFilename());
}
+ for(String s : pluginsFailedLoad) {
+ v.add(s);
+ }
}
return v.toArray(new String[v.size()]);
@@ -244,14 +249,20 @@
} catch(PluginNotFoundException e) {
Logger.normal(this, "Loading plugin
failed (" + filename + ')', e);
String message = e.getMessage();
- core.alerts.register(new
SimpleUserAlert(true, l10n("pluginLoadingFailedTitle"),
l10n("pluginLoadingFailedWithMessage", new String[]{"name", "message"}, new
String[]{filename, message}), l10n("pluginLoadingFailedShort", "name",
filename), UserAlert.ERROR, PluginManager.class));
+ synchronized(pluginWrappers) {
+ pluginsFailedLoad.add(filename);
+ }
+ core.alerts.register(new
PluginLoadFailedUserAlert(filename, true, l10n("pluginLoadingFailedTitle"),
l10n("pluginLoadingFailedWithMessage", new String[]{"name", "message"}, new
String[]{filename, message}), l10n("pluginLoadingFailedShort", "name",
filename), UserAlert.ERROR, PluginManager.class));
} catch(UnsupportedClassVersionError e) {
Logger.error(this, "Could not load
plugin " + filename + " : " + e, e);
System.err.println("Could not load
plugin " + filename + " : " + e);
e.printStackTrace();
System.err.println("Plugin " + filename
+ " appears to require a later JVM");
Logger.error(this, "Plugin " + filename
+ " appears to require a later JVM");
- core.alerts.register(new
SimpleUserAlert(true, l10n("pluginReqNewerJVMTitle", "name", filename),
l10n("pluginReqNewerJVM", "name", filename), l10n("pluginLoadingFailedShort",
"name", filename), UserAlert.ERROR, PluginManager.class));
+ synchronized(pluginWrappers) {
+ pluginsFailedLoad.add(filename);
+ }
+ core.alerts.register(new
PluginLoadFailedUserAlert(filename, true, l10n("pluginReqNewerJVMTitle",
"name", filename), l10n("pluginReqNewerJVM", "name", filename),
l10n("pluginLoadingFailedShort", "name", filename), UserAlert.ERROR,
PluginManager.class));
} finally {
synchronized(startingPlugins) {
startingPlugins.remove(pluginProgress);
@@ -266,6 +277,28 @@
}, "Plugin Starter");
}
+ class PluginLoadFailedUserAlert extends SimpleUserAlert {
+
+ final String filename;
+
+ public PluginLoadFailedUserAlert(String filename, boolean
canDismiss, String title, String text, String shortText, short type, Object
userIdentifier) {
+ super(canDismiss, title, text, shortText, type,
userIdentifier);
+ this.filename = filename;
+ }
+
+ public String dismissButtonText() {
+ return l10n("deleteFailedPluginButton");
+ }
+
+ public void onDismiss() {
+ synchronized(pluginWrappers) {
+ pluginsFailedLoad.remove(filename);
+ }
+ }
+
+
+ }
+
void register(FredPlugin plug, PluginInfoWrapper pi) {
// handles FProxy? If so, register