+ @Override
+ @SuppressWarnings("synthetic-access")
+ protected void configure() {
+ bind(PluginRespirator.class).toInstance(SonePlugin.this.pluginRespirator);
+ bind(Node.class).toInstance(SonePlugin.this.pluginRespirator.getNode());
+ }
+ };
+ /* Sone injector configuration. */
+ AbstractModule soneModule = new AbstractModule() {
+
+ @Override
+ protected void configure() {
+ bind(Core.class).in(Singleton.class);
+ bind(MemoryDatabase.class).in(Singleton.class);
+ bind(EventBus.class).toInstance(eventBus);
+ bind(Configuration.class).toInstance(startConfiguration);
+ bind(FreenetInterface.class).in(Singleton.class);
+ bind(PluginConnector.class).in(Singleton.class);
+ bind(WebOfTrustConnector.class).in(Singleton.class);
+ bind(WebOfTrustUpdater.class).in(Singleton.class);
+ bind(IdentityManager.class).in(Singleton.class);
+ bind(String.class).annotatedWith(Names.named("WebOfTrustContext")).toInstance("Sone");
+ bind(SonePlugin.class).toInstance(SonePlugin.this);
+ bind(FcpInterface.class).in(Singleton.class);
+ bind(Database.class).to(MemoryDatabase.class);
+ bind(SoneProvider.class).to(Core.class).in(Singleton.class);
+ bindListener(Matchers.any(), new TypeListener() {
+
+ @Override
+ public <I> void hear(TypeLiteral<I> typeLiteral, TypeEncounter<I> typeEncounter) {
+ typeEncounter.register(new InjectionListener<I>() {
+
+ @Override
+ public void afterInjection(I injectee) {
+ eventBus.register(injectee);
+ }
+ });
+ }
+ });
+ }
+
+ };
+ Injector injector = Guice.createInjector(freenetModule, soneModule);
+ core = injector.getInstance(Core.class);
+
+ /* create web of trust connector. */
+ webOfTrustConnector = injector.getInstance(WebOfTrustConnector.class);
+
+ /* create FCP interface. */
+ fcpInterface = injector.getInstance(FcpInterface.class);
+ core.setFcpInterface(fcpInterface);
+
+ /* create the web interface. */
+ webInterface = injector.getInstance(WebInterface.class);
+
+ boolean startupFailed = true;
+ try {
+
+ /* 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);
+ 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();
+ }
+ }