* Normally Cayenne applications don't need to access DataSource or any other JDBC
* code directly, however in some unusual conditions it may be needed, and this method
* provides a shortcut to raw JDBC.
*/
public DataSource getDataSource(String dataNodeName) {
DataDomain domain = getDataDomain();
if (dataNodeName != null) {
DataNode node = domain.getNode(dataNodeName);
if (node == null) {
throw new IllegalArgumentException("Unknown DataNode name: "
+ dataNodeName);
}
return node.getDataSource();
}
else {
Collection<DataNode> nodes = domain.getDataNodes();
if (nodes.size() != 1) {
throw new IllegalArgumentException(
"If DataNode name is not specified, DataDomain must have exactly 1 DataNode. Actual node count: "
+ nodes.size());
}