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 COMPONENT_TYPE = "java" // "java" or "versionCatalog"
|
||||||
val GROUP = "de.srsoftware"
|
val GROUP = "de.srsoftware"
|
||||||
val ARTIFACT_ID = "configuration.json"
|
val ARTIFACT_ID = "configuration.json"
|
||||||
val VERSION = "1.0.0"
|
val VERSION = "1.0.1"
|
||||||
val PUBLISHING_TYPE = "AUTOMATIC" // USER_MANAGED or AUTOMATIC
|
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 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"
|
val DESC = "SRSoftware Configuration: Json-based Implementation"
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
package de.srsoftware.configuration;
|
package de.srsoftware.configuration;
|
||||||
|
|
||||||
|
|
||||||
|
import static java.lang.System.Logger;
|
||||||
|
import static java.lang.System.getLogger;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -9,12 +12,12 @@ import java.nio.file.Files;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Configuration implementation, that stores its data in a json file.
|
* A Configuration implementation, that stores its data in a json file.
|
||||||
* Altered json <em>is not automatically saved>/em< after editing!
|
* Altered json <em>is not automatically saved>/em< after editing!
|
||||||
*/
|
*/
|
||||||
public class JsonConfig implements Configuration {
|
public class JsonConfig implements Configuration {
|
||||||
|
private static final Logger LOG = getLogger(JsonConfig.class.getSimpleName());
|
||||||
private final File file;
|
private final File file;
|
||||||
private final JSONObject json;
|
private final JSONObject json;
|
||||||
|
|
||||||
@@ -29,6 +32,7 @@ public class JsonConfig implements Configuration {
|
|||||||
if (!file.exists()) try (var out = new FileWriter(file)) {
|
if (!file.exists()) try (var out = new FileWriter(file)) {
|
||||||
out.write("{}\n");
|
out.write("{}\n");
|
||||||
}
|
}
|
||||||
|
LOG.log(Logger.Level.INFO, "Loading json config file from {0}…", file);
|
||||||
json = new JSONObject(Files.readString(file.toPath()));
|
json = new JSONObject(Files.readString(file.toPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user