Running Jade agents using swing

I have coded a database update software that allows me to deploy a jade mobile agent to update the database. To run it I need to run it using the AMS gui. I would like to run it from gui. Now I have made a great swing gui and I need to know the code that allows me to start my mobile agent when the refresh button is clicked. What is code? Thanks in advance.

+3


source to share


2 answers


To run an agent or do anything JADE-related, you need to write your code using the JADE libraries and APIs, no matter which interface you were using (Swing in this case) One suggestion would be to keep modularity, create another a file that does one of the many such operations you want, and allow your Swing GUI to communicate (say over sockets) with that file by invoking the operation. This file, which will act as a server, will listen on the interface and do the appropriate work. But all commands must be coded using the JADE API. One of these codes:

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

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



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

dummy.start();

+1


source


This is the method I wrote to start one agent from another. You will need to edit it to use it across multiple containers.



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

      

0


source







All Articles