Issue #1374 Stop on Failure

This commit is contained in:
Greg Wilkins 2017-03-09 15:56:54 +11:00
parent 9690e064bc
commit 9f9e1ab190
1 changed files with 19 additions and 0 deletions

View File

@ -234,4 +234,23 @@ public abstract class AbstractLifeCycle implements LifeCycle
@Override public void lifeCycleStopped(LifeCycle event) {} @Override public void lifeCycleStopped(LifeCycle event) {}
@Override public void lifeCycleStopping(LifeCycle event) {} @Override public void lifeCycleStopping(LifeCycle event) {}
} }
/**
* A LifeCycle Listener that will call stop if any failures are notified.
*/
public static final LifeCycle.Listener STOP_ON_FAILURE = new AbstractLifeCycleListener()
{
@Override
public void lifeCycleFailure(LifeCycle lifecycle, Throwable cause)
{
try
{
lifecycle.stop();
}
catch(Exception e)
{
cause.addSuppressed(e);
}
}
};
} }