}
private static void handleConnection(ConfigurationDBAdapter configuration, Node parentNode)
{
DOMElementIterator eventTypeNodeIterator = new DOMElementIterator(parentNode.getChildNodes());
ConfigurationDBRef connection = new ConfigurationDBRef();
String name = getRequiredAttribute(parentNode, "name");
configuration.getJdbcConnections().put(name, connection);
while (eventTypeNodeIterator.hasNext())
{
Element subElement = eventTypeNodeIterator.next();
if (subElement.getNodeName().equals("datasource-connection"))
{
String lookup = subElement.getAttributes().getNamedItem("context-lookup-name").getTextContent();
Properties properties = handleProperties(subElement, "env-property");
connection.setDataSourceConnection(lookup, properties);
}
if (subElement.getNodeName().equals("datasourcefactory-connection"))
{
String className = subElement.getAttributes().getNamedItem("class-name").getTextContent();
Properties properties = handleProperties(subElement, "env-property");
connection.setDataSourceFactory(properties, className);
}
else if (subElement.getNodeName().equals("drivermanager-connection"))
{
String className = subElement.getAttributes().getNamedItem("class-name").getTextContent();
String url = subElement.getAttributes().getNamedItem("url").getTextContent();
String userName = subElement.getAttributes().getNamedItem("user").getTextContent();
String password = subElement.getAttributes().getNamedItem("password").getTextContent();
Properties properties = handleProperties(subElement, "connection-arg");
connection.setDriverManagerConnection(className, url, userName, password, properties);
}
else if (subElement.getNodeName().equals("connection-settings"))
{
if (subElement.getAttributes().getNamedItem("auto-commit") != null)
{
String autoCommit = subElement.getAttributes().getNamedItem("auto-commit").getTextContent();
connection.setConnectionAutoCommit(Boolean.parseBoolean(autoCommit));
}
if (subElement.getAttributes().getNamedItem("transaction-isolation") != null)
{
String transactionIsolation = subElement.getAttributes().getNamedItem("transaction-isolation").getTextContent();
connection.setConnectionTransactionIsolation(Integer.parseInt(transactionIsolation));
}
if (subElement.getAttributes().getNamedItem("catalog") != null)
{
String catalog = subElement.getAttributes().getNamedItem("catalog").getTextContent();
connection.setConnectionCatalog(catalog);
}
if (subElement.getAttributes().getNamedItem("read-only") != null)
{
String readOnly = subElement.getAttributes().getNamedItem("read-only").getTextContent();
connection.setConnectionReadOnly(Boolean.parseBoolean(readOnly));
}
}
}
}