1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.groovy.internal; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collections; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
import javax.inject.Inject; |
27 |
|
import javax.inject.Singleton; |
28 |
|
|
29 |
|
import org.codehaus.groovy.control.customizers.CompilationCustomizer; |
30 |
|
import org.slf4j.Logger; |
31 |
|
import org.xwiki.component.annotation.Component; |
32 |
|
import org.xwiki.component.manager.ComponentManager; |
33 |
|
import org.xwiki.configuration.ConfigurationSource; |
34 |
|
import org.xwiki.groovy.GroovyCompilationCustomizer; |
35 |
|
import org.xwiki.groovy.GroovyConfiguration; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
43 |
|
@Component |
44 |
|
@Singleton |
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 4 |
Complexity Density: 0.4 |
|
45 |
|
public class DefaultGroovyConfiguration implements GroovyConfiguration |
46 |
|
{ |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
private static final String PREFIX = "groovy."; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@Inject |
56 |
|
private ConfigurationSource configuration; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@Inject |
62 |
|
private Logger logger; |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
@Inject |
68 |
|
private ComponentManager componentManager; |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
197 |
@Override... |
71 |
|
public List<String> getCompilationCustomizerNames() |
72 |
|
{ |
73 |
197 |
return this.configuration.getProperty(PREFIX + "compilationCustomizers", Collections.<String>emptyList()); |
74 |
|
} |
75 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
76 |
95 |
@Override... |
77 |
|
public List<CompilationCustomizer> getCompilationCustomizers() |
78 |
|
{ |
79 |
95 |
List<CompilationCustomizer> customizers = new ArrayList<CompilationCustomizer>(); |
80 |
95 |
for (String customizerName : getCompilationCustomizerNames()) { |
81 |
6 |
try { |
82 |
6 |
GroovyCompilationCustomizer customizer = |
83 |
|
this.componentManager.getInstance(GroovyCompilationCustomizer.class, customizerName); |
84 |
6 |
CompilationCustomizer compilationCustomizer = customizer.createCustomizer(); |
85 |
6 |
if (compilationCustomizer != null) { |
86 |
4 |
customizers.add(compilationCustomizer); |
87 |
|
} |
88 |
|
} catch (Exception e) { |
89 |
|
|
90 |
0 |
this.logger.warn("Failed to create the Groovy Compilation Customizer named [{}]", customizerName, e); |
91 |
|
} |
92 |
|
} |
93 |
95 |
return customizers; |
94 |
|
} |
95 |
|
} |