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; |
35 |
|
|
36 |
|
import info.magnolia.module.cache.executor.Bypass; |
37 |
|
import info.magnolia.module.cache.listeners.AbstractCacheListener; |
38 |
|
import info.magnolia.objectfactory.Components; |
39 |
|
import info.magnolia.repository.RepositoryManager; |
40 |
|
|
41 |
|
import java.util.ArrayList; |
42 |
|
import java.util.HashMap; |
43 |
|
import java.util.List; |
44 |
|
import java.util.Map; |
45 |
|
import java.util.Map.Entry; |
46 |
|
|
47 |
|
import javax.inject.Inject; |
48 |
|
|
49 |
|
import org.slf4j.Logger; |
50 |
|
import org.slf4j.LoggerFactory; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
@see |
58 |
|
@see |
59 |
|
|
|
|
| 58.1% |
Uncovered Elements: 13 (31) |
Complexity: 10 |
Complexity Density: 0.56 |
|
60 |
|
public class ContentCachingConfiguration { |
61 |
|
|
62 |
|
private static final Logger log = LoggerFactory.getLogger(ContentCachingConfiguration.class); |
63 |
|
|
64 |
|
private CacheModule cacheModule; |
65 |
|
private RepositoryManager repositoryManager; |
66 |
|
|
67 |
|
private String name; |
68 |
|
private String cacheName; |
69 |
|
private CachePolicy cachePolicy = new info.magnolia.module.cache.cachepolicy.Never(); |
70 |
|
private FlushPolicy flushPolicy; |
71 |
|
private BrowserCachePolicy browserCachePolicy = new info.magnolia.module.cache.browsercachepolicy.Never(); |
72 |
|
|
73 |
|
private Map<String, CachePolicyExecutor> executors = new HashMap<String, CachePolicyExecutor>(); |
74 |
|
private List<AbstractCacheListener> listeners = new ArrayList<AbstractCacheListener>(); |
75 |
|
|
76 |
|
|
77 |
|
@deprecated@link |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
79 |
0 |
@Deprecated... |
80 |
|
public ContentCachingConfiguration() { |
81 |
0 |
this(Components.getComponent(CacheModule.class), Components.getComponent(RepositoryManager.class)); |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
84 |
72 |
@Inject... |
85 |
|
public ContentCachingConfiguration(CacheModule cacheModule, RepositoryManager repositoryManager) { |
86 |
72 |
this.cacheModule = cacheModule; |
87 |
72 |
this.repositoryManager = repositoryManager; |
88 |
72 |
flushPolicy = new FlushAllListeningPolicy(cacheModule, repositoryManager); |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
94 |
0 |
ContentCachingConfiguration(String name, CachePolicy cachePolicy, FlushPolicy flushPolicy) {... |
95 |
0 |
this.name = name; |
96 |
0 |
this.cachePolicy = cachePolicy; |
97 |
0 |
this.flushPolicy = flushPolicy; |
98 |
|
} |
99 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
100 |
|
public String getName() {... |
101 |
|
return name; |
102 |
|
} |
103 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
104 |
|
public void setName(String name) {... |
105 |
|
this.name = name; |
106 |
|
} |
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
108 |
26 |
public String getCacheName() {... |
109 |
26 |
return cacheName != null ? cacheName : name; |
110 |
|
} |
111 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
112 |
|
public void setCacheName(String cacheName) {... |
113 |
|
this.cacheName = cacheName; |
114 |
|
} |
115 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
116 |
|
public CachePolicy getCachePolicy() {... |
117 |
|
return cachePolicy; |
118 |
|
} |
119 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
120 |
|
public void setCachePolicy(CachePolicy cachePolicy) {... |
121 |
|
this.cachePolicy = cachePolicy; |
122 |
|
} |
123 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
124 |
|
public FlushPolicy getFlushPolicy() {... |
125 |
|
return flushPolicy; |
126 |
|
} |
127 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
128 |
|
public void setFlushPolicy(FlushPolicy flushPolicy) {... |
129 |
|
this.flushPolicy = flushPolicy; |
130 |
|
} |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
132 |
20 |
public CachePolicyExecutor getExecutor(CachePolicyResult.CachePolicyBehaviour behaviour) {... |
133 |
20 |
if (executors.containsKey(behaviour.getName())) { |
134 |
19 |
return executors.get(behaviour.getName()); |
135 |
|
} |
136 |
|
|
137 |
1 |
log.error("Check your cache configuration! Executor " + behaviour.getName() + " is probably not set! Bypassing cache."); |
138 |
1 |
return new Bypass(); |
139 |
|
} |
140 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
141 |
|
public BrowserCachePolicy getBrowserCachePolicy() {... |
142 |
|
return browserCachePolicy; |
143 |
|
} |
144 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
145 |
|
public void setBrowserCachePolicy(BrowserCachePolicy browserCachePolicy) {... |
146 |
|
this.browserCachePolicy = browserCachePolicy; |
147 |
|
} |
148 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
149 |
|
public Map<String, CachePolicyExecutor> getExecutors() {... |
150 |
|
return executors; |
151 |
|
} |
152 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
153 |
|
public void setExecutors(Map<String, CachePolicyExecutor> executors) {... |
154 |
|
for (Entry<String, CachePolicyExecutor> executor : executors.entrySet()) { |
155 |
|
this.addExecutor(executor.getKey(), executor.getValue()); |
156 |
|
} |
157 |
|
} |
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
159 |
74 |
public void addExecutor(String name, CachePolicyExecutor executor) {... |
160 |
74 |
executor.setContentCachingConfiguration(this); |
161 |
74 |
this.executors.put(name, executor); |
162 |
|
} |
163 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
164 |
|
public List<AbstractCacheListener> getListeners() {... |
165 |
|
return listeners; |
166 |
|
} |
167 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
168 |
|
public void setListeners(List<AbstractCacheListener> listeners) {... |
169 |
|
this.listeners = listeners; |
170 |
|
} |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
172 |
0 |
public AbstractCacheListener getListener(String name) {... |
173 |
0 |
for (AbstractCacheListener listener : getListeners()) { |
174 |
0 |
if (name.equals(listener.getName())) { |
175 |
0 |
return listener; |
176 |
|
} |
177 |
|
} |
178 |
0 |
return null; |
179 |
|
} |
180 |
|
|
181 |
|
} |