private void init ( ) { if ( properties != null ) { return ; } LOGGER . info ( "Initializing Configuration" ) ; properties = new Properties ( ) ; final String alpineAppProp = PathUtil . resolve ( System . getProperty ( ALPINE_APP_PROP ) ) ; if ( StringUtils . isNotBlank ( alpineAppProp ) ) { LOGGER . info ( "Loading application properties from " + alpineAppProp ) ; try ( InputStream fileInputStream = Files . newInputStream ( ( new File ( alpineAppProp ) ) . toPath ( ) ) ) { properties . load ( fileInputStream ) ; } catch ( FileNotFoundException e ) { LOGGER . error ( "Could not find property file " + alpineAppProp ) ; } catch ( IOException e ) { LOGGER . error ( "Unable to load " + alpineAppProp ) ; } } else { LOGGER . info ( "System property " + ALPINE_APP_PROP + " not specified" ) ; LOGGER . info ( "Loading " + PROP_FILE + " from classpath" ) ; try ( InputStream in = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( PROP_FILE ) ) { properties . load ( in ) ; } catch ( IOException e ) { LOGGER . error ( "Unable to load " + PROP_FILE ) ; } } if ( properties . size ( ) == 0 ) { LOGGER . error ( "A fatal error occurred loading application properties. Please correct the issue and restart the application." ) ; } alpineVersionProperties = new Properties ( ) ; try ( InputStream in = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( ALPINE_VERSION_PROP_FILE ) ) { alpineVersionProperties . load ( in ) ; } catch ( IOException e ) { LOGGER . error ( "Unable to load " + ALPINE_VERSION_PROP_FILE ) ; } if ( alpineVersionProperties . size ( ) == 0 ) { LOGGER . error ( "A fatal error occurred loading Alpine version information. Please correct the issue and restart the application." ) ; } applicationVersionProperties = new Properties ( ) ; try ( InputStream in = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( APPLICATION_VERSION_PROP_FILE ) ) { applicationVersionProperties . load ( in ) ; } catch ( IOException e ) { LOGGER . error ( "Unable to load " + APPLICATION_VERSION_PROP_FILE ) ; } if ( applicationVersionProperties . size ( ) == 0 ) { LOGGER . error ( "A fatal error occurred loading application version information. Please correct the issue and restart the application." ) ; } }
Initialize the Config object . This method should only be called once .