X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fmain%2FSoneModule.kt;h=a95cf78cadb9038f270a91baf69048295769551f;hp=31cc54a365a513093361f45e98393b20b66bb96a;hb=HEAD;hpb=33b58cb4388ee7ca267470c0d883653e1a16dff4 diff --git a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt index 31cc54a..a95cf78 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt @@ -1,20 +1,29 @@ package net.pterodactylus.sone.main +import com.codahale.metrics.* import com.google.common.base.* import com.google.common.eventbus.* import com.google.inject.* import com.google.inject.matcher.* import com.google.inject.name.Names.* import com.google.inject.spi.* -import freenet.l10n.* -import net.pterodactylus.sone.core.* +import net.pterodactylus.sone.core.SoneUriCreator import net.pterodactylus.sone.database.* import net.pterodactylus.sone.database.memory.* +import net.pterodactylus.sone.freenet.* import net.pterodactylus.sone.freenet.wot.* +import net.pterodactylus.sone.web.FreenetSessionProvider +import net.pterodactylus.sone.web.SessionProvider import net.pterodactylus.util.config.* import net.pterodactylus.util.config.ConfigurationException +import net.pterodactylus.util.logging.* import net.pterodactylus.util.version.Version import java.io.* +import java.util.concurrent.* +import java.util.concurrent.Executors.* +import java.util.logging.* +import javax.inject.* +import javax.inject.Singleton open class SoneModule(private val sonePlugin: SonePlugin, private val eventBus: EventBus) : AbstractModule() { @@ -50,22 +59,31 @@ open class SoneModule(private val sonePlugin: SonePlugin, private val eventBus: bind(PluginYear::class.java).toInstance(PluginYear(sonePlugin.year)) bind(PluginHomepage::class.java).toInstance(PluginHomepage(sonePlugin.homepage)) bind(Database::class.java).to(MemoryDatabase::class.java).`in`(Singleton::class.java) - bind(BaseL10n::class.java).toInstance(sonePlugin.l10n().base) + bind(Translation::class.java).toInstance(BaseL10nTranslation(sonePlugin.l10n().base)) loaders?.let { bind(Loaders::class.java).toInstance(it) } + bind(MetricRegistry::class.java).`in`(Singleton::class.java) + bind(WebOfTrustConnector::class.java).to(PluginWebOfTrustConnector::class.java).`in`(Singleton::class.java) + bind(TickerShutdown::class.java).`in`(Singleton::class.java) + bind(SoneUriCreator::class.java).`in`(Singleton::class.java) + bind(SessionProvider::class.java).to(FreenetSessionProvider::class.java).`in`(Singleton::class.java) bindListener(Matchers.any(), object : TypeListener { override fun hear(typeLiteral: TypeLiteral, typeEncounter: TypeEncounter) { - typeEncounter.register(InjectionListener { injectee -> eventBus.register(injectee) }) + typeEncounter.register(InjectionListener { injectee -> + logger.fine { "Injecting $injectee..." } + eventBus.register(injectee) + }) } }) } @Provides @Singleton - fun getCore(configuration: Configuration, freenetInterface: FreenetInterface, identityManager: IdentityManager, soneDownloader: SoneDownloader, imageInserter: ImageInserter, updateChecker: UpdateChecker, webOfTrustUpdater: WebOfTrustUpdater, eventBus: EventBus, database: Database) = - Core(configuration, freenetInterface, identityManager, soneDownloader, imageInserter, updateChecker, webOfTrustUpdater, eventBus, database).apply { - debugInformation.showVersionInformation = configuration.getBooleanValue("Debug/ShowVersionInformation").getValue(false) - }.also(eventBus::register) + @Named("notification") + fun getNotificationTicker(): ScheduledExecutorService = + newSingleThreadScheduledExecutor() + + private val logger: Logger = Logging.getLogger(javaClass) }