1 package org.apachi.onami.lifecycle.warmup;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.concurrent.CountDownLatch;
23
24 import javax.inject.Inject;
25 import javax.inject.Singleton;
26 import org.apache.onami.lifecycle.warmup.WarmUp;
27
28 public class Dag1
29 {
30
31
32
33
34
35
36
37
38
39
40 @SuppressWarnings( "UnusedParameters" )
41 @Singleton
42 public static class A
43 {
44 private final Recorder recorder;
45 private final CountDownLatch latch;
46
47 @Inject
48 public A( Recorder recorder, B b, C c, CountDownLatch latch )
49 {
50 this.recorder = recorder;
51 this.latch = latch;
52 }
53
54 @WarmUp
55 public void warmUp()
56 throws InterruptedException
57 {
58 try
59 {
60 recorder.record( "A" );
61 }
62 finally
63 {
64 latch.countDown();
65 }
66 }
67 }
68
69 @Singleton
70 public static class B
71 {
72 private final Recorder recorder;
73 private final CountDownLatch latch;
74
75 @Inject
76 public B( Recorder recorder, CountDownLatch latch )
77 {
78 this.recorder = recorder;
79 this.latch = latch;
80 }
81
82 @WarmUp
83 public void warmUp()
84 throws InterruptedException
85 {
86 try
87 {
88 recorder.record( "B" );
89 }
90 finally
91 {
92 latch.countDown();
93 }
94 }
95 }
96
97 @Singleton
98 public static class C
99 {
100 private final Recorder recorder;
101 private final CountDownLatch latch;
102
103 @Inject
104 public C( Recorder recorder, CountDownLatch latch )
105 {
106 this.recorder = recorder;
107 this.latch = latch;
108 }
109
110 @WarmUp
111 public void warmUp()
112 throws InterruptedException
113 {
114 try
115 {
116 recorder.record( "C" );
117 }
118 finally
119 {
120 latch.countDown();
121 }
122 }
123 }
124 }