我想从其他不是代理的类向代理发送消息。例如Servlet或主要的静态类。
答案 0 :(得分:0)
这是一个oridnary类而不是代理:
MainContainerAgentsRetriever retriever = new MainContainerAgentsRetriever();
JadeGateway.execute(retriever);
// At this point the retriever behaviour has been fully executed --> the list of
// agents running in the Main Container is available: get it and print it
List agents = retriever.getAgents();
if (agents != null) {
System.out.println("Agents living in the Main Container: ");
for (int i = 0; i < agents.size(); ++i) {
System.out.println("- " + ((AID) agents.get(i)).getLocalName());
ACLMessage msg = new ACLMessage();
msg.addReceiver(((AID) agents.get(i)));
msg.setContent("salam refigha");
retriever.send(msg);
}
}