{
try
{
// Try loading configuration from JCR first
ChromatticSession session = persister.getSession();
ProducerConfigurationMapping pcm = session.findByPath(ProducerConfigurationMapping.class, PRODUCER_CONFIGURATION_PATH);
// if we don't have a configuration persisted in JCR already, force a reload from XML and save the resulting configuration
if (pcm == null)
{
pcm = session.insert(ProducerConfigurationMapping.class, PRODUCER_CONFIGURATION_PATH);
ProducerConfigurationService service = new SimpleXMLProducerConfigurationService(defaultConfigurationIS);
service.reloadConfiguration();
configuration.set(service.getConfiguration());
pcm.initFrom(configuration.get());
persister.save();
}
else
{
configuration.set(pcm.toModel(null, this));
}
}
finally
{
persister.closeSession(false);