final HierarchicalConfiguration globalConfig = new HierarchicalConfiguration(getClass());
if (staticConfig != null)
{
final PropertyFileConfiguration rootProperty = new PropertyFileConfiguration();
rootProperty.load(staticConfig, source);
globalConfig.insertConfiguration(rootProperty);
globalConfig.insertConfiguration(getPackageManager().getPackageConfiguration());
}
if (userConfig != null)
{
final String userConfigStripped;
if (userConfig.charAt(0) == '/')
{
userConfigStripped = userConfig.substring(1);
}
else
{
userConfigStripped = userConfig;
}
try
{
final Enumeration userConfigs = ObjectUtilities.getClassLoader(source).getResources(userConfigStripped);
final ArrayList<PropertyFileConfiguration> configs = new ArrayList<PropertyFileConfiguration>();
while (userConfigs.hasMoreElements())
{
final URL url = (URL) userConfigs.nextElement();
try
{
final PropertyFileConfiguration baseProperty = new PropertyFileConfiguration();
final InputStream in = url.openStream();
try
{
baseProperty.load(in);
}
finally
{
in.close();
}
configs.add(baseProperty);
}
catch (IOException ioe)
{
LOGGER.warn("Failed to load the user configuration at " + url, ioe);
}
}
final PropertyFileConfiguration compressedUserConfig = new PropertyFileConfiguration();
for (int i = configs.size() - 1; i >= 0; i--)
{
final PropertyFileConfiguration baseProperty = configs.get(i);
compressedUserConfig.addAll(baseProperty);
}
globalConfig.insertConfiguration(compressedUserConfig);
}
catch (IOException e)