1 | |
package org.apache.onami.autobind.configuration; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
import java.util.ArrayList; |
21 | |
import java.util.List; |
22 | |
|
23 | |
import javax.inject.Singleton; |
24 | |
|
25 | |
import org.apache.onami.autobind.annotations.GuiceModule; |
26 | |
import org.apache.onami.configuration.PropertiesURLReader; |
27 | |
|
28 | |
@Singleton |
29 | |
@GuiceModule |
30 | 0 | public class ConfigurationModule |
31 | |
extends org.apache.onami.configuration.ConfigurationModule |
32 | |
{ |
33 | |
|
34 | 0 | protected List<PropertiesURLReader> readers = new ArrayList<PropertiesURLReader>(); |
35 | |
|
36 | |
protected boolean bindSystemProperties; |
37 | |
|
38 | |
protected boolean bindEnvironment; |
39 | |
|
40 | |
|
41 | |
@Override |
42 | |
protected void bindConfigurations() |
43 | |
{ |
44 | |
|
45 | 0 | for(PropertiesURLReader reader : readers){ |
46 | |
try |
47 | |
{ |
48 | 0 | bindProperties( reader.readConfiguration() ); |
49 | |
} |
50 | 0 | catch ( Exception e ) |
51 | |
{ |
52 | 0 | addError( "An error occurred while reading properties from '%s': %s", reader.getUrl(), |
53 | |
e.getMessage() ); |
54 | 0 | } |
55 | |
} |
56 | |
|
57 | 0 | if(bindEnvironment){ |
58 | 0 | super.bindEnvironmentVariables(); |
59 | |
} |
60 | 0 | if(bindSystemProperties){ |
61 | 0 | super.bindSystemProperties(); |
62 | |
} |
63 | 0 | } |
64 | |
|
65 | |
@Override |
66 | |
protected void bindEnvironmentVariables() { |
67 | 0 | bindEnvironment = true; |
68 | 0 | } |
69 | |
|
70 | |
@Override |
71 | |
protected void bindSystemProperties() { |
72 | 0 | bindSystemProperties = true; |
73 | 0 | } |
74 | |
|
75 | |
public void addConfigurationReader(PropertiesURLReader reader){ |
76 | 0 | this.readers.add(reader); |
77 | 0 | } |
78 | |
|
79 | |
} |