@@ -1371,12 +1371,33 @@ public static Boolean checkFileExists(final String path) {
1371
1371
*/
1372
1372
public static Properties loadPropertieFile () {
1373
1373
final Properties properties = new Properties ();
1374
+ /* On essaye de lire dans les property du system le fichier de properties */
1374
1375
try {
1375
1376
final String systemFilePropertiesPath = System .getProperty (ConstanteUtils .PROPERTY_FILE_PATH );
1376
- System .out .println ("loadPropertieFile " + systemFilePropertiesPath );
1377
- if (StringUtils .isNotBlank (systemFilePropertiesPath )) {
1378
- final File fileConfig = new File (systemFilePropertiesPath );
1379
- System .out .println ("loadPropertieFile " + fileConfig );
1377
+ readConfigFile (systemFilePropertiesPath , properties );
1378
+ if (!properties .isEmpty ()) {
1379
+ return properties ;
1380
+ }
1381
+ } catch (final Exception e ) {
1382
+ }
1383
+ /* On essaye de lire dans les variables d'env le fichier de properties */
1384
+ try {
1385
+ final String envFilePropertiesPath = System .getenv (ConstanteUtils .PROPERTY_FILE_PATH );
1386
+ readConfigFile (envFilePropertiesPath , properties );
1387
+ } catch (final Exception e ) {
1388
+ }
1389
+ return properties ;
1390
+ }
1391
+
1392
+ /**
1393
+ * Lit un fichier de config
1394
+ * @param path
1395
+ * @param properties
1396
+ */
1397
+ private static void readConfigFile (final String path , final Properties properties ) {
1398
+ try {
1399
+ if (StringUtils .isNotBlank (path )) {
1400
+ final File fileConfig = new File (path );
1380
1401
if (fileConfig .exists () && fileConfig .isFile ()) {
1381
1402
try (FileInputStream file = new FileInputStream (fileConfig )) {
1382
1403
properties .load (file );
@@ -1385,6 +1406,6 @@ public static Properties loadPropertieFile() {
1385
1406
}
1386
1407
} catch (final Exception e ) {
1387
1408
}
1388
- return properties ;
1409
+
1389
1410
}
1390
1411
}
0 commit comments