Guest User

Untitled

a guest
Sep 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.58 KB | None | 0 0
  1. package RA;
  2. import ...
  3. /**
  4.  * @author Nelson Rodrigues
  5.  */
  6. public class RA extends Agent implements GraceAgent {
  7.     private formRA_ myGui = null;
  8.     private boolean isMyGuiON = false;
  9.  
  10.     @Override
  11.     protected void setup(){      
  12.         initialization(); //t2
  13.     // alocate the behaviour to handle the receive the messages
  14.         WaitingMessages waitingMessages = new WaitingMessages(this, isMyGuiON, myGui);
  15.         addBehaviour(waitingMessages);
  16.     }
  17.     @Override
  18.     public void initialization(){
  19.         loadProfile();
  20.         registerAtDF();
  21.         createGui();
  22.         connectToLocalDB();
  23.     }
  24.      /**
  25.      * Register the Resource_Agent service in the yellow pages    
  26.      * @return return the result of the operation
  27.      */
  28.     @Override
  29.     public boolean registerAtDF(){
  30.         boolean res = false;
  31.         DFAgentDescription dfd = new DFAgentDescription();
  32.         dfd.setName(getAID());
  33.         ServiceDescription service = new ServiceDescription();
  34.         service.setType("servico_RA");
  35.         service.setName(getLocalName());
  36.         dfd.addServices(service);
  37.         // *log -> notify the view result of registration ?
  38.         // -> notify the view the type of registration ?
  39.         try {
  40.             DFService.register(this, dfd);
  41.             //*log
  42.             res = true;
  43.         }
  44.         catch (FIPAException ex) {
  45.             Logger.getLogger(RA.class.getName()).log(Level.SEVERE, null, ex);
  46.             return false;
  47.         }
  48.  
  49.         return res;
  50.     }
  51.  
  52.     /**
  53.      * Connect to local BD
  54.      *
  55.      */
  56.     @Override
  57.     public boolean connectToLocalDB()
  58.     {
  59.         //ver qual a base de dados pois sera com as ontologias isto
  60.         throw new UnsupportedOperationException("Not supported yet.");
  61.     }
  62.  
  63.     /**
  64.      * //NOT DONE YET
  65.      *
  66.      * @return
  67.      */
  68.     @Override
  69.     public boolean loadProfile()
  70.     {
  71.         //load profile de um ficheiro xml ?
  72.         throw new UnsupportedOperationException("Not supported yet.");
  73.     }
  74.  
  75.     @Override
  76.     protected void takeDown()
  77.     {
  78.         //Deregistar das paginas amarelas
  79.         //kill GUI
  80.     }
  81.  
  82.    
  83.  
  84.     /**
  85.      * //NOT DONE YET see book
  86.      *
  87.      */
  88.     @Override
  89.     public void createGui()
  90.     {
  91.  
  92.         if (String.valueOf(getArguments()[0]).equals("gui")) {
  93.             isMyGuiON = true;
  94.             this.myGui = new formRA_(this);
  95.         }
  96.     }
  97.  
  98.     /**
  99.      * //NOT DONE YET
  100.      *
  101.      * @return
  102.      */
  103.     @Override
  104.     public void killGui()
  105.     {
  106.         //this.myGui.dispose();
  107.         //kill the agent ??
  108.     }
  109. }
Add Comment
Please, Sign In to add comment