diff --git a/li.strolch.agent/src/main/java/li/strolch/handler/operationslog/LogMessage.java b/li.strolch.agent/src/main/java/li/strolch/handler/operationslog/LogMessage.java index 5293bfac5..1f461608e 100644 --- a/li.strolch.agent/src/main/java/li/strolch/handler/operationslog/LogMessage.java +++ b/li.strolch.agent/src/main/java/li/strolch/handler/operationslog/LogMessage.java @@ -1,5 +1,7 @@ package li.strolch.handler.operationslog; +import java.util.ResourceBundle; + import com.google.gson.JsonObject; import li.strolch.model.Locator; @@ -13,8 +15,8 @@ public class LogMessage extends I18nMessage { private final Locator locator; private final LogSeverity severity; - public LogMessage(String realm, Locator locator, LogSeverity logSeverity, String bundleId, String key) { - super(bundleId, key); + public LogMessage(String realm, Locator locator, LogSeverity logSeverity, ResourceBundle bundle, String key) { + super(bundle, key); this.realm = realm; this.locator = locator; this.severity = logSeverity; diff --git a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java index ea003b3f7..f87f25dd6 100644 --- a/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java +++ b/li.strolch.agent/src/main/java/li/strolch/persistence/api/AbstractTransaction.java @@ -24,6 +24,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import java.util.ResourceBundle; import java.util.Set; import org.slf4j.Logger; @@ -894,7 +895,8 @@ public abstract class AbstractTransaction implements StrolchTransaction { if (this.operationsLog != null) { this.operationsLog.addMessage( new LogMessage(this.realm.getRealm(), Locator.valueOf(AGENT, "tx", StrolchAgent.getUniqueId()), - LogSeverity.EXCEPTION, "strolch-agent", "agent.tx.failed").value("reason", e)); + LogSeverity.EXCEPTION, ResourceBundle.getBundle("strolch-agent"), "agent.tx.failed") + .value("reason", e)); } String msg = "Strolch Transaction for realm {0} failed due to {1}\n{2}"; //$NON-NLS-1$ diff --git a/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java b/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java index ddfeceaa4..4fb3e37a2 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/EventBasedExecutionHandler.java @@ -1,5 +1,6 @@ package li.strolch.execution; +import java.util.ResourceBundle; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -128,7 +129,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler { if (getContainer().hasComponent(OperationsLog.class)) { getComponent(OperationsLog.class).addMessage(new LogMessage(realm, locator, LogSeverity.EXCEPTION, - "strolch-service", "execution.handler.failed.execution").value("reason", e)); + ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.execution") + .value("reason", e)); } } }); @@ -146,7 +148,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler { if (getContainer().hasComponent(OperationsLog.class)) { getComponent(OperationsLog.class).addMessage(new LogMessage(realm, locator, LogSeverity.EXCEPTION, - "strolch-service", "execution.handler.failed.executed").value("reason", e)); + ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.executed") + .value("reason", e)); } } }); @@ -164,7 +167,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler { if (getContainer().hasComponent(OperationsLog.class)) { getComponent(OperationsLog.class).addMessage(new LogMessage(realm, locator, LogSeverity.EXCEPTION, - "strolch-service", "execution.handler.failed.stopped").value("reason", e)); + ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.stopped") + .value("reason", e)); } } }); @@ -182,7 +186,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler { if (getContainer().hasComponent(OperationsLog.class)) { getComponent(OperationsLog.class).addMessage(new LogMessage(realm, locator, LogSeverity.EXCEPTION, - "strolch-service", "execution.handler.failed.error").value("reason", e)); + ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.error") + .value("reason", e)); } } }); @@ -200,7 +205,8 @@ public class EventBasedExecutionHandler extends ExecutionHandler { if (getContainer().hasComponent(OperationsLog.class)) { getComponent(OperationsLog.class).addMessage(new LogMessage(realm, locator, LogSeverity.EXCEPTION, - "strolch-service", "execution.handler.failed.warning").value("reason", e)); + ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.warning") + .value("reason", e)); } } }); @@ -236,8 +242,9 @@ public class EventBasedExecutionHandler extends ExecutionHandler { if (getContainer().hasComponent(OperationsLog.class)) { getComponent(OperationsLog.class) - .addMessage(new LogMessage(realm, activityLoc, LogSeverity.EXCEPTION, "strolch-service", - "execution.handler.failed.archive").value("reason", e)); + .addMessage(new LogMessage(realm, activityLoc, LogSeverity.EXCEPTION, + ResourceBundle.getBundle("strolch-service"), "execution.handler.failed.archive") + .value("reason", e)); } } }); diff --git a/li.strolch.service/src/main/java/li/strolch/execution/policy/SimpleExecution.java b/li.strolch.service/src/main/java/li/strolch/execution/policy/SimpleExecution.java index 99a2cee02..041bb8df4 100644 --- a/li.strolch.service/src/main/java/li/strolch/execution/policy/SimpleExecution.java +++ b/li.strolch.service/src/main/java/li/strolch/execution/policy/SimpleExecution.java @@ -20,10 +20,6 @@ public class SimpleExecution extends ExecutionPolicy { super(container, tx); } - protected void toStarting(Action action) { - setActionState(action, State.STARTING); - } - @Override public void toExecution(Action action) { setActionState(action, State.EXECUTION); diff --git a/li.strolch.service/src/main/java/li/strolch/migrations/Migrations.java b/li.strolch.service/src/main/java/li/strolch/migrations/Migrations.java index a8ec2a9d7..2cd032dcc 100644 --- a/li.strolch.service/src/main/java/li/strolch/migrations/Migrations.java +++ b/li.strolch.service/src/main/java/li/strolch/migrations/Migrations.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.ResourceBundle; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -144,8 +145,8 @@ public class Migrations { List list = migrationsRan.getList(realm); for (Version version : list) { LogMessage logMessage = new LogMessage(realm, locator.append(StrolchAgent.getUniqueId()), - LogSeverity.INFO, "strolch-service", "execution.handler.migrations.version") - .value("version", version.toString()); + LogSeverity.INFO, ResourceBundle.getBundle("strolch-service"), + "execution.handler.migrations.version").value("version", version.toString()); operationsLog.addMessage(logMessage); } } diff --git a/li.strolch.service/src/main/java/li/strolch/migrations/MigrationsHandler.java b/li.strolch.service/src/main/java/li/strolch/migrations/MigrationsHandler.java index 8993a94b9..ce9568448 100644 --- a/li.strolch.service/src/main/java/li/strolch/migrations/MigrationsHandler.java +++ b/li.strolch.service/src/main/java/li/strolch/migrations/MigrationsHandler.java @@ -17,6 +17,7 @@ package li.strolch.migrations; import java.io.File; import java.util.Map; +import java.util.ResourceBundle; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.TimeUnit; @@ -202,8 +203,8 @@ public class MigrationsHandler extends StrolchComponent { if (getContainer().hasComponent(OperationsLog.class)) { getComponent(OperationsLog.class) .addMessage(new LogMessage(Tags.AGENT, getLocator().append(StrolchAgent.getUniqueId()), - LogSeverity.EXCEPTION, "strolch-service", "execution.handler.failed.executed") - .value("reason", e)); + LogSeverity.EXCEPTION, ResourceBundle.getBundle("strolch-service"), + "execution.handler.failed.executed").value("reason", e)); } } } diff --git a/li.strolch.utils/src/main/java/li/strolch/utils/I18nMessage.java b/li.strolch.utils/src/main/java/li/strolch/utils/I18nMessage.java index 50aed5aa9..feeb62532 100644 --- a/li.strolch.utils/src/main/java/li/strolch/utils/I18nMessage.java +++ b/li.strolch.utils/src/main/java/li/strolch/utils/I18nMessage.java @@ -10,22 +10,18 @@ import li.strolch.utils.helper.StringHelper; public class I18nMessage { - private String bundleId; + private ResourceBundle bundle; private String key; private Properties values; - public I18nMessage(String bundleId, String key) { - DBC.INTERIM.assertNotEmpty("bundleId must be set!", bundleId); + public I18nMessage(ResourceBundle bundle, String key) { + DBC.INTERIM.assertNotNull("bundle must be set!", bundle); DBC.INTERIM.assertNotEmpty("key must be set!", key); - this.bundleId = bundleId; + this.bundle = bundle; this.key = key; this.values = new Properties(); } - public String getBundleId() { - return this.bundleId; - } - public String getKey() { return this.key; } @@ -42,8 +38,7 @@ public class I18nMessage { } public String formatMessage() { - ResourceBundle bundle = ResourceBundle.getBundle(this.bundleId); - String string = bundle.getString(this.key); + String string = this.bundle.getString(this.key); return StringHelper.replacePropertiesIn(this.values, EMPTY, string); } }