【问题标题】:how execute an JADE agent from ordinary(not agent) java class?如何从普通(非代理)Java 类执行 JADE 代理?
【发布时间】:2017-01-17 13:31:00
【问题描述】:

我想从不是代理的其他类向代理发送消息。例如 Servlet 或主要静态类。

【问题讨论】:

  • 您是否考虑过您正在打破实施范式这一事实?创建一个代理来发送这条消息不是更好吗?
  • 感谢您的评论,我无法将 servlet 类更改为代理。
  • 你试过 JadeGateway jade.tilab.com/doc/tutorials/JadeGateway.pdf 吗?

标签: java agent agents-jade multi-agent


【解决方案1】:

这是一个普通的类而不是代理:

        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);



            }
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-25
    • 1970-01-01
    • 1970-01-01
    • 2011-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多