projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
🔀 Merge “next” into “feature/notification-handlers”
[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
3f010f6
..
d3dd3bd
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
+++ b/
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
@@
-22,6
+22,8
@@
import static java.util.logging.Logger.*;
import java.util.logging.Logger;
import java.util.logging.*;
import java.util.logging.Logger;
import java.util.logging.*;
+import javax.annotation.Nonnull;
+
import net.pterodactylus.sone.core.*;
import net.pterodactylus.sone.core.event.*;
import net.pterodactylus.sone.fcp.*;
import net.pterodactylus.sone.core.*;
import net.pterodactylus.sone.core.event.*;
import net.pterodactylus.sone.fcp.*;
@@
-60,7
+62,7
@@
public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
private final LoadingCache<String, Class<?>> classCache = CacheBuilder.newBuilder()
.build(new CacheLoader<String, Class<?>>() {
@Override
private final LoadingCache<String, Class<?>> classCache = CacheBuilder.newBuilder()
.build(new CacheLoader<String, Class<?>>() {
@Override
- public Class<?> load(String key) throws Exception {
+ public Class<?> load(
@Nonnull
String key) throws Exception {
return SonePlugin.class.getClassLoader().loadClass(key);
}
});
return SonePlugin.class.getClassLoader().loadClass(key);
}
});
@@
-108,6
+110,9
@@
public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
/** The core. */
private Core core;
/** The core. */
private Core core;
+ /** The event bus. */
+ private EventBus eventBus;
+
/** The web interface. */
private WebInterface webInterface;
/** The web interface. */
private WebInterface webInterface;
@@
-203,17
+208,29
@@
public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
/* we need to request this to install all notification handlers. */
injector.getInstance(NotificationHandler.class);
/* we need to request this to install all notification handlers. */
injector.getInstance(NotificationHandler.class);
+ /* and this is required to shutdown all tickers. */
+ injector.getInstance(TickerShutdown.class);
+
/* start core! */
core.start();
/* start the web interface! */
webInterface.start();
/* start core! */
core.start();
/* start the web interface! */
webInterface.start();
- webInterface.setNewConfig(injector.getInstance(Key.get(Boolean.class, Names.named("NewConfig"))));
+
+ /* send some events on startup */
+ eventBus = injector.getInstance(EventBus.class);
/* first start? */
if (injector.getInstance(Key.get(Boolean.class, Names.named("FirstStart")))) {
/* first start? */
if (injector.getInstance(Key.get(Boolean.class, Names.named("FirstStart")))) {
- injector.getInstance(EventBus.class).post(new FirstStart());
+ eventBus.post(new FirstStart());
+ } else {
+ /* new config? */
+ if (injector.getInstance(Key.get(Boolean.class, Names.named("NewConfig")))) {
+ eventBus.post(new ConfigNotRead());
+ }
}
}
+
+ eventBus.post(new Startup());
}
@VisibleForTesting
}
@VisibleForTesting
@@
-236,6
+253,9
@@
public class SonePlugin implements FredPlugin, FredPluginFCP, FredPluginL10n, Fr
*/
@Override
public void terminate() {
*/
@Override
public void terminate() {
+ /* send shutdown event. */
+ eventBus.post(new Shutdown());
+
try {
/* stop the web interface. */
webInterface.stop();
try {
/* stop the web interface. */
webInterface.stop();