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;
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);
}