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 public class ConfigurationModule
31 extends org.apache.onami.configuration.ConfigurationModule
32 {
33
34 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 for(PropertiesURLReader reader : readers){
46 try
47 {
48 bindProperties( reader.readConfiguration() );
49 }
50 catch ( Exception e )
51 {
52 addError( "An error occurred while reading properties from '%s': %s", reader.getUrl(),
53 e.getMessage() );
54 }
55 }
56
57 if(bindEnvironment){
58 super.bindEnvironmentVariables();
59 }
60 if(bindSystemProperties){
61 super.bindSystemProperties();
62 }
63 }
64
65 @Override
66 protected void bindEnvironmentVariables() {
67 bindEnvironment = true;
68 }
69
70 @Override
71 protected void bindSystemProperties() {
72 bindSystemProperties = true;
73 }
74
75 public void addConfigurationReader(PropertiesURLReader reader){
76 this.readers.add(reader);
77 }
78
79 }