Updated config mechanism and added config for the server
Additionally fixed a small bug in EnvoyLog and envoy.server.Startup, fixed Receiver not stopping when the server was stopped and added access token authorization for the server config
This commit is contained in:
@ -3,10 +3,8 @@ package envoy.client.data;
|
||||
import static java.util.function.Function.identity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import envoy.data.Config;
|
||||
import envoy.data.ConfigItem;
|
||||
|
||||
/**
|
||||
* Implements a configuration specific to the Envoy Client with default values
|
||||
@ -33,15 +31,13 @@ public class ClientConfig extends Config {
|
||||
}
|
||||
|
||||
private ClientConfig() {
|
||||
items.put("server", new ConfigItem<>("server", "s", identity(), null, true));
|
||||
items.put("port", new ConfigItem<>("port", "p", Integer::parseInt, null, true));
|
||||
items.put("localDB", new ConfigItem<>("localDB", "db", File::new, new File("localDB"), true));
|
||||
items.put("ignoreLocalDB", new ConfigItem<>("ignoreLocalDB", "nodb", Boolean::parseBoolean, false, false));
|
||||
items.put("homeDirectory", new ConfigItem<>("homeDirectory", "h", File::new, new File(System.getProperty("user.home"), ".envoy"), true));
|
||||
items.put("fileLevelBarrier", new ConfigItem<>("fileLevelBarrier", "fb", Level::parse, Level.OFF, true));
|
||||
items.put("consoleLevelBarrier", new ConfigItem<>("consoleLevelBarrier", "cb", Level::parse, Level.OFF, true));
|
||||
items.put("user", new ConfigItem<>("user", "u", identity()));
|
||||
items.put("password", new ConfigItem<>("password", "pw", identity()));
|
||||
super(".envoy");
|
||||
put("server", "s", identity(), true);
|
||||
put("port", "p", Integer::parseInt, true);
|
||||
put("localDB", "db", File::new, true);
|
||||
put("ignoreLocalDB", "nodb", Boolean::parseBoolean);
|
||||
put("user", "u", identity());
|
||||
put("password", "pw", identity());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,25 +62,10 @@ public class ClientConfig extends Config {
|
||||
* @return {@code true} if the local database is to be ignored
|
||||
* @since Envoy Client v0.3-alpha
|
||||
*/
|
||||
public Boolean isIgnoreLocalDB() { return (Boolean) items.get("ignoreLocalDB").get(); }
|
||||
|
||||
/**
|
||||
* @return the directory in which all local files are saves
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public File getHomeDirectory() { return (File) items.get("homeDirectory").get(); }
|
||||
|
||||
/**
|
||||
* @return the minimal {@link Level} to log inside the log file
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public Level getFileLevelBarrier() { return (Level) items.get("fileLevelBarrier").get(); }
|
||||
|
||||
/**
|
||||
* @return the minimal {@link Level} to log inside the console
|
||||
* @since Envoy Client v0.2-alpha
|
||||
*/
|
||||
public Level getConsoleLevelBarrier() { return (Level) items.get("consoleLevelBarrier").get(); }
|
||||
public Boolean isIgnoreLocalDB() {
|
||||
final var ignoreLocalDB = items.get("ignoreLocalDB").get();
|
||||
return ignoreLocalDB != null && (Boolean) ignoreLocalDB;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user name
|
||||
|
Reference in New Issue
Block a user