From 1ad1aae2e29c608c5e1ab89e125bf2267fed18c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 12 Dec 2019 20:00:47 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=9A=A7=20Use=20ticker=20from=20Sone=20modu?= =?utf8?q?le=20for=20notifications?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../pterodactylus/sone/web/notification/NotificationHandlerModule.kt | 4 ---- .../net/pterodactylus/sone/web/notification/SoneLockedHandler.kt | 2 +- .../kotlin/net/pterodactylus/sone/web/notification/StartupHandler.kt | 2 +- .../sone/web/notification/NotificationHandlerModuleTest.kt | 3 +++ 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt b/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt index 539f001..0d7bb25 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt @@ -77,10 +77,6 @@ class NotificationHandlerModule : AbstractModule() { ListNotification("sones-locked-notification", "sones", loaders.loadTemplate("/templates/notify/lockedSonesNotification.html"), dismissable = true) @Provides - fun getScheduledExecutorService(): ScheduledExecutorService = - newScheduledThreadPool(1) - - @Provides @Singleton @Named("localPost") fun getLocalPostNotification(loaders: Loaders) = diff --git a/src/main/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandler.kt b/src/main/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandler.kt index e8f2a79..2217bad 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandler.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/SoneLockedHandler.kt @@ -33,7 +33,7 @@ import javax.inject.* class SoneLockedHandler @Inject constructor( private val notificationManager: NotificationManager, @Named("soneLocked") private val notification: ListNotification, - private val executor: ScheduledExecutorService) { + @Named("notification") private val executor: ScheduledExecutorService) { private val future: AtomicReference> = AtomicReference() diff --git a/src/main/kotlin/net/pterodactylus/sone/web/notification/StartupHandler.kt b/src/main/kotlin/net/pterodactylus/sone/web/notification/StartupHandler.kt index c3b69f0..06acf94 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/StartupHandler.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/StartupHandler.kt @@ -30,7 +30,7 @@ import javax.inject.* class StartupHandler @Inject constructor( private val notificationManager: NotificationManager, @Named("startup") private val notification: TemplateNotification, - private val ticker: ScheduledExecutorService) { + @Named("notification") private val ticker: ScheduledExecutorService) { @Subscribe fun startup(startup: Startup) { diff --git a/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt index 477e6e3..b84b3ee 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt @@ -34,6 +34,7 @@ import org.hamcrest.MatcherAssert.* import org.hamcrest.Matchers.* import org.mockito.Mockito.* import java.io.* +import java.util.concurrent.* import kotlin.test.* /** @@ -42,12 +43,14 @@ import kotlin.test.* class NotificationHandlerModuleTest { private val core = mock() + private val ticker = mock() private val notificationManager = NotificationManager() private val loaders = TestLoaders() private val injector: Injector = createInjector( Core::class.isProvidedBy(core), NotificationManager::class.isProvidedBy(notificationManager), Loaders::class.isProvidedBy(loaders), + ScheduledExecutorService::class.withNameIsProvidedBy(ticker, "notification"), NotificationHandlerModule() ) -- 2.7.4