+ ninjaMode.name());
// allow application.conf to be reloaded on changes in dev mode
if (NinjaMode.dev == ninjaMode) {
defaultConfiguration
.setReloadingStrategy(new FileChangedReloadingStrategy());
}
} else {
// If the property was set, but the file not found we emit
// a RuntimeException
String errorMessage = String
.format("Error reading configuration file. Make sure you got a default config file %s",
NinjaProperties.CONF_FILE_LOCATION_BY_CONVENTION);
logger.error(errorMessage);
throw new RuntimeException(errorMessage);
}
// third step => load external configuration when a system property is
// defined.
String ninjaExternalConf = System.getProperty(NINJA_EXTERNAL_CONF);
if (ninjaExternalConf != null) {
// only load it when the property is defined.
externalConfiguration = SwissKnife
.loadConfigurationInUtf8(ninjaExternalConf);
// this should not happen:
if (externalConfiguration == null) {
String errorMessage = String
.format("Ninja was told to use an external configuration%n"
+ " %s = %s %n."
+ "But the corresponding file cannot be found.%n"
+ " Make sure it is visible to this application and on the classpath.",
NINJA_EXTERNAL_CONF, ninjaExternalConf);
logger.error(errorMessage);
throw new RuntimeException(errorMessage);
} else {
// allow the external configuration to be reloaded at
// runtime based on detected file changes
final boolean shouldReload = Boolean.getBoolean(NINJA_EXTERNAL_RELOAD);
if (shouldReload) {
externalConfiguration
.setReloadingStrategy(new FileChangedReloadingStrategy());
}
// Copy special prefix of mode to parent configuration
// By convention it will be something like %test.myproperty
prefixedExternalConfiguration = externalConfiguration