From b12270d58289395ad3b3c10f744d44bd48984a4b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 13 Nov 2024 23:08:07 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=8F=97=EF=B8=8F=20Use=20Rhynodge=20module?= =?utf8?q?=20and=20let=20Guice=20handle=20everything?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../net/pterodactylus/rhynodge/engine/Starter.java | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/pterodactylus/rhynodge/engine/Starter.java b/src/main/java/net/pterodactylus/rhynodge/engine/Starter.java index 20611c1..ce84b5e 100644 --- a/src/main/java/net/pterodactylus/rhynodge/engine/Starter.java +++ b/src/main/java/net/pterodactylus/rhynodge/engine/Starter.java @@ -18,12 +18,8 @@ package net.pterodactylus.rhynodge.engine; import java.io.IOException; -import java.util.Arrays; -import net.pterodactylus.rhynodge.actions.EmailAction; import net.pterodactylus.rhynodge.loader.ChainWatcher; -import net.pterodactylus.rhynodge.loader.ChainWatcher.ChainDirectory; -import net.pterodactylus.rhynodge.states.StateManager.StateDirectory; import net.pterodactylus.util.envopt.Parser; import net.pterodactylus.util.inject.ObjectBinding; @@ -47,27 +43,17 @@ public class Starter { public static void main(String... arguments) throws IOException { Options options = Parser.fromSystemEnvironment().parseEnvironment(Options::new); logger.info("Options: " + options); - EmailAction errorEmailAction = - createErrorEmailAction(options.smtpHostname, options.errorEmailSender, options.errorEmailRecipient); - Injector injector = Guice.createInjector(Arrays.asList( - ObjectBinding.forClass(String.class).named("smtpHostname").is(options.smtpHostname), - ObjectBinding.forClass(String.class).named("emailSender").is(options.emailSender), - ObjectBinding.forClass(String.class).named("emailRecipient").is(options.emailRecipient), - ObjectBinding.forClass(StateDirectory.class).is(StateDirectory.of(options.stateDirectory)), - ObjectBinding.forClass(ChainDirectory.class).is(ChainDirectory.of(options.chainDirectory)), - ObjectBinding.forClass(EmailAction.class).is(errorEmailAction) - )); + Injector injector = Guice.createInjector( + ObjectBinding.forClass(Options.class).shallBe(options), + new RhynodgeModule() + ); /* start a watcher. */ ChainWatcher chainWatcher = injector.getInstance(ChainWatcher.class); chainWatcher.startAsync().awaitTerminated(); } - private static EmailAction createErrorEmailAction(String smtpHostname, String errorEmailSender, String errorEmailRecipient) { - return new EmailAction(smtpHostname, errorEmailSender, errorEmailRecipient); - } - private static final Logger logger = Logger.getLogger(Starter.class); } -- 2.7.4