added minimal logging
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -14,7 +14,7 @@ object Meta {
|
||||
val COMPONENT_TYPE = "java" // "java" or "versionCatalog"
|
||||
val GROUP = "de.srsoftware"
|
||||
val ARTIFACT_ID = "configuration.json"
|
||||
val VERSION = "1.0.0"
|
||||
val VERSION = "1.0.1"
|
||||
val PUBLISHING_TYPE = "AUTOMATIC" // USER_MANAGED or AUTOMATIC
|
||||
val SHA_ALGORITHMS = listOf("SHA-256", "SHA-512") // sha256 and sha512 are supported but not mandatory. Only sha1 is mandatory but it is supported by default.
|
||||
val DESC = "SRSoftware Configuration: Json-based Implementation"
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
package de.srsoftware.configuration;
|
||||
|
||||
|
||||
import static java.lang.System.Logger;
|
||||
import static java.lang.System.getLogger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
@@ -9,14 +12,14 @@ import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import org.json.JSONObject;
|
||||
|
||||
|
||||
/**
|
||||
* A Configuration implementation, that stores its data in a json file.
|
||||
* Altered json <em>is not automatically saved>/em< after editing!
|
||||
*/
|
||||
public class JsonConfig implements Configuration {
|
||||
private final File file;
|
||||
private final JSONObject json;
|
||||
private static final Logger LOG = getLogger(JsonConfig.class.getSimpleName());
|
||||
private final File file;
|
||||
private final JSONObject json;
|
||||
|
||||
/**
|
||||
* Create a new JsonConfig instance using the passed file for storage
|
||||
@@ -29,6 +32,7 @@ public class JsonConfig implements Configuration {
|
||||
if (!file.exists()) try (var out = new FileWriter(file)) {
|
||||
out.write("{}\n");
|
||||
}
|
||||
LOG.log(Logger.Level.INFO, "Loading json config file from {0}…", file);
|
||||
json = new JSONObject(Files.readString(file.toPath()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user