コード例 #1
0
 // #APIDOC_EXCLUDE_BEGIN
 public static void notifyFailureToSender(ACLMessage msg, String sender, String error) {
   if (myFrontEnd != null) {
     // Send back a failure message
     try {
       Iterator it = msg.getAllReceiver();
       while (it.hasNext()) {
         AID receiver = (AID) it.next();
         // If this receiver is local, the message has certainly been delivered
         // successfully --> Do not send any FAILURE back for this receiver
         if (myFrontEnd.getLocalAgent(receiver.getLocalName()) == null) {
           ACLMessage failure = msg.createReply();
           failure.setPerformative(ACLMessage.FAILURE);
           failure.setSender(myFrontEnd.getAMS());
           failure.setLanguage(FIPANames.ContentLanguage.FIPA_SL);
           String content = "( (action " + sender;
           content = content + " (ACLMessage) ) (MTS-error " + receiver + " \"" + error + "\") )";
           failure.setContent(content);
           myFrontEnd.messageIn(failure, sender);
         }
       }
     } catch (Exception e1) {
       logger.log(Logger.SEVERE, "Error delivering FAILURE message.", e1);
     }
   }
 }
コード例 #2
0
 /**
  * Get agent proxy to local agent given its name. <br>
  * <b>NOT available in MIDP</b> <br>
  *
  * @param localAgentName The short local name of the desired agent.
  * @throws ControllerException If any problems occur obtaining this proxy.
  */
 public static AgentController getAgent(String localName) throws ControllerException {
   if (myFrontEnd == null) {
     throw new ControllerException("FrontEndContainer  not found");
   }
   // Check that the agent exists
   jade.core.Agent instance = myFrontEnd.getLocalAgent(localName);
   if (instance == null) {
     throw new ControllerException("Agent " + localName + " not found.");
   }
   return new MicroAgentControllerImpl(localName, myFrontEnd);
 }