refactored ModuleRegistry to singleton system
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -32,7 +32,6 @@ import java.util.function.BiFunction;
|
||||
public class MessageSystem implements PostBox {
|
||||
public static final System.Logger LOG = System.getLogger(MessageSystem.class.getSimpleName());
|
||||
private final Timer timer = new Timer();
|
||||
private final ModuleRegistry registry;
|
||||
|
||||
private record Receiver(User user, de.srsoftware.umbrella.core.model.Message message){}
|
||||
|
||||
@@ -72,7 +71,7 @@ public class MessageSystem implements PostBox {
|
||||
private String debugAddress;
|
||||
private final HashMap<Receiver,List<Exception>> exceptions = new HashMap<>();
|
||||
|
||||
public MessageSystem(ModuleRegistry moduleRegistry, Configuration config) throws UmbrellaException {
|
||||
public MessageSystem(Configuration config) throws UmbrellaException {
|
||||
var dbFile = config.get(CONFIG_DB).orElseThrow(() -> missingConfigException(CONFIG_DB));
|
||||
db = new SqliteMessageDb(connect(dbFile));
|
||||
debugAddress = config.get(DEBUG_ADDREESS).map(Object::toString).orElse(null);
|
||||
@@ -81,7 +80,7 @@ public class MessageSystem implements PostBox {
|
||||
user = config.get(CONFIG_SMTP_USER).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.user not configured!"));
|
||||
pass = config.get(CONFIG_SMTP_PASS).map(Object::toString).orElseThrow(() -> new RuntimeException("umbrella.modules.message.smtp.pass not configured!"));
|
||||
from = user;
|
||||
registry = moduleRegistry.add(this);
|
||||
ModuleRegistry.add(this);
|
||||
new SubmissionTask(8).schedule();
|
||||
new SubmissionTask(10).schedule();
|
||||
new SubmissionTask(12).schedule();
|
||||
@@ -117,7 +116,7 @@ public class MessageSystem implements PostBox {
|
||||
var date = new Date();
|
||||
|
||||
for (var receiver : dueRecipients){
|
||||
BiFunction<String,Map<String,String>,String> translateFunction = (text,fills) -> registry.translator().translate(receiver.language(),text,fills);
|
||||
BiFunction<String,Map<String,String>,String> translateFunction = (text,fills) -> ModuleRegistry.translator().translate(receiver.language(),text,fills);
|
||||
|
||||
var combined = new CombinedMessage("Collected messages",translateFunction);
|
||||
var envelopes = queue.stream().filter(env -> env.isFor(receiver)).toList();
|
||||
|
||||
Reference in New Issue
Block a user