Naming a new container
Runtime rt = Runtime.instance(); // Get a hold on JADE runtime
Profile p = new ProfileImpl(); // Create a default profile
p.setParameter(Profile.CONTAINER_NAME, "your-container-name-goes-here" );
AgentContainer ac;
if (MainContainer) ac = rt.createMainContainer(p);
else ac = rt.createAgentContainer(p);
ac.createNewAgent(...
Profile p = new ProfileImpl(); // Create a default profile
p.setParameter(Profile.CONTAINER_NAME, "your-container-name-goes-here" );
AgentContainer ac;
if (MainContainer) ac = rt.createMainContainer(p);
else ac = rt.createAgentContainer(p);
ac.createNewAgent(...
Request the AMS to Perform the CreateAgent action
/**//*to REQUEST AMS agent to launch mobile agents*/
// Get a hold on JADE runtime Object[] args=getArguments();
AgentContainer mc = (AgentContainer) args[0 ];
CreateAgent ca=new CreateAgent();
ca.setClassName("sma.MobileAgent" );
ca.setAgentName("AM_0" );
ContainerID id=new ContainerID();
id.setName(mc.getName());
ca.setContainer(id);
ACLMessage request = new ACLMessage(ACLMessage.REQUEST);
request.setLanguage(FIPANames.ContentLanguage.FIPA_SL);
request.setOntology(JADEManagementOntology.NAME);
Action action=new Action();
action.setActor(getAMS());
action.setAction(ca);
try ... {
getContentManager().fillContent(request, action);
send(request);
}
catch (Exception ex) ...{ ex.printStackTrace(); }
// Get a hold on JADE runtime Object[] args=getArguments();
AgentContainer mc = (AgentContainer) args[0 ];
CreateAgent ca=new CreateAgent();
ca.setClassName("sma.MobileAgent" );
ca.setAgentName("AM_0" );
ContainerID id=new ContainerID();
id.setName(mc.getName());
ca.setContainer(id);
ACLMessage request = new ACLMessage(ACLMessage.REQUEST);
request.setLanguage(FIPANames.ContentLanguage.FIPA_SL);
request.setOntology(JADEManagementOntology.NAME);
Action action=new Action();
action.setActor(getAMS());
action.setAction(ca);
try ... {
getContentManager().fillContent(request, action);
send(request);
}
catch (Exception ex) ...{ ex.printStackTrace(); }