queueChangeEvent(new AssetChangeEvent( agentAsset, AssetChangeEvent.REMOVED_ASSET));
queueChangeEvent(new AssetChangeEvent( agentAsset, REMOVED_ASSET));
	    public void statusChanged(CommunityStatusChangeEvent[] csce) {				AssetTechSpecInterface hostAsset;		AssetTechSpecInterface nodeAsset;		AssetTechSpecInterface agentAsset;		String agentName = null;		String nodeName = null;		String hostName = null;				boolean newAgent;		boolean movingAgent;		boolean removedAsset;				//Look at the events for new agent assets		for (int i = 0; i < csce.length; i++) {		    		    newAgent = false;		    movingAgent = false;		    removedAsset = false;		    if (logger.isDebugEnabled()) logger.debug("!!!! [STATUS CHANGED CALLED] on asset="+csce[i].getName()+" with:  \n= "+csce[i].toString()+"  getCurrentLocation = " + csce[i].getCurrentLocation()+" getPriorLocation = " + csce[i].getPriorLocation());                /*                logger.warn("!!!! ****************************************************");logger.warn("!!!! [STATUS CHANGED CALLED] asset = "+csce[i].getName());if (csce[i].locationChanged())    logger.warn("!!!! location changed");if (csce[i].membersAdded())    logger.warn("!!!! membersAdded");if (csce[i].leaderChanged())    logger.warn("!!!! leaderChanged");if (csce[i].membersRemoved())    logger.warn("!!!! membersRemoved");if (csce[i].stateChanged())    logger.warn("!!!! stateChanged");if (csce[i].stateExpired())    logger.warn("!!!! stateExpired");logger.warn("!!!! getCurrentLocation = " + csce[i].getCurrentLocation());logger.warn("!!!! getPriorLocation = " + csce[i].getPriorLocation());logger.warn("!!!! **********************************************************");*/ 		    // Is this a new agent? 		    if ( (csce[i].membersAdded() && csce[i].getCurrentLocation() != null) ||			 (csce[i].locationChanged() && csce[i].getPriorLocation() == null) )  {			newAgent = true;            		if (logger.isDebugEnabled()) 			    logger.debug("newAgent on asset="+csce[i].getName()+					 " with "+csce[i].toString()+					 " getCurrentLocation="+ csce[i].getCurrentLocation()+					 " getPriorLocation="+csce[i].getPriorLocation());		    } else if (csce[i].locationChanged() && csce[i].getPriorLocation() != null) {			movingAgent = true;            		if (logger.isDebugEnabled()) 			    logger.debug("movingAgent on asset="+csce[i].getName()+					 " with "+csce[i].toString()+					 " getCurrentLocation = " + csce[i].getCurrentLocation()+					 " getPriorLocation = " + csce[i].getPriorLocation());		    } else if (csce[i].membersRemoved()) {			removedAsset = true;            		if (logger.isDebugEnabled()) 			    logger.debug("removedAgent on asset="+csce[i].getName()+					 " with "+csce[i].toString()+					 " getCurrentLocation="+csce[i].getCurrentLocation()+					 " getPriorLocation="+csce[i].getPriorLocation());		    }		    agentName = csce[i].getName();		    //***********************************************************************		    //******** Ignore if not a new agent or moving agent -- for NOW *********		    //***********************************************************************		    //Later could monitor other changes in an agent / node.		    if ( newAgent || movingAgent ) {			if ( csce[i].getType() == CommunityStatusModel.AGENT ) {			    nodeName = csce[i].getCurrentLocation();			    hostName = csm.getLocation(nodeName);                        //node & node agent have the same name			} else if ( csce[i].getType() == CommunityStatusModel.NODE ) { 			    nodeName = agentName;			    hostName = csce[i].getCurrentLocation();			}			if (hostName == null || 			    nodeName == null || 			    hostName.length() == 0 || 			    nodeName.length() == 0) {			    if (logger.isDebugEnabled()) 				logger.debug("!!!- Queued new agent asset ["+agentName+"]"+					     " without host/node info: hostName="+hostName+					     " nodeName="+nodeName);			    pendingAssets.add(csce[i]);			    continue;			} else { //continue			    hostAsset = getHost(hostName);			    nodeAsset = getNode(hostAsset, nodeName);			}						//*** Handle a new agent			if ( newAgent )  {			    			    //Make sure we haven't seen this agent before we create a new one!			    agentAsset = assetSvc.getAssetTechSpec(new AssetID(agentName, AssetType.AGENT));			    if (agentAsset != null) {				if (logger.isDebugEnabled()) 				    logger.debug("Saw DUPLICATE agent asset ["+agentName+						 "] with host/node info: hostName = "+hostName + 						 "  nodeName = "+nodeName);				continue;			    }                    			    if (logger.isDebugEnabled()) 				logger.debug("Saw new agent asset ["+agentName+					     "] with host/node info: hostName = "+hostName + 					     "  nodeName = "+nodeName);			    agentAsset = new DefaultAssetTechSpec( hostAsset, nodeAsset,  agentName, 								   AssetType.AGENT, us.nextUID());			    assetSvc.putAssetTechSpec(agentAsset);/*			    //Use NODE name to assign FWD / REAR property -- doing this also for nodes in getNode()			    if (nodeName.startsWith("REAR")) {				agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "REAR"));			    } else if (nodeName.startsWith("FWD")) {				agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "FORWARD"));			    }*/			    queueChangeEvent(new AssetChangeEvent( agentAsset, AssetChangeEvent.NEW_ASSET));			                            //*** Handle an agent moving			} else if (movingAgent) { //it's a movingAgent			    			    logger.info("Agent location changed: agent=" + agentName +					" priorLocation=" + csce[i].getPriorLocation() +					" newLocation=" + csce[i].getCurrentLocation());			    			    agentAsset = assetSvc.getAssetTechSpec(new AssetID(agentName, AssetType.AGENT));			    if (agentAsset == null) { // then this is an agent we've never seen before!				agentAsset = new DefaultAssetTechSpec( hostAsset, nodeAsset,  agentName, AssetType.AGENT, us.nextUID());                            				assetSvc.putAssetTechSpec(agentAsset);			    }			    agentAsset.setNewLocation(hostAsset, nodeAsset);			    queueChangeEvent(new AssetChangeEvent( agentAsset, AssetChangeEvent.MOVED_ASSET));/*			    			    //Use NODE name to assign FWD / REAR property			    if (nodeName.startsWith("REAR")) {				agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "REAR"));			    } else if (nodeName.startsWith("FWD")) {				agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "FWD"));			    }*/			    			    //*** Handle an agent that has been removed			} 					    } else if (removedAsset) { //it's a removedAsset                                                //if it's a node agent, remove the node asset.			                        if (csce[i].getType() == CommunityStatusModel.AGENT) {                            logger.info("Agent REMOVED: agent=" + agentName);                                                    agentAsset = assetSvc.getAssetTechSpec(new AssetID(agentName, AssetType.AGENT));                            if (agentAsset != null) {                                queueChangeEvent(new AssetChangeEvent( agentAsset, AssetChangeEvent.REMOVED_ASSET));                                                                            }                        } else if (csce[i].getType() == CommunityStatusModel.NODE) {                            //then we must remove both the node asset and the node-agent asset                            logger.info("NODE AND NODE-AGENT REMOVED: node=" + agentName);                                                    nodeAsset = assetSvc.getAssetTechSpec(new AssetID(agentName, AssetType.NODE));                            if (nodeAsset != null) {                                queueChangeEvent(new AssetChangeEvent( nodeAsset, AssetChangeEvent.REMOVED_ASSET));                                                                            }                            agentAsset = assetSvc.getAssetTechSpec(new AssetID(agentName, AssetType.AGENT));                            if (agentAsset != null) {                                queueChangeEvent(new AssetChangeEvent( agentAsset, AssetChangeEvent.REMOVED_ASSET));                                                                            }                        }                                                                } else {                   // logger.debug("!!!! [STATUS CHANGED CALLED] - UNKNOWN change");                }            }            // dw - check if any of the agents for which there was previously incomplete info can now be completed            Iterator iter = pendingAssets.iterator();            while (iter.hasNext()) {                CommunityStatusChangeEvent thisCSCE = (CommunityStatusChangeEvent) iter.next();                agentName = thisCSCE.getName();                if (logger.isDebugEnabled()) logger.debug("Considering the pending CSCE: " + thisCSCE.toString());                // this is basically a clone of the handling of the original handling - really should be merged                if ( thisCSCE.getType() == CommunityStatusModel.AGENT ) {                    nodeName = thisCSCE.getCurrentLocation();                    hostName = csm.getLocation(nodeName);                }                else if ( thisCSCE.getType() == CommunityStatusModel.NODE ) { //node & node agent have the same name                    nodeName = agentName;                    hostName = thisCSCE.getCurrentLocation();                }                if (hostName == null || nodeName == null || hostName.length() == 0 || nodeName.length() == 0) {                    if (logger.isDebugEnabled()) logger.debug("!!!- Still incomplete: "+agentName+"] without host/node info: hostName = "+hostName + "  nodeName = "+nodeName);                    continue;                } else { //continue                    hostAsset = getHost(hostName);                    nodeAsset = getNode(hostAsset, nodeName);                }                //*** Handle an agent whose info is now complete - it becomes a new agent entry                //Make sure we haven't seen this agent before we create a new one! - this should be impossible when handling pending requests                agentAsset = assetSvc.getAssetTechSpec(new AssetID(agentName, AssetType.AGENT));                if (agentAsset != null) {                    if (logger.isDebugEnabled()) logger.debug("Saw DUPLICATE agent asset ["+agentName+"] with host/node info: hostName = "+hostName + "  nodeName = "+nodeName);                    continue;                }                                    if (logger.isDebugEnabled()) logger.debug("Saw new agent asset from pending queue ["+agentName+"] with host/node info: hostName = "+hostName + "  nodeName = "+nodeName);                agentAsset = new DefaultAssetTechSpec( hostAsset, nodeAsset,  agentName, AssetType.AGENT, us.nextUID());		assetSvc.putAssetTechSpec(agentAsset);/*                //Use NODE name to assign FWD / REAR property -- doing this also for nodes in getNode()                if (nodeName.startsWith("REAR")) {                    agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "REAR"));                } else if (nodeName.startsWith("FWD")) {                    agentAsset.addProperty(new AgentAssetProperty(AgentAssetProperty.location, "FORWARD"));                }*/                iter.remove();                queueChangeEvent(new AssetChangeEvent( agentAsset, AssetChangeEvent.NEW_ASSET));            }        }