package jadePrime.manage;
import jade.core.Agent;
import jade.core.AID;
import jade.domain.AMSService;
import jade.domain.FIPAAgentManagement.*;
public class AMSDump extends Agent
{
protected void setup()
{
AMSAgentDescription [] agents = null;
try {
SearchConstraints c = new SearchConstraints();
c.setMaxResults (new Long(-1));
agents = AMSService.search( this, new AMSAgentDescription (), c );
}
catch (Exception e) {
System.out.println( "Problem searching AMS: " + e );
e.printStackTrace();
}
AID myID = getAID();
for (int i=0; i<agents.length;i++)
{
AID agentID = agents[i].getName();
System.out.println(
( agentID.equals( myID ) ? "*** " : " ")
+ i + ": " + agentID.getName()
);
}
doDelete();
//System.exit(0);
}
} //end
详见:http://www.iro.umontreal.ca/%7Evaucher/Agents/Jade/primer4.html#5
运行结果:
![](http://blog.chinaunix.net/upfile/070529084420.jpg)