/[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 3212 - (hide annotations) (download)
Thu Dec 28 09:34:47 2017 UTC (6 years, 5 months ago) by torben
File size: 790 byte(s)
Use generics to encapsulate returned value
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 3212 public final void sendNotification(CircuitBreaker<?> breaker, Event evnt) {
12 torben 1161 ExecutorService exec = breaker.getExecutor();
13 torben 1148
14 torben 1161 exec.submit( new AsyncRunnable(breaker, evnt) );
15 torben 1148 }
16    
17 torben 3212 public abstract void sendAsync(CircuitBreaker<?> breaker, Event evnt);
18 torben 1148
19     public class AsyncRunnable implements Runnable {
20 torben 3212 CircuitBreaker<?> breaker;
21 torben 1148 Event evnt;
22    
23 torben 3212 public AsyncRunnable(CircuitBreaker<?> breaker, Event evnt) {
24 torben 1161 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