[app-wiring-refactor]: Externalise configuration path

This commit is contained in:
Francesco Burato 2020-10-30 18:03:36 +00:00
parent d0c2135e17
commit e8bb8ae24b
4 changed files with 12 additions and 4 deletions

View file

@ -33,4 +33,4 @@ public abstract class FluentBuilder<ToBuild, RealBuilder extends FluentBuilder<T
instance.buildSequence.forEach(c -> c.accept(instance));
return instance.makeValue();
}
}
}

View file

@ -170,4 +170,4 @@
<deckType name="Block Constructed Custom - Star Wars" jar="mage-deck-constructed.jar" className="mage.deck.StarWarsBlock"/>
<deckType name="Limited" jar="mage-deck-limited.jar" className="mage.deck.Limited"/>
</deckTypes>
</config>
</config>

View file

@ -39,6 +39,7 @@ import java.io.IOException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.nio.charset.Charset;
import java.nio.file.Paths;
import java.util.*;
/**
@ -52,9 +53,11 @@ public final class Main {
private static final String testModeArg = "-testMode=";
private static final String fastDBModeArg = "-fastDbMode=";
private static final String adminPasswordArg = "-adminPassword=";
private static final String configPathProp = "xmage.config.path";
private static final File pluginFolder = new File("plugins");
private static final File extensionFolder = new File("extensions");
private static final String defaultConfigPath = Paths.get("config", "config.xml").toString();
public static final PluginClassLoader classLoader = new PluginClassLoader();
private static TransporterServer server;
@ -69,7 +72,6 @@ public final class Main {
logger.info("Starting MAGE server version " + version);
logger.info("Logging level: " + logger.getEffectiveLevel());
logger.info("Default charset: " + Charset.defaultCharset());
final ConfigWrapper config = new ConfigWrapper(ConfigFactory.loadFromFile("config/config.xml"));
String adminPassword = "";
for (String arg : args) {
if (arg.startsWith(testModeArg)) {
@ -82,6 +84,13 @@ public final class Main {
}
}
final String configPath = Optional.ofNullable(System.getProperty(configPathProp))
.orElse(defaultConfigPath);
logger.info(String.format("Reading configuration from path=%s", configPath));
final ConfigWrapper config = new ConfigWrapper(ConfigFactory.loadFromFile(configPath));
if (config.isAuthenticationActivated()) {
logger.info("Check authorized user DB version ...");
if (!AuthorizedUserRepository.instance.checkAlterAndMigrateAuthorizedUser()) {

View file

@ -40,7 +40,6 @@ public class UserManager implements IUserManager {
private ExecutorService USER_EXECUTOR;
// TODO externalise start of threads
public UserManager(ManagerFactory managerFactory) {
this.managerFactory = managerFactory;
}