Index: lams_build/build_base.xml
===================================================================
diff -u -r37286da230b2bacd7f7764d630c639c6b51dcf24 -r713fdb17739e31e966736659f72f01ce087f38d1
--- lams_build/build_base.xml (.../build_base.xml) (revision 37286da230b2bacd7f7764d630c639c6b51dcf24)
+++ lams_build/build_base.xml (.../build_base.xml) (revision 713fdb17739e31e966736659f72f01ce087f38d1)
@@ -53,6 +53,8 @@
+
+
Index: lams_build/conf/j2ee/jboss-deployment-structure.xml
===================================================================
diff -u -r37286da230b2bacd7f7764d630c639c6b51dcf24 -r713fdb17739e31e966736659f72f01ce087f38d1
--- lams_build/conf/j2ee/jboss-deployment-structure.xml (.../jboss-deployment-structure.xml) (revision 37286da230b2bacd7f7764d630c639c6b51dcf24)
+++ lams_build/conf/j2ee/jboss-deployment-structure.xml (.../jboss-deployment-structure.xml) (revision 713fdb17739e31e966736659f72f01ce087f38d1)
@@ -36,6 +36,8 @@
+
+
Index: lams_common/.classpath
===================================================================
diff -u -rde884cf8c730a25d2f2296f7a768d3fd45508c99 -r713fdb17739e31e966736659f72f01ce087f38d1
--- lams_common/.classpath (.../.classpath) (revision de884cf8c730a25d2f2296f7a768d3fd45508c99)
+++ lams_common/.classpath (.../.classpath) (revision 713fdb17739e31e966736659f72f01ce087f38d1)
@@ -44,6 +44,8 @@
+
+
Index: lams_common/src/java/org/lamsfoundation/lams/util/Configuration.java
===================================================================
diff -u -r9bf5a36222c5ac4abf1174554eac951f7eeccd51 -r713fdb17739e31e966736659f72f01ce087f38d1
--- lams_common/src/java/org/lamsfoundation/lams/util/Configuration.java (.../Configuration.java) (revision 9bf5a36222c5ac4abf1174554eac951f7eeccd51)
+++ lams_common/src/java/org/lamsfoundation/lams/util/Configuration.java (.../Configuration.java) (revision 713fdb17739e31e966736659f72f01ce087f38d1)
@@ -23,6 +23,8 @@
package org.lamsfoundation.lams.util;
+import java.io.IOException;
+import java.net.ConnectException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -34,6 +36,9 @@
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.helpers.Operations;
+import org.jboss.dmr.ModelNode;
import org.lamsfoundation.lams.config.ConfigurationItem;
import org.lamsfoundation.lams.config.Registration;
import org.lamsfoundation.lams.config.dao.IConfigurationDAO;
@@ -164,13 +169,7 @@
@Override
public void afterPropertiesSet() {
- if (Configuration.items != null) {
- return;
- }
Configuration.refreshCache();
- if (Configuration.items == null) {
- return;
- }
String refreshCacheIntervalString = Configuration.get(ConfigurationKeys.CONFIGURATION_CACHE_REFRESH_INTERVAL);
Integer refreshCacheInterval = StringUtils.isBlank(refreshCacheIntervalString) ? null
@@ -191,6 +190,37 @@
e);
}
}
+
+ new Thread("LAMSConfigurationServerStateCheckThread") {
+ @Override
+ public void run() {
+ boolean check = true;
+ do {
+ try (ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9990)) {
+ // try every 5 seconds
+ Thread.sleep(5000);
+ // read servedr state
+ ModelNode address = new ModelNode().setEmptyList();
+ ModelNode op = Operations.createReadAttributeOperation(address, "server-state");
+ ModelNode result = client.execute(op);
+ if (Operations.isSuccessfulOutcome(result)) {
+ String state = Operations.readResult(result).asString();
+ if ("running".equalsIgnoreCase(state)) {
+ log.info("Refreshing configuration cache after server start");
+ // refresh and die
+ Configuration.refreshCache();
+ check = false;
+ }
+ }
+ } catch (ConnectException e) {
+ // this exception happens all the time until server starts up
+ } catch (IOException | InterruptedException e) {
+ // something really wrong happenned, die
+ check = false;
+ }
+ } while (check);
+ }
+ }.start();
}
/**