protected String resolvePlaceholder ( String property , String defaultValue ) throws IllegalStateException { // "graphite.host" -> "GRAPHITE_HOST" String environmentVariableStyleProperty = property . toUpperCase ( ) ; environmentVariableStyleProperty = environmentVariableStyleProperty . replaceAll ( "\\." , "_" ) ; String result ; if ( externalProperties . containsKey ( property ) ) { result = externalProperties . get ( property ) ; } else if ( System . getProperties ( ) . containsKey ( property ) ) { result = System . getProperty ( property ) ; } else if ( System . getenv ( ) . containsKey ( property ) ) { result = System . getenv ( property ) ; } else if ( System . getenv ( ) . containsKey ( environmentVariableStyleProperty ) ) { result = System . getenv ( environmentVariableStyleProperty ) ; } else if ( defaultValue != null ) { result = defaultValue ; } else { throw new IllegalStateException ( "Property '" + property + "' not found in System properties nor in Environment variables" ) ; } return result ; }
Search for the given placeholder in system properties then in environment variables .