Commit 1f6fa0e1 authored by Andre Freyssinet's avatar Andre Freyssinet

Fix compilation issues.

parent 3f53fe85
...@@ -154,6 +154,14 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea ...@@ -154,6 +154,14 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea
logger.log(BasicLevel.DEBUG, "JMSModule.stopLiveConnection()"); logger.log(BasicLevel.DEBUG, "JMSModule.stopLiveConnection()");
} }
// Waits for end of initialization if needed (JORAM-290)
while (getStatus() <= STARTING) {
logger.log(BasicLevel.WARN, "JMSModule.stopLiveConnection: Wait for StartupDaemon");
try {
Thread.sleep(1000L);
} catch (InterruptedException exc) {}
}
if (cnx != null) { if (cnx != null) {
try { try {
cnx.setExceptionListener(null); cnx.setExceptionListener(null);
...@@ -353,11 +361,32 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea ...@@ -353,11 +361,32 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea
return cnx != null && !reconnectionDaemon.isRunning(); return cnx != null && !reconnectionDaemon.isRunning();
} }
private int status = UNKNOWN;
public final static int UNKNOWN = -1;
public final static int STARTING = 0;
public final static int OK = 1;
public final static int FAILING = 2;
public int getStatus() {
if (status <= STARTING)
return status;
else if (isConnectionOpen())
return OK;
else
return FAILING;
}
public String getState() { public String getState() {
if (isConnectionOpen()) { switch (getStatus()) {
case STARTING:
return "STARTING";
case OK:
return "OK"; return "OK";
case FAILING:
return "FAILING";
} }
return "FAILING"; return "UNKNOWN";
} }
private String getMBeanName() { private String getMBeanName() {
...@@ -386,6 +415,7 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea ...@@ -386,6 +415,7 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea
/** The daemon's loop. */ /** The daemon's loop. */
public void run() { public void run() {
status = STARTING;
if (logmon.isLoggable(BasicLevel.DEBUG)) { if (logmon.isLoggable(BasicLevel.DEBUG)) {
logmon.log(BasicLevel.DEBUG, "run()"); logmon.log(BasicLevel.DEBUG, "run()");
} }
...@@ -398,6 +428,7 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea ...@@ -398,6 +428,7 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea
} }
try { try {
doConnect(); doConnect();
status = OK;
if (logmon.isLoggable(BasicLevel.INFO)) { if (logmon.isLoggable(BasicLevel.INFO)) {
logmon.log(BasicLevel.INFO, logmon.log(BasicLevel.INFO,
"StartupDaemon: " + name + " connected using " + cnxFactName + " ConnectionFactory."); "StartupDaemon: " + name + " connected using " + cnxFactName + " ConnectionFactory.");
...@@ -473,6 +504,9 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea ...@@ -473,6 +504,9 @@ public class JMSModule implements ExceptionListener, Serializable, JMSModuleMBea
logmon.log(BasicLevel.DEBUG, "Exception:: notUsableMessage=" + notUsableMessage, exc); logmon.log(BasicLevel.DEBUG, "Exception:: notUsableMessage=" + notUsableMessage, exc);
} }
} finally { } finally {
// Removes the STARTING status if the connection is not established.
if (status != OK)
status = FAILING;
finish(); finish();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment