public static < C extends Configurable > C getConfiguration ( Class < C > klass ) { String defaultPropertyFile = "datumbox." + klass . getSimpleName ( ) . toLowerCase ( Locale . ENGLISH ) + DEFAULT_POSTFIX + ".properties" ; Properties properties = new Properties ( ) ; ClassLoader cl = klass . getClassLoader ( ) ; //Load default properties from jar try ( InputStream in = cl . getResourceAsStream ( defaultPropertyFile ) ) { properties . load ( in ) ; } catch ( IOException ex ) { throw new UncheckedIOException ( ex ) ; } //Look for user defined properties String propertyFile = defaultPropertyFile . replaceFirst ( DEFAULT_POSTFIX , "" ) ; if ( cl . getResource ( propertyFile ) != null ) { //Override the default if they exist try ( InputStream in = cl . getResourceAsStream ( propertyFile ) ) { properties . load ( in ) ; } catch ( IOException ex ) { throw new UncheckedIOException ( ex ) ; } logger . trace ( "Loading properties file {}: {}" , propertyFile , properties ) ; } else { logger . warn ( "Using default properties file {}: {}" , defaultPropertyFile , properties ) ; } return getConfiguration ( klass , properties ) ; }
Initializes the Configuration Object based on the configuration file .