refactored ModuleRegistry to singleton system

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-09-12 00:38:28 +02:00
parent e8e215f24c
commit bfe87f53a8
23 changed files with 140 additions and 163 deletions

View File

@@ -22,6 +22,7 @@ import static de.srsoftware.umbrella.core.Constants.FIELD_PRICE_FORMAT;
import static de.srsoftware.umbrella.core.Constants.FIELD_TIME_ID;
import static de.srsoftware.umbrella.core.Constants.FIELD_TYPE;
import static de.srsoftware.umbrella.core.Constants.FIELD_UNIT;
import static de.srsoftware.umbrella.core.ModuleRegistry.*;
import static de.srsoftware.umbrella.core.Paths.*;
import static de.srsoftware.umbrella.core.ResponseCode.HTTP_UNPROCESSABLE;
import static de.srsoftware.umbrella.core.Util.mapValues;
@@ -76,11 +77,12 @@ public class DocumentApi extends BaseHandler implements DocumentService {
private final Configuration config;
private final DocumentDb db;
public DocumentApi(ModuleRegistry registry, Configuration config) throws UmbrellaException {
super(registry);
public DocumentApi(Configuration config) throws UmbrellaException {
super();
this.config = config;
var dbFile = config.get(CONFIG_DATABASE).orElseThrow(() -> missingFieldException(CONFIG_DATABASE));
db = new SqliteDb(connect(dbFile));
ModuleRegistry.add(this);
Optional<String> templates = config.get(CONFIG_TEMPLATES);
if (templates.isEmpty()) throw missingFieldException(CONFIG_TEMPLATES);