p.load(url.openStream());
bootstraps.add(p);
}
catch (Exception e1)
{
throw new InitialisationException(e1, this);
}
}
// ... and only then merge and process them
int objectCounter = 1;
int transformerCounter = 1;
Properties transformers = new Properties();
Properties namedObjects = new Properties();
Properties unnamedObjects = new Properties();
for (Properties bootstrap : bootstraps)
{
for (Map.Entry entry : bootstrap.entrySet())
{
final String key = (String) entry.getKey();
if (key.contains(OBJECT_KEY))
{
String newKey = key.substring(0, key.lastIndexOf(".")) + objectCounter++;
unnamedObjects.put(newKey, entry.getValue());
}
else if (key.contains(TRANSFORMER_KEY))
{
String newKey = key.substring(0, key.lastIndexOf(".")) + transformerCounter++;
transformers.put(newKey, entry.getValue());
}
else
{
// we allow arbitrary keys in the registry-bootstrap.properties but since we're
// aggregating multiple files here we must make sure that the keys are unique
// if (accumulatedProps.getProperty(key) != null)
// {
// throw new IllegalStateException(
// "more than one registry-bootstrap.properties file contains a key " + key);
// }
// else
{
namedObjects.put(key, entry.getValue());
}
}
}
}
try
{
registerUnnamedObjects(unnamedObjects, context.getRegistry());
registerTransformers(transformers, context.getRegistry());
registerObjects(namedObjects, context.getRegistry());
}
catch (Exception e1)
{
throw new InitialisationException(e1, this);
}
}