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.cms.util.DeprecationUtil; |
37 |
|
import info.magnolia.event.EventBus; |
38 |
|
import info.magnolia.event.SystemEventBus; |
39 |
|
import info.magnolia.module.ModuleLifecycleContext; |
40 |
|
import info.magnolia.module.ModuleManager; |
41 |
|
import info.magnolia.module.ModulesStartedEvent; |
42 |
|
import info.magnolia.module.cache.factory.DelegatingCacheFactory; |
43 |
|
import info.magnolia.module.cache.mbean.CacheMonitor; |
44 |
|
import info.magnolia.objectfactory.Components; |
45 |
|
|
46 |
|
import java.util.Collections; |
47 |
|
import java.util.HashMap; |
48 |
|
import java.util.HashSet; |
49 |
|
import java.util.Map; |
50 |
|
import java.util.Set; |
51 |
|
|
52 |
|
import javax.inject.Inject; |
53 |
|
import javax.inject.Named; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
@see |
59 |
|
@see |
60 |
|
|
|
|
| 20% |
Uncovered Elements: 32 (40) |
Complexity: 13 |
Complexity Density: 0.52 |
|
61 |
|
public class CacheModule extends AbstractCacheModule { |
62 |
|
|
63 |
|
private final Set<CacheModuleLifecycleListener> listeners = Collections.synchronizedSet(new HashSet<CacheModuleLifecycleListener>()); |
64 |
|
private CacheFactory cacheFactory = new DelegatingCacheFactory(); |
65 |
|
private Map<String, ContentCachingConfiguration> contentCaching = new HashMap<String, ContentCachingConfiguration>(); |
66 |
|
private ContentCompression compression; |
67 |
|
|
68 |
|
|
69 |
|
@deprecated@link |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
0 |
@Deprecated... |
72 |
|
public CacheModule(CacheMonitor cacheMonitor) { |
73 |
0 |
this(cacheMonitor, Components.getComponentWithAnnotation(EventBus.class, Components.named(SystemEventBus.NAME))); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
76 |
42 |
@Inject... |
77 |
|
public CacheModule(CacheMonitor cacheMonitor, @Named(SystemEventBus.NAME) EventBus systemEventBus) { |
78 |
42 |
super(cacheMonitor); |
79 |
42 |
systemEventBus.addHandler(ModulesStartedEvent.class, new ModulesStartedEvent.Handler() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0 |
@Override... |
81 |
|
public void onModuleStartupCompleted(ModulesStartedEvent event) { |
82 |
0 |
start(); |
83 |
|
} |
84 |
|
}); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
@deprecated@link |
89 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
0 |
@Deprecated... |
91 |
|
public CacheModule(ModuleManager moduleManager, CacheMonitor cacheMonitor) { |
92 |
0 |
this(cacheMonitor); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
@link |
97 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
98 |
|
@Override... |
99 |
|
public CacheFactory getCacheFactory() { |
100 |
|
return cacheFactory; |
101 |
|
} |
102 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
103 |
|
public void setCacheFactory(CacheFactory cacheFactory) {... |
104 |
|
this.cacheFactory = cacheFactory; |
105 |
|
} |
106 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
107 |
|
public Map<String, ContentCachingConfiguration> getContentCaching() {... |
108 |
|
return contentCaching; |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
|
@deprecated@link |
113 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
114 |
0 |
@Deprecated... |
115 |
|
public ContentCachingConfiguration addConfiguration(String name, CacheConfiguration cacheConfiguration) { |
116 |
0 |
DeprecationUtil.isDeprecated("Use info.magnolia.module.cache.CacheModule#setContentCaching instead."); |
117 |
0 |
return contentCaching.put(name, cacheConfiguration); |
118 |
|
} |
119 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
120 |
|
public void setContentCaching(Map<String, ContentCachingConfiguration> contentCaching) {... |
121 |
|
this.contentCaching = contentCaching; |
122 |
|
} |
123 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
124 |
|
public void setCompression(ContentCompression compression) {... |
125 |
|
this.compression = compression; |
126 |
|
} |
127 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
128 |
|
public ContentCompression getCompression() {... |
129 |
|
return compression; |
130 |
|
} |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
132 |
23 |
public void register(CacheModuleLifecycleListener listener) {... |
133 |
23 |
listeners.add(listener); |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
@deprecated@link |
138 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
139 |
0 |
@Deprecated... |
140 |
|
public ContentCachingConfiguration getConfiguration(String name) { |
141 |
0 |
DeprecationUtil.isDeprecated("Use info.magnolia.module.cache.CacheModule#getContentCaching instead."); |
142 |
0 |
return this.getContentCaching(name); |
143 |
|
} |
144 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
145 |
47 |
@Override... |
146 |
|
public ContentCachingConfiguration getContentCaching(String name) { |
147 |
47 |
return this.getContentCaching().get(name) != null ? this.getContentCaching().get(name) : this.getContentCaching().get(DEFAULT_CACHE_CONFIG); |
148 |
|
} |
149 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
150 |
0 |
@Override... |
151 |
|
public void start(ModuleLifecycleContext moduleLifecycleContext) { |
152 |
0 |
cacheFactory.start(ModuleLifecycleContext.PHASE_MODULE_RESTART == moduleLifecycleContext.getPhase()); |
153 |
0 |
this.getCacheMonitor().countStart(); |
154 |
0 |
if (ModuleLifecycleContext.PHASE_MODULE_RESTART == moduleLifecycleContext.getPhase()) { |
155 |
0 |
start(); |
156 |
0 |
for (CacheModuleLifecycleListener listener : listeners) { |
157 |
0 |
listener.onCacheModuleStart(); |
158 |
|
} |
159 |
|
} |
160 |
|
} |
161 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
162 |
0 |
@Override... |
163 |
|
public void stop(ModuleLifecycleContext moduleLifecycleContext) { |
164 |
0 |
this.getCacheMonitor().stop(); |
165 |
0 |
for (ContentCachingConfiguration cfg : contentCaching.values()) { |
166 |
0 |
final String name = cfg.getCacheName(); |
167 |
0 |
this.stopCache(name); |
168 |
|
} |
169 |
0 |
cacheFactory.stop(ModuleLifecycleContext.PHASE_MODULE_RESTART == moduleLifecycleContext.getPhase()); |
170 |
|
} |
171 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
172 |
0 |
private void start() {... |
173 |
|
|
174 |
0 |
for (ContentCachingConfiguration cfg : contentCaching.values()) { |
175 |
0 |
final String name = cfg.getCacheName(); |
176 |
0 |
this.startCache(name); |
177 |
|
} |
178 |
|
} |
179 |
|
} |