Cleanup: avoid injecting Injector directly

- Inject SingletonStore to restrict the possible functions
- Refactor PasswordSecurityTest to correspond to the usual way of testing
This commit is contained in:
ljacqu
2017-03-21 22:59:21 +01:00
parent d19748fe5b
commit 7dbf5551c9
6 changed files with 80 additions and 86 deletions
@@ -1,12 +1,12 @@
package fr.xephi.authme.command.executable.authme;
import ch.jalu.injector.Injector;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.initialization.factory.SingletonStore;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.settings.Settings;
@@ -25,9 +25,6 @@ public class ReloadCommand implements ExecutableCommand {
@Inject
private AuthMe plugin;
@Inject
private Injector injector;
@Inject
private Settings settings;
@@ -37,6 +34,12 @@ public class ReloadCommand implements ExecutableCommand {
@Inject
private CommonService commonService;
@Inject
private SingletonStore<Reloadable> reloadableStore;
@Inject
private SingletonStore<SettingsDependent> settingsDependentStore;
@Override
public void executeCommand(CommandSender sender, List<String> arguments) {
try {
@@ -56,10 +59,10 @@ public class ReloadCommand implements ExecutableCommand {
}
private void performReloadOnServices() {
injector.retrieveAllOfType(Reloadable.class)
reloadableStore.retrieveAllOfType()
.forEach(r -> r.reload());
injector.retrieveAllOfType(SettingsDependent.class)
settingsDependentStore.retrieveAllOfType()
.forEach(s -> s.reload(settings));
}
}