1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.cache.cachepolicy.voters; |
35 |
|
|
36 |
|
import info.magnolia.module.cache.cachepolicy.instructor.CacheInstructor; |
37 |
|
import info.magnolia.module.cache.filter.CacheResponseWrapper; |
38 |
|
import info.magnolia.objectfactory.Components; |
39 |
|
import info.magnolia.voting.voters.BaseVoterImpl; |
40 |
|
|
41 |
|
import javax.inject.Inject; |
42 |
|
import javax.inject.Provider; |
43 |
|
|
44 |
|
|
45 |
|
@link |
46 |
|
|
|
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 5 |
Complexity Density: 1 |
|
47 |
|
public class ServerTtlVoter extends BaseVoterImpl<CacheResponseWrapper> { |
48 |
|
|
49 |
|
private final Provider<CacheInstructor> cacheInstructorProvider; |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
16 |
@Inject... |
52 |
|
public ServerTtlVoter(Provider<CacheInstructor> cacheInstructor) { |
53 |
16 |
this.cacheInstructorProvider = cacheInstructor; |
54 |
|
} |
55 |
|
|
56 |
|
|
57 |
|
@deprecated@link |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0 |
@Deprecated... |
60 |
|
public ServerTtlVoter() { |
61 |
0 |
this(new Provider<CacheInstructor>() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
0 |
@Override... |
63 |
|
public CacheInstructor get() { |
64 |
0 |
return Components.getComponent(CacheInstructor.class); |
65 |
|
} |
66 |
|
}); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
69 |
2 |
@Override... |
70 |
|
public int vote(CacheResponseWrapper cacheResponseWrapper) { |
71 |
2 |
Integer ttl = cacheInstructorProvider.get().getTtl(); |
72 |
2 |
return ttl == null ? Integer.MAX_VALUE : ttl; |
73 |
|
} |
74 |
|
} |