简体   繁体   English

使用swing启动Jade代理

[英]Launch Jade agents using swing

i have coded a database update software which allows me to deploy a jade mobile agent in order to update the database. 我编写了一个数据库更新软件,允许我部署一个玉移动代理,以更新数据库。 In order for it to run, i need to launch it using the AMS gui. 为了运行它,我需要使用AMS gui启动它。 I wanted to be able to launch it from gui. 我希望能够从gui发布它。 I have now done a nice swing gui and i only need to know the code which allows me to launch my mobile agent when the "Update" button is clicked. 我现在做了一个很好的摇摆gui,我只需要知道允许我在点击“更新”按钮时启动我的移动代理的代码。 What is the code? 代码是什么? Thanks in advance. 提前致谢。

To launch an agent or do whatever related to JADE you need to write YOUR code using JADE libraries and API, irrespective of what Front End you have used (Swing in this case) One suggestion would be, to keep the modularity, is create another file which does one of many such operations you want, and let your Swing GUI interact (say via sockets) to that file, triggering your operation. 要启动代理或执行与JADE相关的任何操作,您需要使用JADE库和API编写代码,而不管您使用的是什么前端(在这种情况下为Swing)一个建议是,为了保持模块性,创建另一个文件它可以执行您想要的许多此类操作之一,并让您的Swing GUI与该文件进行交互(例如通过套接字),从而触发您的操作。 That file, which would act as a server, would listen to the front end and do the respective work. 该文件将充当服务器,将收听前端并执行相应的工作。 But all commands are to be coded using JADE API. 但是所有命令都要使用JADE API进行编码。 One such code is: 一个这样的代码是:

ContainerController cc = Runtime.instance().createAgentContainer(newProfileImpl());

Object arguments[] = new Object[1];``arguments[0]=new Object();

AgentController dummy = cc.createNewAgent("mob2","mobiletrial", arguments);

dummy.start();

This is a method I wrote for launching one agent from another.You'll have to edit it for multiple container use. 这是我为从另一个代理启动一个代理而编写的方法。您需要编辑它以便多个容器使用。

void launchAgent( final String AgentName, final String AgentType)
{
    log(Level.FINER,"attempting to launch angent name: "+AgentName+" type: "+AgentType);
    CreateAgent ca = new CreateAgent();
    ca.setAgentName(AgentName);
    ca.setClassName(AgentType);
    ca.setContainer(new ContainerID(AgentContainer.MAIN_CONTAINER_NAME, null));
    Action actExpr = new Action(this.getAMS(), ca);
    ACLMessage request = new ACLMessage(ACLMessage.REQUEST);
    request.addReceiver(this.getAMS());

    request.setOntology(JADEManagementOntology.getInstance().getName());


    request.setLanguage(FIPANames.ContentLanguage.FIPA_SL);
    request.setProtocol(FIPANames.InteractionProtocol.FIPA_REQUEST);
    try {
        getContentManager().fillContent(request, actExpr);

        addBehaviour(new AchieveREInitiator(this, request) {
            protected void handleInform(ACLMessage inform) {
            log(Level.INFO,"Agent successfully created name:"+AgentName+" type: "+AgentType);
            }

        protected void handleFailure(ACLMessage failure) {
            log(Level.SEVERE,"Agent launch failed name: "+AgentName+" type: "+AgentType);
            }
            } );
        }
    catch (Exception e) {
        e.printStackTrace();
        }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM