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

Annotation of /miscJava/CircuitBreaker/src/main/java/dk/thoerup/circuitbreaker/notification/AsyncNotifier.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2569 - (hide annotations) (download)
Tue Jun 9 08:55:10 2015 UTC (9 years ago) by torben
File size: 778 byte(s)
Statistics should be added by composition instead of inheritance
1 torben 1148 package dk.thoerup.circuitbreaker.notification;
2    
3     import java.util.concurrent.ExecutorService;
4    
5     import dk.thoerup.circuitbreaker.CircuitBreaker;
6 torben 2569 import dk.thoerup.circuitbreaker.Event;
7 torben 1148
8     public abstract class AsyncNotifier implements Notifier {
9    
10    
11 torben 1161 public final void sendNotification(CircuitBreaker breaker, Event evnt) {
12     ExecutorService exec = breaker.getExecutor();
13 torben 1148
14 torben 1161 exec.submit( new AsyncRunnable(breaker, evnt) );
15 torben 1148 }
16    
17 torben 1161 public abstract void sendAsync(CircuitBreaker breaker, Event evnt);
18 torben 1148
19     public class AsyncRunnable implements Runnable {
20 torben 1161 CircuitBreaker breaker;
21 torben 1148 Event evnt;
22    
23 torben 1161 public AsyncRunnable(CircuitBreaker breaker, Event evnt) {
24     this.breaker = breaker;
25 torben 1148 this.evnt = evnt;
26     }
27    
28    
29     public void run() {
30 torben 1161 sendAsync(breaker, evnt);
31 torben 1148 }
32    
33    
34     }
35    
36     }

  ViewVC Help
Powered by ViewVC 1.1.20