}
private void fireAddedBehaviour(AID agentID, Behaviour b) {
// NOTE: A normal synchronized block could create deadlock problems
// as it prevents concurrent scannings of the listeners list.
List l = agentListeners.startScanning();
if (l != null) {
AgentEvent ev = null;
if (b == b.root()) {
// The behaviour has been added to the Agent
ev = new AgentEvent(AgentEvent.ADDED_BEHAVIOUR, agentID, new BehaviourID(b), myID());
}
else {
// The behaviour is actually a new child that has been added to a CompositeBehaviour
//FIXME: TO be done
//ev = new AgentEvent(AgentEvent.ADDED_SUB_BEHAVIOUR, agentID, new BehaviourID(b.getParent()), new BehaviourID(b), myID());
}
Iterator it = l.iterator();
while (it.hasNext()) {
AgentListener al = (AgentListener) it.next();
al.addedBehaviour(ev);
}
agentListeners.stopScanning();