// Update the map of debuggers currently debugging the targetName agent
synchronized (debuggers) {
List l = (List) debuggers.get(targetName);
if (l == null) {
l = new LinkedList();
debuggers.put(targetName, l);
}
if (!l.contains(introspectorName)) {
l.add(introspectorName);
}
}
Agent a = myContainer.acquireLocalAgent(targetName);
// Activate generation of behaviour-related events on the
// target agent
a.setGenerateBehaviourEvents(true);
// Retrieve the current agent state
AgentState as = a.getAgentState();
// Retrieve the list of pending ACL messages
List messages = new LinkedList();
myContainer.fillListFromMessageQueue(messages, a);
// Retrieve the list of ready and blocked agent behaviour IDs
List readyBehaviours = new LinkedList();
myContainer.fillListFromReadyBehaviours(readyBehaviours, a);
List blockedBehaviours = new LinkedList();
myContainer.fillListFromBlockedBehaviours(blockedBehaviours, a);
myContainer.releaseLocalAgent(targetName);
// Notify all the needed events
fireChangedAgentState(targetName, as, as);
Iterator itReady = readyBehaviours.iterator();
while(itReady.hasNext()) {
BehaviourID bid = (BehaviourID)itReady.next();
AgentEvent ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, targetName, bid, myContainer.getID());
tn.addedBehaviour(ev);
}
Iterator itBlocked = blockedBehaviours.iterator();
while(itBlocked.hasNext()) {
BehaviourID bid = (BehaviourID)itBlocked.next();
AgentEvent ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, targetName, bid, myContainer.getID());
tn.addedBehaviour(ev);
ev = new AgentEvent(AgentEvent.CHANGED_BEHAVIOUR_STATE, targetName, bid, Behaviour.STATE_READY, Behaviour.STATE_BLOCKED, myContainer.getID());