Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package jason.infra.centralised;
  
 
 import java.util.List;
 import java.util.Set;
This class implements the centralised version of the runtime services.
 
 
     private static Logger logger = Logger.getLogger(CentralisedRuntimeServices.class.getName());
     
     private RunCentralisedMAS masRunner;
     
     public CentralisedRuntimeServices(RunCentralisedMAS masRunner) {
         this. = masRunner;
     }
     
     protected CentralisedAgArch newAgInstance() {
         return new CentralisedAgArch();
     }
     
     public String createAgent(String agNameString agSourceString agClassList<StringarchClassesClassParameters bbParsSettings sttsthrows Exception {
         if (.isLoggable(.)) 
             .fine("Creating centralised agent " + agName + " from source " + agSource + " (agClass=" + agClass + ", archClass=" + archClasses + ", settings=" + stts);
 
         AgentParameters ap = new AgentParameters();
         ap.setAgClass(agClass);
         ap.addArchClass(archClasses);
         ap.setBB(bbPars);
         
         if (stts == null
             stts = new Settings();
         
         while (.getAg(agName) != null)
             agName += "_a";
 
         CentralisedAgArch agArch = newAgInstance();
         agArch.setAgName(agName);
         agArch.createArchs(ap.getAgArchClasses(), ap.agClass.getClassName(), ap.getBBClass(), agSourcestts);
         .addAg(agArch);
         
         .fine("Agent " + agName + " created!");
         return agName;
     }
     
     public void startAgent(String agName) {
         // create the agent thread
         CentralisedAgArch agArch = .getAg(agName);
         Thread agThread = new Thread(agArch);
         agArch.setThread(agThread);
         agThread.start(); 
     }
     
     public AgArch clone(Agent sourceList<StringarchClassesString agNamethrows JasonException {
         // create a new infra arch
         CentralisedAgArch agArch = newAgInstance();
         agArch.setAgName(agName);
         .addAg(agArch);
         
         agArch.createArchs(archClassessource);
 
         startAgent(agName);
         return agArch.getUserAgArch();
     }
 
     public Set<StringgetAgentsNames() {
         return .getAgs().keySet();
     }
     
     public int getAgentsQty() {
         return .getAgs().keySet().size();
     }
 
     public boolean killAgent(String agNameString byAg) {
         .fine("Killing centralised agent " + agName);
         CentralisedAgArch ag = .getAg(agName);
         if (ag != null && ag.getTS().getAg().killAcc(byAg)) {
             ag.stopAg();
             return true;
         }
         return false;
     }
 
     public void stopMAS() throws Exception {
         .finish();
     }
New to GrepCode? Check out our FAQ X