package dk.thoerup.circuitbreaker.notification; import java.util.concurrent.ExecutorService; import dk.thoerup.circuitbreaker.CircuitBreaker; public abstract class AsyncNotifier implements Notifier { CircuitBreaker cb; public AsyncNotifier(CircuitBreaker cb) { this.cb = cb; } public final void sendNotification(String breakerName, Event evnt) { ExecutorService exec = cb.getExecutor(); exec.submit( new AsyncRunnable(breakerName, evnt) ); } public abstract void sendAsync(String breakerName, Event evnt); public class AsyncRunnable implements Runnable { String breakerName; Event evnt; public AsyncRunnable(String breakerName, Event evnt) { this.breakerName = breakerName; this.evnt = evnt; } public void run() { sendAsync(breakerName, evnt); } } }