X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fmain%2FSonePlugin.java;h=810fef1164211512f7c9bda34cc6f7eda51b5f15;hb=ca4a41282673af46640e423473772444dea4f3c6;hp=c7afdd0213a7c1753c2a694ae5c777e84bd9ad88;hpb=84a2d480d9c45cf7c3513f9557dd00056b30336f;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index c7afdd0..810fef1 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 { @@ -141,8 +145,21 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 core.freenetInterface(freenetInterface); /* start core! */ - core.start(); - webInterface.start(); + boolean startupFailed = true; + try { + core.start(); + webInterface.start(); + startupFailed = false; + } finally { + if (startupFailed) { + /* + * we let the exception bubble up but shut the logging down so + * that the logfile is not swamped by the installed logging + * handlers of the failed instances. + */ + Logging.shutdown(); + } + } } /** @@ -157,6 +174,14 @@ 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(); } //