From: David ‘Bombe’ Roden Date: Fri, 29 Nov 2019 16:30:45 +0000 (+0100) Subject: 🚧 Add notification manager to web interface module X-Git-Tag: v81^2~15^2~3 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=174865a5a746755a0c09f51a7840ac0e6034cbb6;hp=c2749a08af5f846c7285c0bb6a930f372bd7f9cb 🚧 Add notification manager to web interface module --- 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)) + } + }