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 Dag3
27  {
28      /*
29          Mix of classes with/without warmups and
30          dependencies that cross tiers
31  
32  
33                    C
34                  <      >
35              BnW
36            <
37          A       ==>       D
38            <
39              B
40                  <      >
41                    CnW
42       */
43  
44      @SuppressWarnings( "UnusedParameters" )
45      @Singleton
46      public static class A
47      {
48          private final Recorder recorder;
49  
50          @Inject
51          public A( Recorder recorder, BnW bnw, B b, D d )
52          {
53              this.recorder = recorder;
54          }
55  
56          @WarmUp
57          public void warmUp()
58              throws InterruptedException
59          {
60              recorder.record( "A" );
61          }
62      }
63  
64      @SuppressWarnings( "UnusedParameters" )
65      @Singleton
66      public static class B
67      {
68          private final Recorder recorder;
69  
70          @Inject
71          public B( Recorder recorder, CnW cnw )
72          {
73              this.recorder = recorder;
74          }
75  
76          @WarmUp
77          public void warmUp()
78              throws InterruptedException
79          {
80              recorder.record( "B" );
81          }
82      }
83  
84      @SuppressWarnings( "UnusedParameters" )
85      @Singleton
86      public static class BnW
87      {
88          @Inject
89          public BnW( C c )
90          {
91          }
92      }
93  
94      @SuppressWarnings( "UnusedParameters" )
95      @Singleton
96      public static class C
97      {
98          private final Recorder recorder;
99  
100         @Inject
101         public C( Recorder recorder, D d )
102         {
103             this.recorder = recorder;
104         }
105 
106         @WarmUp
107         public void warmUp()
108             throws InterruptedException
109         {
110             recorder.record( "C" );
111         }
112     }
113 
114     @SuppressWarnings( "UnusedParameters" )
115     @Singleton
116     public static class CnW
117     {
118         @Inject
119         public CnW( D d )
120         {
121         }
122     }
123 
124     @Singleton
125     public static class D
126     {
127         private final Recorder recorder;
128 
129         @Inject
130         public D( Recorder recorder )
131         {
132             this.recorder = recorder;
133         }
134 
135         @WarmUp
136         public void warmUp()
137             throws InterruptedException
138         {
139             recorder.record( "D" );
140         }
141     }
142 }