|
@@ -1,11 +1,11 @@ |
1 |
1 |
|
// This Source Code is in the Public Domain per: http://litesoft.org/License.txt |
2 |
2 |
|
package org.litesoft.configuration; |
3 |
3 |
|
|
4 |
|
- |
import org.litesoft.util.*; |
5 |
|
- |
|
6 |
4 |
|
import java.io.*; |
7 |
5 |
|
import java.util.*; |
8 |
6 |
|
|
|
7 |
+ |
import org.litesoft.util.*; |
|
8 |
+ |
|
9 |
9 |
|
public class ConfigAccessorLocator implements ConfigDataAccessorFactory |
10 |
10 |
|
{ |
11 |
11 |
|
public static final String CURRENT_DIR = "."; |
|
@@ -14,26 +14,21 @@ |
14 |
14 |
|
private ConfigAccessorFactory mConfigAccessorFactory; |
15 |
15 |
|
private List<String> mAdditionalSearchPaths = new ArrayList<String>(); |
16 |
16 |
|
|
17 |
|
- |
public ConfigAccessorLocator( String pRelativeConfigFilePath, |
18 |
|
- |
ConfigAccessorFactory pConfigAccessorFactory ) |
|
17 |
+ |
public ConfigAccessorLocator( String pRelativeConfigFilePath, ConfigAccessorFactory pConfigAccessorFactory ) |
19 |
18 |
|
{ |
20 |
19 |
|
mRelativeConfigFilePath = Utils.assertNotNullNotEmpty( "RelativeConfigFilePath", pRelativeConfigFilePath ).replace( '\\', '/' ); |
21 |
20 |
|
Utils.assertNotNull( "ConfigAccessorFactory", mConfigAccessorFactory = pConfigAccessorFactory ); |
22 |
21 |
|
} |
23 |
22 |
|
|
24 |
23 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
25 |
|
- |
public ConfigAccessorLocator( String pRelativeConfigFilePath, |
26 |
|
- |
ConfigAccessorFactory pConfigAccessorFactory, |
27 |
|
- |
String... pAdditionalSearchPaths ) |
|
24 |
+ |
public ConfigAccessorLocator( String pRelativeConfigFilePath, ConfigAccessorFactory pConfigAccessorFactory, String... pAdditionalSearchPaths ) |
28 |
25 |
|
{ |
29 |
26 |
|
this( pRelativeConfigFilePath, pConfigAccessorFactory ); |
30 |
27 |
|
addSearchPaths( pAdditionalSearchPaths ); |
31 |
28 |
|
} |
32 |
29 |
|
|
33 |
30 |
|
@SuppressWarnings({"UnusedDeclaration"}) |
34 |
|
- |
public ConfigAccessorLocator( String pRelativeConfigFilePath, |
35 |
|
- |
ConfigAccessorFactory pConfigAccessorFactory, |
36 |
|
- |
List<String> pAdditionalSearchPaths ) |
|
31 |
+ |
public ConfigAccessorLocator( String pRelativeConfigFilePath, ConfigAccessorFactory pConfigAccessorFactory, List<String> pAdditionalSearchPaths ) |
37 |
32 |
|
{ |
38 |
33 |
|
this( pRelativeConfigFilePath, pConfigAccessorFactory ); |
39 |
34 |
|
addSearchPaths( pAdditionalSearchPaths ); |
|
@@ -137,9 +132,7 @@ |
137 |
132 |
|
|
138 |
133 |
|
private RuntimeException newErrorMessage( String pWhy, Throwable pCause ) |
139 |
134 |
|
{ |
140 |
|
- |
return new IllegalStateException( "Unable to " + pWhy + " '" + mRelativeConfigFilePath + "'," + |
141 |
|
- |
" looked in the following Hierarchies: " + mCheckedForFileAt, |
142 |
|
- |
pCause ); |
|
135 |
+ |
return new IllegalStateException( "Unable to " + pWhy + " '" + mRelativeConfigFilePath + "'," + " looked in the following Hierarchies: " + mCheckedForFileAt, pCause ); |
143 |
136 |
|
} |
144 |
137 |
|
|
145 |
138 |
|
private List<String> mCheckedForFileAt = new ArrayList<String>(); |
|
@@ -193,8 +186,7 @@ |
193 |
186 |
|
} |
194 |
187 |
|
try |
195 |
188 |
|
{ |
196 |
|
- |
ConfigDataAccessor configAccessor = |
197 |
|
- |
mConfigAccessorFactory.create( fileRelativeFrom, mRelativeConfigFilePath, is ); |
|
189 |
+ |
ConfigDataAccessor configAccessor = mConfigAccessorFactory.create( fileRelativeFrom, mRelativeConfigFilePath, is ); |
198 |
190 |
|
System.out.println( "Loaded configuration from: " + fileAt.getAbsolutePath() ); |
199 |
191 |
|
return configAccessor; |
200 |
192 |
|
} |