--- CircuitBreaker/src/dk/thoerup/circuitbreaker/CircuitBreaker.java 2010/06/20 21:54:53 864 +++ CircuitBreaker/src/dk/thoerup/circuitbreaker/CircuitBreaker.java 2010/06/21 17:16:46 871 @@ -82,26 +82,23 @@ } public void tripBreaker() { - synchronized(this) { - if (currentState != open) { // TODO:Is this conditional necessary ?? - open.trip(); - currentState = open; - - notifier.sendNotification(name, Notifier.Event.BreakerTripped); - } - } + commonTripBreaker(Notifier.Event.BreakerTripped); } //a re-trip should basically do the same as a normal trip, but it is here just to differentiate the two different events public void retripBreaker() { - synchronized(this) { + commonTripBreaker(Notifier.Event.BreakerRetripped); + } + + private void commonTripBreaker(Notifier.Event event) { + synchronized(this) { if (currentState != open) { // TODO:Is this conditional necessary ?? open.trip(); currentState = open; - notifier.sendNotification(name, Notifier.Event.BreakerRetripped); + notifier.sendNotification(name, event); } - } + } } public void attemptReset() {