use of alma.ACS.MasterComponentReadOnly in project ACS by ACS-Community.
the class MastercompBundle method checkCurrentMasterComponents.
private void checkCurrentMasterComponents() throws Exception {
Map aliveMasterComps = new HashMap();
try {
String[] curls = getContainerServices().findComponents(null, "IDL:alma/ACS/MasterComponent:1.0");
for (int i = 0; i < curls.length; i++) {
String curl = curls[i];
MastercompBundle bundle = new MastercompBundle();
if (!mastercompNameToObject.containsKey(curl)) {
// new mastercomponent found
org.omg.CORBA.Object compObj = getContainerServices().getComponent(curl);
MasterComponentReadOnly mcomp = alma.ACS.MasterComponentReadOnlyHelper.narrow(compObj);
StateChangeListener listener = attachListener(mcomp);
System.out.println("found new mastercomponent '" + curl + "'.");
bundle.masterComp = mcomp;
bundle.stateChangeListener = listener;
aliveMasterComps.put(curl, bundle);
} else {
// got one we had already
bundle = (MastercompBundle) mastercompNameToObject.get(curl);
aliveMasterComps.put(curl, bundle);
// remove from old map so that we learn about dead components
mastercompNameToObject.remove(curl);
}
}
} catch (Exception e) {
m_logger.log(Level.WARNING, "exception occured while updating list of master components: ", e);
throw e;
}
// deal with dead components
for (Iterator iter = mastercompNameToObject.keySet().iterator(); iter.hasNext(); ) {
String deadCurl = (String) iter.next();
m_logger.info("master component '" + deadCurl + "' no longer there.");
MastercompBundle deadBundle = (MastercompBundle) mastercompNameToObject.get(deadCurl);
deadBundle.stateChangeListener.destroyMonitor();
}
// only discard old map when all was cleaned up well
mastercompNameToObject = aliveMasterComps;
}
Aggregations