From f003c93ea19b72b16743a2483726385cee6b53ba Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 13 Oct 2010 15:14:59 +0200 Subject: [PATCH] Store plugin store when plugin is terminated. --- src/main/java/net/pterodactylus/sone/main/SonePlugin.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index 7ac2c83..b253d41 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -41,6 +41,7 @@ import freenet.pluginmanager.FredPluginL10n; import freenet.pluginmanager.FredPluginThreadless; import freenet.pluginmanager.FredPluginVersioned; import freenet.pluginmanager.PluginRespirator; +import freenet.pluginmanager.PluginStore; /** * This class interfaces with Freenet. It is the class that is loaded by the @@ -73,6 +74,9 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 /** The l10n helper. */ private PluginL10n l10n; + /** The plugin store. */ + private PluginStore pluginStore; + // // ACCESSORS // @@ -118,7 +122,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 /* create a configuration. */ Configuration configuration; try { - configuration = new Configuration(new PluginStoreConfigurationBackend(pluginRespirator.getStore())); + configuration = new Configuration(new PluginStoreConfigurationBackend(pluginStore = pluginRespirator.getStore())); } catch (DatabaseDisabledException dde1) { logger.log(Level.WARNING, "Could not load plugin store, using XML files."); try { @@ -157,6 +161,11 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 core.stop(); /* TODO wait for core to stop? */ + try { + pluginRespirator.putStore(pluginStore); + } catch (DatabaseDisabledException dde1) { + logger.log(Level.WARNING, "Could not store plugin store, database is disabled.", dde1); + } /* shutdown logger. */ Logging.shutdown(); -- 2.7.4