From: David ‘Bombe’ Roden Date: Thu, 12 Dec 2019 18:41:16 +0000 (+0100) Subject: 🚧 Add DI configuration for notification ticker X-Git-Tag: v81^2~5^2~35 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=043ae80d779448ceb2cf9fcff5d8942a5db7b0bf;p=Sone.git 🚧 Add DI configuration for notification ticker --- diff --git a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt index 8a3b0c2..5a66015 100644 --- a/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt @@ -16,7 +16,11 @@ 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() { @@ -67,6 +71,12 @@ open class SoneModule(private val sonePlugin: SonePlugin, private val eventBus: }) } + @Provides + @Singleton + @Named("notification") + fun getNotificationTicker(): ScheduledExecutorService = + newSingleThreadScheduledExecutor() + private val logger: Logger = Logging.getLogger(javaClass) } diff --git a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt index 7f6b8d0..9fe5dbb 100644 --- a/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt @@ -20,6 +20,7 @@ import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* import org.mockito.Mockito.* import java.io.* +import java.util.concurrent.* import java.util.concurrent.atomic.* import kotlin.test.* @@ -216,4 +217,9 @@ class SoneModuleTest { injector.verifySingletonInstance() } + @Test + fun `notification ticker is created as singleton`() { + injector.verifySingletonInstance(named("notification")) + } + }