Package jade.core

Examples of jade.core.ServiceHelper


  public String getBEServiceClassName() {
    return "jade.core.messaging.TopicManagementService";
  }

  public ServiceHelper getHelper(Agent a) {
    ServiceHelper sh = new TopicManagementHelper() {
      private Agent myAgent;
     
      public void init(Agent a) {
        myAgent = a;
      }
     
      public AID createTopic(String topicName) {
        return TopicUtility.createTopic(topicName);
      }

      public boolean isTopic(AID id) {
        return TopicUtility.isTopic(id);
      }
     
      public void register(AID topic) throws ServiceException {
        try {
          invoke(myAgent.getLocalName(), "register", new Object[]{topic});
        }
        catch (NotFoundException nfe) {
          throw new ServiceException("Registering agent "+myAgent.getLocalName()+" not found on the back-end");
        }
        catch (IMTPException imtpe) {
          throw new ServiceException("Communication error: "+imtpe.getMessage(), imtpe);
        }
      }
     
      public void deregister(AID topic) throws ServiceException {
        try {
          invoke(myAgent.getLocalName(), "deregister", new Object[]{topic});
        }
        catch (NotFoundException nfe) {
          throw new ServiceException("Deregistering agent "+myAgent.getLocalName()+" not found on the back-end");
        }
        catch (IMTPException imtpe) {
          throw new ServiceException("Communication error: "+imtpe.getMessage(), imtpe);
        }
      }
    };
    sh.init(a);
    return sh;
  }
View Full Code Here

TOP

Related Classes of jade.core.ServiceHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.