- boolean startupFailed = true;
- try {
- /* create freenet interface. */
- FreenetInterface freenetInterface = new FreenetInterface(pluginRespirator.getNode());
-
- /* create web of trust connector. */
- PluginConnector pluginConnector = new PluginConnector(pluginRespirator);
- webOfTrustConnector = new WebOfTrustConnector(pluginConnector);
- identityManager = new IdentityManager(webOfTrustConnector);
- identityManager.setContext("Sone");
-
- /* create core. */
- core = new Core(oldConfiguration, freenetInterface, identityManager);
-
- /* create the web interface. */
- webInterface = new WebInterface(this);
- core.addCoreListener(webInterface);
-
- /* create FCP interface. */
- fcpInterface = new FcpInterface(core);
- core.setFcpInterface(fcpInterface);
-
- /* create the identity manager. */
- identityManager.addIdentityListener(core);
-
- /* start core! */
- core.start();
- if ((newConfiguration != null) && (oldConfiguration != newConfiguration)) {
- logger.log(Level.INFO, "Setting configuration to file-based configuration.");
- core.setConfiguration(newConfiguration);
- }
- webInterface.start();
- webInterface.setFirstStart(firstStart);
- webInterface.setNewConfig(newConfig);
- identityManager.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();
- }
- }
+ /* create web of trust connector. */
+ webOfTrustConnector = injector.getInstance(WebOfTrustConnector.class);
+
+ /* create FCP interface. */
+ fcpInterface = injector.getInstance(FcpInterface.class);
+
+ /* create the web interface. */
+ webInterface = injector.getInstance(WebInterface.class);
+ NotificationHandler notificationHandler = injector.getInstance(NotificationHandler.class);
+
+ /* start core! */
+ core.start();
+
+ /* start the web interface! */
+ webInterface.start();
+ webInterface.setFirstStart(injector.getInstance(Key.get(Boolean.class, Names.named("FirstStart"))));
+ webInterface.setNewConfig(injector.getInstance(Key.get(Boolean.class, Names.named("NewConfig"))));
+ notificationHandler.start();
+ }
+
+ @VisibleForTesting
+ protected Injector createInjector() {
+ FreenetModule freenetModule = new FreenetModule(pluginRespirator);
+ AbstractModule soneModule = new SoneModule(this, new EventBus());
+ Module webInterfaceModule = new WebInterfaceModule();
+
+ return createInjector(freenetModule, soneModule, webInterfaceModule);
+ }
+
+ @VisibleForTesting
+ protected Injector createInjector(Module... modules) {
+ return injectorCreator.invoke(modules);