[jboss-svn-commits] JBL Code SVN: r8066 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Dec 5 10:17:00 EST 2006
Author: tfennelly
Date: 2006-12-05 10:16:58 -0500 (Tue, 05 Dec 2006)
New Revision: 8066
Modified:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/State.java
Log:
More for http://jira.jboss.com/jira/browse/JBESB-256.
All code in place now. Just need to add a few more tests.
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/State.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/State.java 2006-12-05 14:11:19 UTC (rev 8065)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/State.java 2006-12-05 15:16:58 UTC (rev 8066)
@@ -21,17 +21,54 @@
package org.jboss.soa.esb.listeners;
+import org.apache.log4j.Logger;
+
/**
* ESB listener component state.
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public enum State {
- Loading_parameters, Running, Ready, Shutting_down, Done_OK, Exception_thrown;
+ Uninitialised, Loading_parameters, Running, Ready, Shutting_down, Done_OK, Exception_thrown;
+ private static Logger logger = Logger.getLogger(State.class);
+
private int m_iCompletionCode = 0;
- private Exception m_oException = null;
+ private Throwable m_oThrowable = null;
+
+ /**
+ * Block until the state of the supplied listener component transitions to a state of "Ready".
+ */
+ public static void waitUntilReady(Lifecycle owner) {
+ if(owner == null || owner.getState() == null) {
+ throw new IllegalArgumentException("Null or stateless 'owner' arg in method call.");
+ }
+
+ long mark = System.currentTimeMillis();
+ while(owner.getState().isGettingReady()) {
+ if(System.currentTimeMillis() - mark > 2000) {
+ logger.info("Waiting on listener component [" + owner.getClass().getName() + "] to transition to a state of 'Ready'. Current state is '" + owner.getState() + "'.");
+ mark = System.currentTimeMillis();
+ }
+
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ logger.error("Interrupted while waiting for state to transition to 'Ready'.", e);
+ }
+ }
+ logger.info("Listener component [" + owner.getClass().getName() + "] is now in a state of 'Ready'.");
+ }
/**
+ * Is this state instance in one of the states leading up to (but not including) the "Ready" state.
+ * @return True if this state instance in one of the states leading up to (but not including)
+ * the "Ready" state, otherwise false.
+ */
+ private boolean isGettingReady() {
+ return (this.ordinal() < Ready.ordinal());
+ }
+
+ /**
* Get the completion code.
* @return The completion code.
*/
@@ -43,8 +80,8 @@
* Get the exception.
* @return Get the exception.
*/
- public Exception getException() {
- return m_oException;
+ public Throwable getThrowable() {
+ return m_oThrowable;
}
/**
@@ -57,9 +94,9 @@
/**
* Set the exception.
- * @param exception The Exception.
+ * @param thrown The Exception.
*/
- public void setException(Exception exception) {
- m_oException = exception;
+ public void setThrowable(Throwable thrown) {
+ m_oThrowable = thrown;
}
}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list