[jboss-svn-commits] JBL Code SVN: r8453 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/listeners

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Dec 20 14:08:54 EST 2006


Author: estebanschifman
Date: 2006-12-20 14:08:52 -0500 (Wed, 20 Dec 2006)
New Revision: 8453

Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/listeners/DefaultListenerManager.java
Log:
new method:  waitUntilready(millis) - default to 20 seconds

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/listeners/DefaultListenerManager.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/listeners/DefaultListenerManager.java	2006-12-20 17:50:18 UTC (rev 8452)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/internal/soa/esb/listeners/DefaultListenerManager.java	2006-12-20 19:08:52 UTC (rev 8453)
@@ -298,7 +298,12 @@
 						tryToLaunchChildListener(oCurr, sClass);
 					}
 				}
-				waitUntilReady();
+				try { waitUntilReady(); }
+				catch (InterruptedException e) 
+				{
+					_logger.error("Unable to start all child listeners in due time"); 
+					return;
+				}
 			}
 			_status = State.Ready;
 
@@ -675,11 +680,19 @@
 		}
 	} // ____________________________
 
+	//  default maximum is 20 seconds - Use other format if you want otherwise
+	public void waitUntilReady() throws InterruptedException
+	{
+		waitUntilReady(20000);
+	}
+
 	// this method will typically run in the invoker's thread
 	// (which btw might be the same as the run() thread if this not launched in
 	// a separate thread
-	public void waitUntilReady()
+	public void waitUntilReady(long lMax) throws InterruptedException
 	{
+		lMax = (lMax < 100) ? 100 : (lMax > 100000) ? 100000 : lMax;
+		long runUntil = lMax + System.currentTimeMillis();
 		boolean someChildPending = true;
 		
 		do
@@ -704,14 +717,9 @@
 
 			if (someChildPending)
 			{
-				try
-				{
 					Thread.sleep(_pauseTimeMillis);
-				}
-				catch (InterruptedException e)
-				{
-					return;
-				}
+					if (System.currentTimeMillis()>runUntil)
+						throw new InterruptedException();
 			}
 
 		} while (someChildPending);




More information about the jboss-svn-commits mailing list