try {
URL resourceURL = new File(path).toURI().toURL();
URLClassLoader urlLoader = new URLClassLoader(new URL[] { resourceURL });
userBundle = ResourceBundle.getBundle(DANDELION_USER_PROPERTIES, Locale.getDefault(), urlLoader,
new UTF8Control());
LOG.debug("User configuration loaded");
}
catch (MalformedURLException e) {
LOG.warn("Wrong path to the externalized bundle", e);
}
catch (MissingResourceException e) {
LOG.info("No *.properties file in {}. Trying to lookup in classpath...", path);
}
}
// No system property is set, retrieves the bundle from the classpath
if (userBundle == null) {
try {
// The user bundle is read using UTF-8
userBundle = ResourceBundle
.getBundle(DANDELION_USER_PROPERTIES, Locale.getDefault(), new UTF8Control());
LOG.debug("User configuration loaded");
}
catch (MissingResourceException e) {
// if no resource bundle is found, try using the context
// classloader
try {
userBundle = ResourceBundle.getBundle("dandelion/" + DANDELION_USER_PROPERTIES,
Locale.getDefault(), Thread.currentThread().getContextClassLoader(), new UTF8Control());
LOG.debug("User configuration loaded");
}
catch (MissingResourceException mre) {
LOG.debug("No custom configuration. Using default one.");
}