1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.configuration.internal; |
21 |
|
|
22 |
|
import java.net.URL; |
23 |
|
|
24 |
|
import javax.inject.Inject; |
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.apache.commons.configuration.BaseConfiguration; |
29 |
|
import org.apache.commons.configuration.PropertiesConfiguration; |
30 |
|
import org.slf4j.Logger; |
31 |
|
import org.xwiki.component.annotation.Component; |
32 |
|
import org.xwiki.component.phase.Initializable; |
33 |
|
import org.xwiki.component.phase.InitializationException; |
34 |
|
import org.xwiki.environment.Environment; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
42 |
|
@Component |
43 |
|
@Named("xwikiproperties") |
44 |
|
@Singleton |
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 4 |
Complexity Density: 0.44 |
|
45 |
|
public class XWikiPropertiesConfigurationSource extends CommonsConfigurationSource implements Initializable |
46 |
|
{ |
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
private static final String XWIKI_PROPERTIES_FILE = "/WEB-INF/xwiki.properties"; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@Inject |
56 |
|
private Environment environment; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@Inject |
62 |
|
private Logger logger; |
63 |
|
|
|
|
| 92.3% |
Uncovered Elements: 1 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
64 |
61 |
@Override... |
65 |
|
public void initialize() throws InitializationException |
66 |
|
{ |
67 |
|
|
68 |
|
|
69 |
61 |
URL xwikiPropertiesUrl = null; |
70 |
61 |
try { |
71 |
61 |
xwikiPropertiesUrl = this.environment.getResource(XWIKI_PROPERTIES_FILE); |
72 |
61 |
if (xwikiPropertiesUrl != null) { |
73 |
32 |
setConfiguration(new PropertiesConfiguration(xwikiPropertiesUrl)); |
74 |
|
} else { |
75 |
|
|
76 |
|
|
77 |
29 |
this.logger.debug("No configuration file [{}] found. Using default configuration values.", |
78 |
|
XWIKI_PROPERTIES_FILE); |
79 |
|
} |
80 |
|
} catch (Exception e) { |
81 |
|
|
82 |
|
|
83 |
0 |
this.logger.warn("Failed to load configuration file [{}]. Using default configuration values. " |
84 |
|
+ "Internal error [{}]", XWIKI_PROPERTIES_FILE, e.getMessage()); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
61 |
if (xwikiPropertiesUrl == null) { |
90 |
29 |
setConfiguration(new BaseConfiguration()); |
91 |
|
} |
92 |
|
} |
93 |
|
} |