[jboss-svn-commits] JBL Code SVN: r9348 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/lifecycle.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Feb 5 12:12:02 EST 2007
Author: kevin.conner at jboss.com
Date: 2007-02-05 12:12:02 -0500 (Mon, 05 Feb 2007)
New Revision: 9348
Modified:
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/lifecycle/AbstractManagedLifecycle.java
labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/lifecycle/AbstractThreadedManagedLifecycle.java
Log:
Fix for threaded managed lifecycle race: JBESB-406
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/lifecycle/AbstractManagedLifecycle.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/lifecycle/AbstractManagedLifecycle.java 2007-02-05 14:14:08 UTC (rev 9347)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/lifecycle/AbstractManagedLifecycle.java 2007-02-05 17:12:02 UTC (rev 9348)
@@ -324,26 +324,51 @@
*/
public boolean waitUntilDestroyed(final long transitionPeriod)
{
- return waitForStateChange(ManagedLifecycleState.DESTROYED, transitionPeriod) ;
+ return waitUntilState(ManagedLifecycleState.DESTROYED, transitionPeriod) ;
}
+
/**
* Wait until the managed instance has transitioned into the specified state.
* @param state The expected state.
* @param transitionPeriod The maximum delay expected for the transition, specified in milliseconds.
* @return true if the transition occurs within the expected period, false otherwise.
*/
- protected boolean waitForStateChange(final ManagedLifecycleState state, final long transitionPeriod)
+ protected boolean waitUntilState(final ManagedLifecycleState state, final long transitionPeriod)
{
+ return waitForStateChange(state, transitionPeriod, true) ;
+ }
+
+ /**
+ * Wait until the managed instance is not in the specified state.
+ * @param state The original state.
+ * @param transitionPeriod The maximum delay expected for the transition, specified in milliseconds.
+ * @return true if the transition occurs within the expected period, false otherwise.
+ */
+ protected boolean waitUntilNotState(final ManagedLifecycleState state, final long transitionPeriod)
+ {
+ return waitForStateChange(state, transitionPeriod, false) ;
+ }
+
+
+ /**
+ * Wait until the managed instance has transitioned.
+ * @param state The specified state.
+ * @param transitionPeriod The maximum delay expected for the transition, specified in milliseconds.
+ * @param equality True if the state should be equal to the specified state, false otherwise.
+ * @return true if the transition occurs within the expected period, false otherwise.
+ */
+ private boolean waitForStateChange(final ManagedLifecycleState state, final long transitionPeriod, final boolean equality)
+ {
try
{
stateLock.lock() ;
try
{
- if (this.state != state)
+ if (equality ^ (this.state == state))
{
final long end = System.currentTimeMillis() + transitionPeriod ;
- while(this.state != state)
+ while(equality ^ (this.state == state))
{
final long delay = end - System.currentTimeMillis() ;
if (delay <= 0)
@@ -353,7 +378,7 @@
stateChanged.await(delay, TimeUnit.MILLISECONDS) ;
}
}
- return (this.state == state) ;
+ return !(equality ^ (this.state == state)) ;
}
finally
{
Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/lifecycle/AbstractThreadedManagedLifecycle.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/lifecycle/AbstractThreadedManagedLifecycle.java 2007-02-05 14:14:08 UTC (rev 9347)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/lifecycle/AbstractThreadedManagedLifecycle.java 2007-02-05 17:12:02 UTC (rev 9348)
@@ -108,6 +108,7 @@
*/
public final void run()
{
+ waitUntilNotState(ManagedLifecycleState.STARTING, getTerminationPeriod()) ;
try
{
changeState(ManagedLifecycleState.RUNNING) ;
More information about the jboss-svn-commits
mailing list