From: David ‘Bombe’ Roden Date: Thu, 12 Dec 2019 19:00:47 +0000 (+0100) Subject: 🚧 Use ticker from Sone module for notifications X-Git-Tag: v81^2~5^2~33 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=1ad1aae2e29c608c5e1ab89e125bf2267fed18c6;p=Sone.git 🚧 Use ticker from Sone module for notifications --- 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() )