return buildDaoManager(reader);
}
public DaoManager buildDaoManager(Reader reader)
throws DaoException {
StandardDaoManager daoManager = new StandardDaoManager();
try {
Document doc = getDoc(reader);
Element root = (Element) doc.getLastChild();
String rootname = root.getNodeName();
if (!DAO_CONFIG_ELEMENT.equals(rootname)) {
throw new IOException("Error while configuring DaoManager. The root tag of the DAO configuration XML " +
"document must be '" + DAO_CONFIG_ELEMENT + "'.");
}
NodeList children = root.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
if (CONTEXT_ELEMENT.equals(child.getNodeName())) {
DaoContext daoContext = parseContext((Element) child, daoManager);
daoManager.addContext(daoContext);
} else if (PROPERTIES_ELEMENT.equals(child.getNodeName())) {
Properties attributes = parseAttributes(child);
if (attributes.containsKey("resource")) {
String resource = attributes.getProperty("resource");
if (properties == null) {