{
final Set connectionSet = new HashHolder();
if (connectionsElement != null)
{
XMLUtil.withFirstChildElement(connectionsElement, "DataSourceConnections", false, new ElementHandler()
{
public void handleElement(Element connectionsElement)
{
XMLUtil.forEachChildElement(connectionsElement, null,
m_helper.new ElementHandler("dataSource")
{
protected String getName(Element element)
{
return XMLUtil.getReqStringAttr(element, "dataSource");
}
public void handleElement(Element connectionElement, String sDataSource)
{
DataSource source = m_metadata.getDataSource(sDataSource);
String sExpectedElement = m_metadata.getDataSourceTypeElement(source.getType()) + "Connection";
if (!sExpectedElement.equals(connectionElement.getNodeName()))
{
throw new MetadataException("err.meta.dataSourceConnectionElement",
new Object[]{connectionElement.getNodeName(), source.getName(),
sConnectionsName, sExpectedElement});
}
if (!connectionSet.add(source))
{
throw new MetadataException("err.meta.dupDataSourceConnection", new Object[]{sDataSource});
}
String sAdapter = XMLUtil.getStringAttr(connectionElement, "adapter");
if (sAdapter != null)
{
source.setAdapter(source.getType().getAdapter(sAdapter));
}
source.setReadLimit(XMLUtil.getIntAttr(connectionElement, "readLimit", source.getReadLimit()));
//Load DataSource-specific attributes.
((XMLPersistenceMetadataLoader)m_helper.getClassInstance(source.getType().getLoader()))
.loadConnection(connectionElement, source, XMLMetadataLoader.this);
}
});
}
});
}
//Call loadConnection to initialize DataSources with no entry in the .connections file.
for (Iterator itr = m_metadata.getDataSourceIterator(); itr.hasNext();)
{
DataSource source = (DataSource)itr.next();
if (!connectionSet.contains(source))
{
int nCookie = getHelper().pushMarker(MetadataValidationException.TYPE_NAME, "DataSourceConnection");
getHelper().pushMarker("dataSourceConnection", source.getName());
try
{
((XMLPersistenceMetadataLoader)m_helper.getClassInstance(source.getType().getLoader()))
.loadConnection(null, source, XMLMetadataLoader.this);
}
catch (MetadataException e)
{
m_helper.addException(e);
}
finally
{
m_helper.restoreMarker(nCookie);
}
}
}
if (connectionsElement != null && !m_bIntegrationExcluded)
{
XMLUtil.withFirstChildElement(connectionsElement, "ChannelConnections", false, new ElementHandler()
{
public void handleElement(Element connectionsElement)
{
XMLUtil.forEachChildElement(connectionsElement, null,
m_helper.new ElementHandler("channel")
{
protected String getName(Element element)
{
return XMLUtil.getReqStringAttr(element, "channel");
}