From 043ae80d779448ceb2cf9fcff5d8942a5db7b0bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 12 Dec 2019 19:41:16 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=9A=A7=20Add=20DI=20configuration=20for=20?= =?utf8?q?notification=20ticker?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/net/pterodactylus/sone/main/SoneModule.kt | 10 ++++++++++ src/test/kotlin/net/pterodactylus/sone/main/SoneModuleTest.kt | 6 ++++++ 2 files changed, 16 insertions(+) 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")) + } + } -- 2.7.4