- boolean startupFailed = true;
- try {
- /* create freenet interface. */
- FreenetInterface freenetInterface = new FreenetInterface(pluginRespirator.getNode());
-
- /* create web of trust connector. */
- PluginConnector pluginConnector = new PluginConnector(pluginRespirator);
- WebOfTrustConnector 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 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);
+ final Configuration startConfiguration;
+ if ((newConfiguration != null) && (oldConfiguration != newConfiguration)) {
+ logger.log(Level.INFO, "Setting configuration to file-based configuration.");
+ startConfiguration = newConfiguration;
+ } else {
+ startConfiguration = oldConfiguration;
+ }
+ final EventBus eventBus = new EventBus();
+
+ /* Freenet injector configuration. */
+ FreenetModule freenetModule = new FreenetModule(pluginRespirator);
+
+ /* Sone injector configuration. */
+ AbstractModule soneModule = new AbstractModule() {
+
+ @Override
+ protected void configure() {
+ bind(EventBus.class).toInstance(eventBus);
+ bind(Configuration.class).toInstance(startConfiguration);
+ Context context = new Context("Sone");
+ bind(Context.class).toInstance(context);
+ bind(getOptionalContextTypeLiteral()).toInstance(of(context));
+ bind(SonePlugin.class).toInstance(SonePlugin.this);
+ bind(Version.class).toInstance(Version.parse(getVersion()));
+ bind(PluginVersion.class).toInstance(new PluginVersion(getVersion()));
+ bind(PluginYear.class).toInstance(new PluginYear(getYear()));
+ bind(PluginHomepage.class).toInstance(new PluginHomepage(getHomepage()));
+ bind(Database.class).to(MemoryDatabase.class).in(Singleton.class);
+ bind(BaseL10n.class).toInstance(l10n.getBase());
+ bind(SoneProvider.class).to(Core.class).in(Singleton.class);
+ bind(PostProvider.class).to(Core.class).in(Singleton.class);
+ if (startConfiguration.getBooleanValue("Developer.LoadFromFilesystem").getValue(false)) {
+ String path = startConfiguration.getStringValue("Developer.FilesystemPath").getValue(null);
+ if (path != null) {
+ bind(Loaders.class).toInstance(new DebugLoaders(path));
+ }
+ }
+ 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);
+ }
+ });
+ }
+ });