return;
}
File serviceXml = new File(metaInf, "services-tools.xml");
try {
if (serviceXml.exists()) {
XMLReader reader = new XMLReader(metaInf + File.separator +
"services-tools.xml");
Element root;
if (reader != null) {
root = reader.getRootNode();
// First, parse the services.
NodeList serviceNodes = reader.getNodes("service", root);
for (int i = 0; i < serviceNodes.getLength(); i++) {
Node serviceNode = serviceNodes.item(i);
if (serviceNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element se = (Element) serviceNode;
String id = null;
NamedNodeMap attrList = serviceNode.getAttributes();
for (int j = 0; j < attrList.getLength(); j++) {
if (attrList.item(j).getNodeType() ==
Node.ATTRIBUTE_NODE) {
if (attrList.item(j).getNodeName().equals("id")) {
id = attrList.item(j).getNodeValue();
}
}
}
NodeList classNodes = serviceNode.getChildNodes();
String loadableClass = null;
for (int k = 0; k < classNodes.getLength(); k++) {
if (classNodes.item(k).getNodeType() ==
Node.ELEMENT_NODE) {
loadableClass = reader.getValue("class", se);
}
}
if (id != null && loadableClass != null) {
if (serviceMap.containsKey(id)) {
logger.log(Level.WARNING,
"Ignoring duplicate service " + id +
" in " + type + File.separator + dir);
} else {
ServiceDescription desc =
new ServiceDescription(id,
loadableClass, type, dir);
serviceMap.put(id, desc);
}
}
}
// Then parse the tools.
NodeList toolNodes = reader.getNodes("tool", root);
for (int i = 0; i < toolNodes.getLength(); i++) {
String id = null;
String serviceName = null;
String toolClass = null;
Node toolNode = toolNodes.item(i);
if (toolNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
Element te = (Element) toolNode;
NamedNodeMap attrList = toolNode.getAttributes();
for (int j = 0; j < attrList.getLength(); j++) {
if (attrList.item(j).getNodeType() ==
Node.ATTRIBUTE_NODE) {
if (attrList.item(j).getNodeName().equals("id")) {
id = attrList.item(j).getNodeValue();
}
if (attrList.item(j).getNodeName().
equals("service")) {
serviceName = attrList.item(j).getNodeValue();
}
}
}
NodeList classNodes = toolNode.getChildNodes();
for (int k = 0; k < classNodes.getLength(); k++) {
if (classNodes.item(k).getNodeType() ==
Node.ELEMENT_NODE) {
toolClass = reader.getValue("class", te);
}
}
if (id != null) {
String key = id;