throw new LifecycleException(MESSAGES.failToStartManager(), e);
}
Container container = this.getContainer();
if (container instanceof Lifecycle) {
Lifecycle lifecycle = (Lifecycle) container;
LifecycleListener[] listeners = lifecycle.findLifecycleListeners();
// Remove existing listeners
for (LifecycleListener listener : listeners) {
lifecycle.removeLifecycleListener(listener);
}
// Register our listener first
lifecycle.addLifecycleListener(this);
// Re-register the old listeners
for (LifecycleListener listener : listeners) {
lifecycle.addLifecycleListener(listener);
}
}
// Handle re-entrance
if (!this.semaphore.tryAcquire()) {