*/
public <T extends ConfigBeanProxy> void parseAndSetConfigBean(List<ConfigBeanDefaultValue> values) {
ConfigParser configParser = new ConfigParser(serviceLocator);
// I don't use the GlassFish document here as I don't need persistence
final DomDocument doc = new DomDocument<GlassFishConfigBean>(serviceLocator) {
@Override
public Dom make(final ServiceLocator serviceLocator, XMLStreamReader xmlStreamReader, GlassFishConfigBean dom, ConfigModel configModel) {
return new GlassFishConfigBean(serviceLocator, this, dom, configModel, xmlStreamReader);
}
};
//TODO requires rework to put all the changes that a service may introduce into one transaction
//the solution is to put the loop into the apply method... But it would be some fine amount of work
for (final ConfigBeanDefaultValue configBeanDefaultValue : values) {
final ConfigBeanProxy parent = configModularityUtils.getOwningObject(configBeanDefaultValue.getLocation());
if(parent==null) continue;
ConfigurationPopulator populator = null;
if (replaceSystemProperties)
try {
populator = new ConfigurationPopulator(
configModularityUtils.replacePropertiesWithCurrentValue(
configBeanDefaultValue.getXmlConfiguration(), configBeanDefaultValue)
, doc, parent);
} catch (Exception e) {
LocalStringManager localStrings =
new LocalStringManagerImpl(ConfigurationParser.class);
final String msg = localStrings.getLocalString(
"can.not.add.configuration.to.extension.point",
"Cannot add new configuration extension to the extension point.");
LOG.log(Level.SEVERE, msg, e);
}
else {
//Check that parent is not null!
populator = new ConfigurationPopulator(configBeanDefaultValue.getXmlConfiguration(), doc, parent);
}
populator.run(configParser);
try {
Class configBeanClass = configModularityUtils.getClassForFullName(configBeanDefaultValue.getConfigBeanClassName());
final ConfigBeanProxy pr = doc.getRoot().createProxy(configBeanClass);
ConfigSupport.apply(new SingleConfigCode<ConfigBeanProxy>() {
public Object run(ConfigBeanProxy param) throws PropertyVetoException, TransactionFailure {
boolean writeDefaultElementsToXml = Boolean.parseBoolean(System.getProperty("writeDefaultElementsToXml", "true"));
if (!writeDefaultElementsToXml) {
//Do not write default snippets to domain.xml
doc.getRoot().skipFromXml();
}
configModularityUtils.setConfigBean(pr, configBeanDefaultValue, param);
return param;
}
}, parent);