/[projects]/CircuitBreaker/src/dk/thoerup/circuitbreaker/notification/AsyncNotifier.java
ViewVC logotype

Contents of /CircuitBreaker/src/dk/thoerup/circuitbreaker/notification/AsyncNotifier.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (show annotations) (download)
Fri Oct 1 11:40:30 2010 UTC (13 years, 8 months ago) by torben
File size: 817 byte(s)
Support for async notifiers (and basic java notifier - needs debugging)
1 package dk.thoerup.circuitbreaker.notification;
2
3 import java.util.concurrent.ExecutorService;
4
5 import dk.thoerup.circuitbreaker.CircuitBreaker;
6
7 public abstract class AsyncNotifier implements Notifier {
8
9 CircuitBreaker cb;
10
11 public AsyncNotifier(CircuitBreaker cb) {
12 this.cb = cb;
13 }
14
15 public final void sendNotification(String breakerName, Event evnt) {
16 ExecutorService exec = cb.getExecutor();
17
18 exec.submit( new AsyncRunnable(breakerName, evnt) );
19 }
20
21 public abstract void sendAsync(String breakerName, Event evnt);
22
23 public class AsyncRunnable implements Runnable {
24 String breakerName;
25 Event evnt;
26
27 public AsyncRunnable(String breakerName, Event evnt) {
28 this.breakerName = breakerName;
29 this.evnt = evnt;
30 }
31
32
33 public void run() {
34 sendAsync(breakerName, evnt);
35 }
36
37
38 }
39
40 }

  ViewVC Help
Powered by ViewVC 1.1.20