Shut the logger down when the plugin is terminated.
[Sone.git] / src / main / java / net / pterodactylus / sone / main / SonePlugin.java
index 5bc32e8..7ac2c83 100644 (file)
@@ -31,12 +31,15 @@ import net.pterodactylus.util.config.ConfigurationException;
 import net.pterodactylus.util.config.MapConfigurationBackend;
 import net.pterodactylus.util.config.XMLConfigurationBackend;
 import net.pterodactylus.util.logging.Logging;
+import net.pterodactylus.util.version.Version;
 import freenet.client.async.DatabaseDisabledException;
 import freenet.l10n.BaseL10n.LANGUAGE;
 import freenet.l10n.PluginL10n;
 import freenet.pluginmanager.FredPlugin;
 import freenet.pluginmanager.FredPluginBaseL10n;
 import freenet.pluginmanager.FredPluginL10n;
+import freenet.pluginmanager.FredPluginThreadless;
+import freenet.pluginmanager.FredPluginVersioned;
 import freenet.pluginmanager.PluginRespirator;
 
 /**
@@ -45,13 +48,16 @@ import freenet.pluginmanager.PluginRespirator;
  *
  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
  */
-public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10n {
+public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10n, FredPluginThreadless, FredPluginVersioned {
 
        static {
                /* initialize logging. */
                Logging.setup("sone");
        }
 
+       /** The version. */
+       private static final Version VERSION = new Version("SNAPSHOT", 0, 1);
+
        /** The logger. */
        private static final Logger logger = Logging.getLogger(SonePlugin.class);
 
@@ -61,6 +67,9 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
        /** The core. */
        private Core core;
 
+       /** The web interface. */
+       private WebInterface webInterface;
+
        /** The l10n helper. */
        private PluginL10n l10n;
 
@@ -124,7 +133,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
                FreenetInterface freenetInterface = new FreenetInterface(pluginRespirator.getNode(), pluginRespirator.getHLSimpleClient());
 
                /* create the web interface. */
-               WebInterface webInterface = new WebInterface(this);
+               webInterface = new WebInterface(this);
 
                /* create core. */
                core = new Core();
@@ -141,10 +150,16 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
         */
        @Override
        public void terminate() {
+               /* stop the web interface. */
+               webInterface.stop();
+
                /* stop the core. */
                core.stop();
 
                /* TODO wait for core to stop? */
+
+               /* shutdown logger. */
+               Logging.shutdown();
        }
 
        //
@@ -203,4 +218,16 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
                return SonePlugin.class.getClassLoader();
        }
 
+       //
+       // INTERFACE FredPluginVersioned
+       //
+
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public String getVersion() {
+               return VERSION.toString();
+       }
+
 }