* @return The configuration.
*/
protected Configuration loadConfiguration()
{
final HierarchicalConfiguration globalConfig = new HierarchicalConfiguration(getClass());
final PropertyFileConfiguration rootProperty = new PropertyFileConfiguration();
rootProperty.load("/org/pentaho/reporting/engine/classic/core/classic-engine.properties", ClassicEngineBoot.class); // NON-NLS
globalConfig.insertConfiguration(rootProperty);
globalConfig.insertConfiguration(getPackageManager().getPackageConfiguration());
try
{
final String userConfigStripped = "classic-engine.properties"; // NON-NLS
final Enumeration userConfigs = ObjectUtilities.getClassLoader(ClassicEngineBoot.class).getResources(
userConfigStripped);
final ArrayList configs = new ArrayList();
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); // NON-NLS
}
}
for (int i = configs.size() - 1; i >= 0; i--)
{
final PropertyFileConfiguration baseProperty = (PropertyFileConfiguration) configs.get(i);
globalConfig.insertConfiguration(baseProperty);
}
}
catch (IOException e)
{
logger.warn("Failed to lookup the user configurations.", e); // NON-NLS
}
globalConfig.insertConfiguration(ClassicEngineBoot.configWrapper);
final SystemPropertyConfiguration systemConfig = new SystemPropertyConfiguration();
globalConfig.insertConfiguration(systemConfig);
return globalConfig;
}