From: David ‘Bombe’ Roden Date: Wed, 13 Nov 2024 22:08:07 +0000 (+0100) Subject: 🏗️ Use Rhynodge module and let Guice handle everything X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=rhynodge.git 🏗️ Use Rhynodge module and let Guice handle everything --- 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); }