projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change Sone downloading logic.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
main
/
SonePlugin.java
diff --git
a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java
b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java
index
60812cd
..
810fef1
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
+++ b/
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
@@
-31,6
+31,7
@@
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.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.client.async.DatabaseDisabledException;
import freenet.l10n.BaseL10n.LANGUAGE;
import freenet.l10n.PluginL10n;
@@
-38,7
+39,9
@@
import freenet.pluginmanager.FredPlugin;
import freenet.pluginmanager.FredPluginBaseL10n;
import freenet.pluginmanager.FredPluginL10n;
import freenet.pluginmanager.FredPluginThreadless;
import freenet.pluginmanager.FredPluginBaseL10n;
import freenet.pluginmanager.FredPluginL10n;
import freenet.pluginmanager.FredPluginThreadless;
+import freenet.pluginmanager.FredPluginVersioned;
import freenet.pluginmanager.PluginRespirator;
import freenet.pluginmanager.PluginRespirator;
+import freenet.pluginmanager.PluginStore;
/**
* This class interfaces with Freenet. It is the class that is loaded by the
/**
* This class interfaces with Freenet. It is the class that is loaded by the
@@
-46,13
+49,16
@@
import freenet.pluginmanager.PluginRespirator;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10n, FredPluginThreadless {
+public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10n, FredPluginThreadless
, FredPluginVersioned
{
static {
/* initialize logging. */
Logging.setup("sone");
}
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);
/** The logger. */
private static final Logger logger = Logging.getLogger(SonePlugin.class);
@@
-68,6
+74,9
@@
public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
/** The l10n helper. */
private PluginL10n l10n;
/** The l10n helper. */
private PluginL10n l10n;
+ /** The plugin store. */
+ private PluginStore pluginStore;
+
//
// ACCESSORS
//
//
// ACCESSORS
//
@@
-113,7
+122,7
@@
public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
/* create a configuration. */
Configuration configuration;
try {
/* create a configuration. */
Configuration configuration;
try {
- configuration = new Configuration(new PluginStoreConfigurationBackend(pluginRespirator.getStore()));
+ configuration = new Configuration(new PluginStoreConfigurationBackend(plugin
Store = plugin
Respirator.getStore()));
} catch (DatabaseDisabledException dde1) {
logger.log(Level.WARNING, "Could not load plugin store, using XML files.");
try {
} catch (DatabaseDisabledException dde1) {
logger.log(Level.WARNING, "Could not load plugin store, using XML files.");
try {
@@
-136,8
+145,21
@@
public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
core.freenetInterface(freenetInterface);
/* start core! */
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();
+ }
+ }
}
/**
}
/**
@@
-152,6
+174,14
@@
public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
core.stop();
/* TODO wait for core to stop? */
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();
}
//
}
//
@@
-210,4
+240,16
@@
public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
return SonePlugin.class.getClassLoader();
}
return SonePlugin.class.getClassLoader();
}
+ //
+ // INTERFACE FredPluginVersioned
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getVersion() {
+ return VERSION.toString();
+ }
+
}
}