logger.debug("Adding: " + se.name);
if (logger.isDebugEnabled()) { logger.debug("Adding: " + se.name); }
  public void update(Community community) {    if (logger.isDebugEnabled()) {      logger.debug("update:" +                   " community=" + community.getName() +                   " numEntities=" + community.getEntities().size());    }    if (communityName.equals(community.getName())) {      synchronized (statusMap) {        communityAttrs = community.getAttributes();        try {          Attribute attr = communityAttrs.get(ROBUSTNESS_MANAGER_ATTRIBUTE);          if (attr != null)            setPreferredLeader( (String) attr.get());        } catch (NamingException ne) {}        // Add new members        for (Iterator it = community.getEntities().iterator(); it.hasNext(); ) {          Entity entity = (Entity) it.next();          if (entity instanceof Agent) {            if (!statusMap.containsKey(entity.getName())) {              int type = AGENT;              Attribute entityTypeAttr = entity.getAttributes().get(                  ENTITY_TYPE_ATTRIBUTE);              if (entityTypeAttr != null && entityTypeAttr.contains("Node")) {                type = NODE;              }              StatusEntry se = new StatusEntry(entity.getName(), type,                                               entity.getAttributes());              statusMap.put(se.name, se);              logger.debug("Adding: " + se.name);              queueChangeEvent(                  new CommunityStatusChangeEvent(CommunityStatusChangeEvent.                                                 MEMBERS_ADDED, se));              if (type == NODE) {                for (Iterator iter = nodeChangeListeners.iterator(); iter.hasNext();) {                  NodeChangeListener ncl = (NodeChangeListener)iter.next();                  ncl.addNode(se.name);                }              }            } else {              StatusEntry se = (StatusEntry) statusMap.get(entity.getName());              if (se.attrs == null) {                se.attrs = entity.getAttributes();              }            }          }        }        // Remove members        String entitiesInModel[] = listAllEntries();        for (int i = 0; i < entitiesInModel.length; i++) {          if (!community.hasEntity(entitiesInModel[i])) {            StatusEntry se = (StatusEntry)statusMap.remove(entitiesInModel[i]);            queueChangeEvent(                new CommunityStatusChangeEvent(CommunityStatusChangeEvent.                                               MEMBERS_REMOVED, se));            if(se.type == NODE) {              for(Iterator it = nodeChangeListeners.iterator(); it.hasNext();) {                NodeChangeListener ncl = (NodeChangeListener)it.next();                ncl.removeNode(se.name);              }            }          }        }      }    }  }