View Javadoc
1   package org.apachi.onami.lifecycle.warmup;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import javax.inject.Inject;
23  import javax.inject.Singleton;
24  import org.apache.onami.lifecycle.warmup.WarmUp;
25  
26  public class Dag4
27  {
28      /*
29                      E
30                    <   <
31                  D       \
32                <   <     \
33              B       F   \
34            <             \
35          A               \
36            <             \
37              C  - - - - -
38       */
39  
40      @SuppressWarnings( "UnusedParameters" )
41      @Singleton
42      public static class A
43      {
44          private final Recorder recorder;
45  
46          @Inject
47          public A( Recorder recorder, B b, C c )
48          {
49              this.recorder = recorder;
50          }
51  
52          @WarmUp
53          public void warmUp()
54              throws InterruptedException
55          {
56              recorder.record( "A" );
57          }
58      }
59  
60      @Singleton
61      @SuppressWarnings( "UnusedParameters" )
62      public static class B
63      {
64          private final Recorder recorder;
65  
66          @Inject
67          public B( Recorder recorder, D d )
68          {
69              this.recorder = recorder;
70          }
71  
72          @WarmUp
73          public void warmUp()
74              throws InterruptedException
75          {
76              recorder.record( "B" );
77          }
78      }
79  
80      @Singleton
81      @SuppressWarnings( "UnusedParameters" )
82      public static class C
83      {
84          private final Recorder recorder;
85  
86          @Inject
87          public C( Recorder recorder, E e )
88          {
89              this.recorder = recorder;
90          }
91  
92          @WarmUp
93          public void warmUp()
94              throws InterruptedException
95          {
96              recorder.record( "C" );
97          }
98      }
99  
100     @Singleton
101     @SuppressWarnings( "UnusedParameters" )
102     public static class D
103     {
104         private final Recorder recorder;
105 
106         @Inject
107         public D( Recorder recorder, E e, F f )
108         {
109             this.recorder = recorder;
110         }
111 
112         @WarmUp
113         public void warmUp()
114             throws InterruptedException
115         {
116             recorder.record( "D" );
117         }
118     }
119 
120     @Singleton
121     public static class E
122     {
123         private final Recorder recorder;
124 
125         @Inject
126         public E( Recorder recorder )
127         {
128             this.recorder = recorder;
129         }
130 
131         @WarmUp
132         public void warmUp()
133             throws InterruptedException
134         {
135             recorder.record( "E" );
136         }
137     }
138 
139     @Singleton
140     public static class F
141     {
142         private final Recorder recorder;
143 
144         @Inject
145         public F( Recorder recorder )
146         {
147             this.recorder = recorder;
148         }
149 
150         @WarmUp
151         public void warmUp()
152             throws InterruptedException
153         {
154             recorder.record( "F" );
155         }
156     }
157 }