NodeDescriptor nodeDsc = (NodeDescriptor) allNodes[i];
infos.add(new NodeInfo(nodeDsc));
}
// Build the map of services for each node
Map nodeServices = new HashMap();
// Avoid concurrent modification exception
Object[] allServices = services.values().toArray();
for (int j = 0; j < allServices.length; ++j) {
ServiceEntry e = (ServiceEntry) allServices[j];
Node[] serviceNodes = e.getNodes();
for (int i = 0; i < serviceNodes.length; i++) {
String nodeName = serviceNodes[i].getName();
Vector v = (Vector) nodeServices.get(nodeName);
if (v == null) {
v = new Vector();
nodeServices.put(nodeName, v);
}
Service svc = e.getService();
v.addElement(new ServiceDescriptor(svc.getName(), svc));
}
}
// Now fill the services in the list of NodeInfo
Iterator it = infos.iterator();
while (it.hasNext()) {
NodeInfo ni = (NodeInfo) it.next();
Vector v = (Vector) nodeServices.get(ni.getNodeDescriptor().getName());
ni.setServices(v);
}
return infos;
}