|
@@ -1,46 +1,46 @@ |
1 |
|
- |
package org.litesoft.initfrom.server; |
2 |
|
- |
|
3 |
|
- |
import org.litesoft.configuration.*; |
4 |
|
- |
|
5 |
|
- |
import java.util.*; |
6 |
|
- |
|
7 |
|
- |
public class InitFrom_Configuration { |
8 |
|
- |
private static final String SYSTEM_PROP_CONFIG_FILE = "CONFIG_FILE"; |
9 |
|
- |
|
10 |
|
- |
private static String makeConfigFileName() { |
11 |
|
- |
String zProperty = System.getProperty( SYSTEM_PROP_CONFIG_FILE ); |
12 |
|
- |
return (zProperty != null) ? zProperty : "InitFrom.properties"; |
13 |
|
- |
} |
14 |
|
- |
|
15 |
|
- |
// Set up the Search Path |
16 |
|
- |
private static List<String> createConfigSearchPath( String... pAdditionalPaths ) { |
17 |
|
- |
List<String> zSearchPath = new ArrayList<String>(); |
18 |
|
- |
|
19 |
|
- |
zSearchPath.add( System.getProperty( "CONFIG_DIR" ) ); |
20 |
|
- |
if ( pAdditionalPaths != null ) { |
21 |
|
- |
for ( String zAdditionalPath : pAdditionalPaths ) { |
22 |
|
- |
if ( zAdditionalPath != null ) { |
23 |
|
- |
zSearchPath.add( zAdditionalPath ); |
24 |
|
- |
} |
25 |
|
- |
} |
26 |
|
- |
} |
27 |
|
- |
zSearchPath.add( System.getenv( "CONFIG_DIR" ) ); |
28 |
|
- |
|
29 |
|
- |
return zSearchPath; |
30 |
|
- |
} |
31 |
|
- |
|
32 |
|
- |
public static synchronized void initialize( String... pAdditionalPaths ) { |
33 |
|
- |
if ( !Configuration.isInstantiated() ) { |
34 |
|
- |
new ServerConfiguration( makeConfigAccessorLocator( pAdditionalPaths ) ); // force creation & self registration |
35 |
|
- |
|
36 |
|
- |
// LoggerFactory.init( new ConfigurationLoggerLevel(), getLoggerProxy() ); |
37 |
|
- |
} |
38 |
|
- |
} |
39 |
|
- |
|
40 |
|
- |
private static ConfigAccessorLocator makeConfigAccessorLocator( String... pAdditionalPaths ) { |
41 |
|
- |
String configFileName = makeConfigFileName(); |
42 |
|
- |
List<String> zSearchPath = createConfigSearchPath( pAdditionalPaths ); |
43 |
|
- |
|
44 |
|
- |
return new ConfigAccessorLocator( configFileName, ConfigAccessorFactoryProperties.INSTANCE, zSearchPath ); |
45 |
|
- |
} |
46 |
|
- |
} |
|
1 |
+ |
package org.litesoft.initfrom.server; |
|
2 |
+ |
|
|
3 |
+ |
import org.litesoft.configuration.*; |
|
4 |
+ |
|
|
5 |
+ |
import java.util.*; |
|
6 |
+ |
|
|
7 |
+ |
public class InitFrom_Configuration { |
|
8 |
+ |
private static final String SYSTEM_PROP_CONFIG_FILE = "CONFIG_FILE"; |
|
9 |
+ |
|
|
10 |
+ |
private static String makeConfigFileName() { |
|
11 |
+ |
String zProperty = System.getProperty( SYSTEM_PROP_CONFIG_FILE ); |
|
12 |
+ |
return (zProperty != null) ? zProperty : "InitFrom.properties"; |
|
13 |
+ |
} |
|
14 |
+ |
|
|
15 |
+ |
// Set up the Search Path |
|
16 |
+ |
private static List<String> createConfigSearchPath( String... pAdditionalPaths ) { |
|
17 |
+ |
List<String> zSearchPath = new ArrayList<String>(); |
|
18 |
+ |
|
|
19 |
+ |
zSearchPath.add( System.getProperty( "CONFIG_DIR" ) ); |
|
20 |
+ |
if ( pAdditionalPaths != null ) { |
|
21 |
+ |
for ( String zAdditionalPath : pAdditionalPaths ) { |
|
22 |
+ |
if ( zAdditionalPath != null ) { |
|
23 |
+ |
zSearchPath.add( zAdditionalPath ); |
|
24 |
+ |
} |
|
25 |
+ |
} |
|
26 |
+ |
} |
|
27 |
+ |
zSearchPath.add( System.getenv( "CONFIG_DIR" ) ); |
|
28 |
+ |
|
|
29 |
+ |
return zSearchPath; |
|
30 |
+ |
} |
|
31 |
+ |
|
|
32 |
+ |
public static synchronized void initialize( String... pAdditionalPaths ) { |
|
33 |
+ |
if ( !Configuration.isInstantiated() ) { |
|
34 |
+ |
new ServerConfiguration( makeConfigAccessorLocator( pAdditionalPaths ) ); // force creation & self registration |
|
35 |
+ |
|
|
36 |
+ |
// LoggerFactory.init( new ConfigurationLoggerLevel(), getLoggerProxy() ); |
|
37 |
+ |
} |
|
38 |
+ |
} |
|
39 |
+ |
|
|
40 |
+ |
private static ConfigAccessorLocator makeConfigAccessorLocator( String... pAdditionalPaths ) { |
|
41 |
+ |
String configFileName = makeConfigFileName(); |
|
42 |
+ |
List<String> zSearchPath = createConfigSearchPath( pAdditionalPaths ); |
|
43 |
+ |
|
|
44 |
+ |
return new ConfigAccessorLocator( configFileName, ConfigAccessorFactoryProperties.INSTANCE, zSearchPath ); |
|
45 |
+ |
} |
|
46 |
+ |
} |