[Minor] log locale and time zone after start

This commit is contained in:
Robert von Burg 2019-06-05 14:46:07 +02:00
parent 48421bc49f
commit 939a510bab
1 changed files with 27 additions and 25 deletions

View File

@ -118,8 +118,8 @@ public class ComponentContainerImpl implements ComponentContainer {
realmName = DEFAULT_REALM; realmName = DEFAULT_REALM;
} else { } else {
String msg = "The User {0} is missing the property {1} and the Realm {2} can not be used as it does not exist!"; String msg = "The User {0} is missing the property {1} and the Realm {2} can not be used as it does not exist!";
throw new StrolchException(MessageFormat.format(msg, certificate.getUsername(), PROP_REALM, throw new StrolchException(
DEFAULT_REALM)); MessageFormat.format(msg, certificate.getUsername(), PROP_REALM, DEFAULT_REALM));
} }
} }
@ -165,8 +165,8 @@ public class ComponentContainerImpl implements ComponentContainer {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Class<StrolchComponent> strolchComponentClass = (Class<StrolchComponent>) implClass; Class<StrolchComponent> strolchComponentClass = (Class<StrolchComponent>) implClass;
Constructor<StrolchComponent> constructor = strolchComponentClass.getConstructor(ComponentContainer.class, Constructor<StrolchComponent> constructor = strolchComponentClass
String.class); .getConstructor(ComponentContainer.class, String.class);
StrolchComponent strolchComponent = constructor.newInstance(this, componentName); StrolchComponent strolchComponent = constructor.newInstance(this, componentName);
strolchComponent.setup(componentConfiguration); strolchComponent.setup(componentConfiguration);
@ -179,8 +179,7 @@ public class ComponentContainerImpl implements ComponentContainer {
msg = MessageFormat.format(msg, componentName, e.getMessage()); msg = MessageFormat.format(msg, componentName, e.getMessage());
throw new StrolchConfigurationException(msg, e); throw new StrolchConfigurationException(msg, e);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SecurityException } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SecurityException | IllegalArgumentException | InvocationTargetException e) {
| IllegalArgumentException | InvocationTargetException e) {
String msg = "Could not load class for component {0} due to: {1}"; //$NON-NLS-1$ String msg = "Could not load class for component {0} due to: {1}"; //$NON-NLS-1$
msg = MessageFormat.format(msg, componentName, e.getMessage()); msg = MessageFormat.format(msg, componentName, e.getMessage());
@ -199,8 +198,8 @@ public class ComponentContainerImpl implements ComponentContainer {
String environment = getEnvironment(); String environment = getEnvironment();
String applicationName = getApplicationName(); String applicationName = getApplicationName();
System.setProperty("user.timezone", getTimezone()); System.setProperty("user.timezone", getTimezone());
logger.info(MessageFormat.format(msg, applicationName, environment, Locale.getDefault(), logger.info(MessageFormat
System.getProperty("user.timezone"))); .format(msg, applicationName, environment, Locale.getDefault(), System.getProperty("user.timezone")));
// set up the container itself // set up the container itself
this.strolchConfiguration = strolchConfiguration; this.strolchConfiguration = strolchConfiguration;
@ -232,8 +231,8 @@ public class ComponentContainerImpl implements ComponentContainer {
long took = System.nanoTime() - start; long took = System.nanoTime() - start;
msg = "{0}:{1} Strolch Container setup with {2} components. Took {3}"; //$NON-NLS-1$ msg = "{0}:{1} Strolch Container setup with {2} components. Took {3}"; //$NON-NLS-1$
logger.info(MessageFormat.format(msg, applicationName, environment, this.componentMap.size(), logger.info(MessageFormat
formatNanoDuration(took))); .format(msg, applicationName, environment, this.componentMap.size(), formatNanoDuration(took)));
} }
public void initialize() { public void initialize() {
@ -254,8 +253,8 @@ public class ComponentContainerImpl implements ComponentContainer {
long took = System.nanoTime() - start; long took = System.nanoTime() - start;
msg = "{0}:{1} All {2} Strolch Components have been initialized. Took {3}"; //$NON-NLS-1$ msg = "{0}:{1} All {2} Strolch Components have been initialized. Took {3}"; //$NON-NLS-1$
logger.info(MessageFormat.format(msg, applicationName, environment, this.controllerMap.size(), logger.info(MessageFormat
formatNanoDuration(took))); .format(msg, applicationName, environment, this.controllerMap.size(), formatNanoDuration(took)));
} }
public void start() { public void start() {
@ -277,18 +276,21 @@ public class ComponentContainerImpl implements ComponentContainer {
msg = "{0}:{1} All {2} Strolch Components started. Took {3}. Strolch is now ready to be used. Have fun =))"; //$NON-NLS-1$ msg = "{0}:{1} All {2} Strolch Components started. Took {3}. Strolch is now ready to be used. Have fun =))"; //$NON-NLS-1$
String tookS = formatNanoDuration(took); String tookS = formatNanoDuration(took);
logger.info(MessageFormat.format(msg, applicationName, environment, this.controllerMap.size(), tookS)); logger.info(MessageFormat.format(msg, applicationName, environment, this.controllerMap.size(), tookS));
logger.info(MessageFormat.format("System: {0}", SystemHelper.asString())); //$NON-NLS-1$ logger.info(MessageFormat.format("System: {0}", SystemHelper.asString()));
logger.info(MessageFormat.format("Memory: {0}", SystemHelper.getMemorySummary())); //$NON-NLS-1$ logger.info(MessageFormat.format("Memory: {0}", SystemHelper.getMemorySummary()));
logger.info(MessageFormat.format("Using locale {0} with timezone {1}",
getAgent().getStrolchConfiguration().getRuntimeConfiguration().getLocale().toLanguageTag(),
getTimezone()));
if (hasComponent(OperationsLog.class)) { if (hasComponent(OperationsLog.class)) {
for (String realmName : getRealmNames()) { for (String realmName : getRealmNames()) {
getComponent(OperationsLog.class).addMessage(new LogMessage(realmName, SYSTEM_USER_AGENT, getComponent(OperationsLog.class).addMessage(new LogMessage(realmName, SYSTEM_USER_AGENT,
Locator.valueOf(AGENT, "strolch-agent", StrolchAgent.getUniqueId()), LogSeverity.Info, Locator.valueOf(AGENT, "strolch-agent", StrolchAgent.getUniqueId()), LogSeverity.Info,
ResourceBundle.getBundle("strolch-agent"), "agent.started") // ResourceBundle.getBundle("strolch-agent"), "agent.started") //
.value("applicationName", applicationName) // .value("applicationName", applicationName) //
.value("environment", environment) // .value("environment", environment) //
.value("components", "" + this.controllerMap.size()) // .value("components", "" + this.controllerMap.size()) //
.value("took", tookS)); .value("took", tookS));
} }
} }
} }
@ -306,9 +308,9 @@ public class ComponentContainerImpl implements ComponentContainer {
getComponent(OperationsLog.class).addMessage(new LogMessage(realmName, SYSTEM_USER_AGENT, getComponent(OperationsLog.class).addMessage(new LogMessage(realmName, SYSTEM_USER_AGENT,
Locator.valueOf(AGENT, "strolch-agent", StrolchAgent.getUniqueId()), LogSeverity.Info, Locator.valueOf(AGENT, "strolch-agent", StrolchAgent.getUniqueId()), LogSeverity.Info,
ResourceBundle.getBundle("strolch-agent"), "agent.stopping") // ResourceBundle.getBundle("strolch-agent"), "agent.stopping") //
.value("applicationName", applicationName) // .value("applicationName", applicationName) //
.value("environment", environment) // .value("environment", environment) //
.value("components", "" + this.controllerMap.size())); .value("components", "" + this.controllerMap.size()));
} }
} }
@ -323,8 +325,8 @@ public class ComponentContainerImpl implements ComponentContainer {
long took = System.nanoTime() - start; long took = System.nanoTime() - start;
msg = "{0}:{1} All {2} Strolch Components have been stopped. Took {3}"; //$NON-NLS-1$ msg = "{0}:{1} All {2} Strolch Components have been stopped. Took {3}"; //$NON-NLS-1$
logger.info(MessageFormat.format(msg, applicationName, environment, this.controllerMap.size(), logger.info(MessageFormat
formatNanoDuration(took))); .format(msg, applicationName, environment, this.controllerMap.size(), formatNanoDuration(took)));
} }
this.state = ComponentState.STOPPED; this.state = ComponentState.STOPPED;
@ -348,8 +350,8 @@ public class ComponentContainerImpl implements ComponentContainer {
long took = System.nanoTime() - start; long took = System.nanoTime() - start;
msg = "{0}:{1} All {2} Strolch Components have been destroyed! Took {3}"; //$NON-NLS-1$ msg = "{0}:{1} All {2} Strolch Components have been destroyed! Took {3}"; //$NON-NLS-1$
logger.info(MessageFormat.format(msg, applicationName, environment, this.controllerMap.size(), logger.info(MessageFormat
formatNanoDuration(took))); .format(msg, applicationName, environment, this.controllerMap.size(), formatNanoDuration(took)));
this.controllerMap.clear(); this.controllerMap.clear();
this.componentMap.clear(); this.componentMap.clear();
} }