From 174865a5a746755a0c09f51a7840ac0e6034cbb6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 29 Nov 2019 17:30:45 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=9A=A7=20Add=20notification=20manager=20to?= =?utf8?q?=20web=20interface=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/web/WebInterface.java | 6 ++++-- src/main/kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt | 6 ++++++ .../kotlin/net/pterodactylus/sone/web/WebInterfaceModuleTest.kt | 8 ++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index e31d9a8..bcc7a11 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -124,7 +124,7 @@ public class WebInterface implements SessionProvider { private final Loaders loaders; /** The notification manager. */ - private final NotificationManager notificationManager = new NotificationManager(); + private final NotificationManager notificationManager; /** The Sone plugin. */ private final SonePlugin sonePlugin; @@ -207,7 +207,8 @@ public class WebInterface implements SessionProvider { ParserFilter parserFilter, ShortenFilter shortenFilter, RenderFilter renderFilter, LinkedElementRenderFilter linkedElementRenderFilter, - PageToadletRegistry pageToadletRegistry, MetricRegistry metricRegistry, Translation translation, L10nFilter l10nFilter) { + PageToadletRegistry pageToadletRegistry, MetricRegistry metricRegistry, Translation translation, L10nFilter l10nFilter, + NotificationManager notificationManager) { this.sonePlugin = sonePlugin; this.loaders = loaders; this.listNotificationFilter = listNotificationFilter; @@ -223,6 +224,7 @@ public class WebInterface implements SessionProvider { this.metricRegistry = metricRegistry; this.l10nFilter = l10nFilter; this.translation = translation; + this.notificationManager = notificationManager; formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword(); soneTextParser = new SoneTextParser(getCore(), getCore()); diff --git a/src/main/kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt b/src/main/kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt index c996e30..3d87aa7 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/WebInterfaceModule.kt @@ -10,6 +10,7 @@ import net.pterodactylus.sone.freenet.wot.* import net.pterodactylus.sone.main.* import net.pterodactylus.sone.template.* import net.pterodactylus.sone.text.* +import net.pterodactylus.util.notify.* import net.pterodactylus.util.template.* import javax.inject.* import javax.inject.Singleton @@ -126,4 +127,9 @@ class WebInterfaceModule : AbstractModule() { @Named("toadletPathPrefix") fun getPathPrefix(): String = "/Sone/" + @Provides + @Singleton + fun getNotificationManager() = + NotificationManager() + } diff --git a/src/test/kotlin/net/pterodactylus/sone/web/WebInterfaceModuleTest.kt b/src/test/kotlin/net/pterodactylus/sone/web/WebInterfaceModuleTest.kt index 14427ef..ec45e67 100644 --- a/src/test/kotlin/net/pterodactylus/sone/web/WebInterfaceModuleTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/web/WebInterfaceModuleTest.kt @@ -15,6 +15,7 @@ import net.pterodactylus.sone.template.* import net.pterodactylus.sone.test.* import net.pterodactylus.sone.text.* import net.pterodactylus.sone.web.page.* +import net.pterodactylus.util.notify.* import net.pterodactylus.util.template.* import net.pterodactylus.util.web.* import org.hamcrest.MatcherAssert.* @@ -283,4 +284,11 @@ class WebInterfaceModuleTest { assertThat(injector.getInstance().createPageToadlet(page).path(), startsWith("/Sone/")) } + @Test + fun `notification manager is created as singleton`() { + val firstNotificationManager = injector.getInstance() + val secondNotificationManager = injector.getInstance() + assertThat(firstNotificationManager, sameInstance(secondNotificationManager)) + } + } -- 2.7.4