Package jade.domain.FIPAAgentManagement

Examples of jade.domain.FIPAAgentManagement.ServiceDescription


                new Object[]{getAID().getLocalName(), serviceName});


        DFAgentDescription dfd = new DFAgentDescription();
        dfd.setName(getAID());
        ServiceDescription sd = new ServiceDescription();

        sd.setType(RESOURCE_AGENT_TYPE);
        sd.setName(serviceName);
        dfd.addServices(sd);

        addBehaviour(new ResourceBehaviour());

        try {
View Full Code Here


        if (arguments != null) {
            destinationLocalName = (String) arguments[0];
            fullServiceName = NODE_AGENT_SERVICE_PREFIX + destinationLocalName;
            DFAgentDescription dfd = new DFAgentDescription();
            dfd.setName(getAID());
            ServiceDescription sd = new ServiceDescription();

            sd.setType(NODE_AGENT_TYPE);
            sd.setName(fullServiceName);
            dfd.addServices(sd);

            try {
                DFService.register(this, dfd);
            } catch (FIPAException fe) {
View Full Code Here

     * Registers this agent with the DF.
     */
    private void register() {
        DFAgentDescription dfd = new DFAgentDescription();
        dfd.setName(getAID());
        ServiceDescription sd = new ServiceDescription();

        sd.setType(CLIENT_AGENT_TYPE);
        sd.setName(CLIENT_AGENT_SERVICE);
        dfd.addServices(sd);
        try {
            DFService.register(this, dfd);
        } catch (FIPAException ex) {
            Logger.getLogger(ClientAgent.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

     * @param type The agent type that should be searched for
     * @return The DFAgentDescription template
     */
    private DFAgentDescription buildSearchTemplateForType(String type) {
        DFAgentDescription template = new DFAgentDescription();
        ServiceDescription sd = new ServiceDescription();
        sd.setType(type);
        template.addServices(sd);
        return template;
    }
View Full Code Here

     * @param service The service name that should be searched for
     * @return The DFAgentDescription template
     */
    private DFAgentDescription buildSearchTemplateForService(String service) {
        DFAgentDescription template = new DFAgentDescription();
        ServiceDescription sd = new ServiceDescription();
        sd.setName(service);
        template.addServices(sd);
        return template;
    }
View Full Code Here

     * @param type The agent type that should be searched for
     * @return The DFAgentDescription template
     */
    private DFAgentDescription buildSearchTemplateForServiceAndType(String service, String type) {
        DFAgentDescription template = new DFAgentDescription();
        ServiceDescription sd = new ServiceDescription();
        sd.setName(service);
        sd.setType(type);
        template.addServices(sd);
        return template;
    }
View Full Code Here

      }

      // Match services set
      itTemplate = templateDesc.getAllServices();
      while(itTemplate.hasNext()) {
        ServiceDescription templateSvc = (ServiceDescription)itTemplate.next();
        boolean found = false;
        Iterator itFact = factDesc.getAllServices();
        while(!found && itFact.hasNext()) {
          ServiceDescription factSvc = (ServiceDescription)itFact.next();
          found = compareServiceDesc(templateSvc, factSvc);
        }
        if(!found)
          return false;
      }
View Full Code Here

      boolean executeOntologiesBatch = false;
      boolean executeLanguagesBatch = false;
      boolean executePropertiesBatch = false;
     
      while(iter.hasNext()){
        ServiceDescription service = (ServiceDescription)iter.next();
        String serviceId = getGUID();
        pss.stm_insService.clearParameters();
        pss.stm_insService.setString(1, serviceId);
        pss.stm_insService.setString(2, descrId);
        pss.stm_insService.setString(3, service.getName());
        pss.stm_insService.setString(4, service.getType());
        pss.stm_insService.setString(5, service.getOwnership());
        pss.stm_insService.addBatch();
       
        // Service - Protocols
        Iterator iterS = service.getAllProtocols();
        while(iterS.hasNext()){
          pss.stm_insServiceProtocol.setString(1, serviceId);
          pss.stm_insServiceProtocol.setString(2, (String)iterS.next());
          pss.stm_insServiceProtocol.addBatch();
          executeProtocolsBatch = true;
        }
       
        // Service - Ontologies
        iterS = service.getAllOntologies();
        while(iterS.hasNext()){
          pss.stm_insServiceOntology.setString(1, serviceId);
          pss.stm_insServiceOntology.setString(2, (String)iterS.next());
          pss.stm_insServiceOntology.addBatch();
          executeOntologiesBatch = true;
        }
       
        // Service - Languages
        iterS = service.getAllLanguages();
        while(iterS.hasNext()){
          pss.stm_insServiceLanguage.setString(1, serviceId);
          pss.stm_insServiceLanguage.setString(2, (String)iterS.next());
          pss.stm_insServiceLanguage.addBatch();
          executeLanguagesBatch = true;
        }
       
        // Service - Properties
        iterS = service.getAllProperties();
        while(iterS.hasNext()){
         
          Property prop = (Property)iterS.next();
          try {
            pss.stm_insServiceProperty.setString(1, serviceId);
            pss.stm_insServiceProperty.setString(2, prop.getName());
           
            // serialize value to a string and calcualte
            // a hash map for later search operations
            Object value = prop.getValue();
            // store plain String object value directly
            // in 'propval_str' field otherwise store it in
            // 'propval_obj' field and fill hash field (this will be used in search phase to allow matching Serializable objects)
            if ( needSerialization(value) ) {
              //System.out.println("DF Handling Object property "+prop.getName()+": value = "+value);
              String valueStr = serializeObj(value);
              pss.stm_insServiceProperty.setString(3, valueStr);
              pss.stm_insServiceProperty.setString(4, null);
              String hashStr = getHashValue(value);
              pss.stm_insServiceProperty.setString(5, hashStr);
            }
            else {
              // set to NULL the serialized representation of the object and its hash
              //System.out.println("DF Handling String property "+prop.getName()+": value = "+value);
              pss.stm_insServiceProperty.setString(3, null);
              pss.stm_insServiceProperty.setString(4, (String) value);
              pss.stm_insServiceProperty.setString(5, null);
            };
           
            pss.stm_insServiceProperty.addBatch();
            executePropertiesBatch = true;           
          } catch (Exception e) {
            if(logger.isLoggable(Logger.SEVERE))
              logger.log(Logger.SEVERE,"Cannot serialize property '" + prop.getName() +
                  "' for service '" + service.getName() + "'", e);
          }
        }
      }
      pss.stm_insService.executeBatch();
      if (executeProtocolsBatch) {
View Full Code Here

     
      // Services
      pss.stm_selServices.setString(1, descrId);
      rs = pss.stm_selServices.executeQuery();
      while(rs.next()) {
        ServiceDescription sd = new ServiceDescription();
        String serviceId = rs.getString("id");
        sd.setName(rs.getString("sname"));
        sd.setType(rs.getString("stype"));
        sd.setOwnership(rs.getString("sownership"));
       
        // Service protocols
        pss.stm_selServiceProtocols.setString(1, serviceId);
        rsS = pss.stm_selServiceProtocols.executeQuery();
        while(rsS.next()){
          sd.addProtocols(rsS.getString(PROTOCOL));
       
        closeResultSet(rsS);
       
        // Service languages
        pss.stm_selServiceLanguages.setString(1, serviceId);
        rsS = pss.stm_selServiceLanguages.executeQuery();
        while(rsS.next()){
          sd.addOntologies(rsS.getString(ONTOLOGY));
       
        closeResultSet(rsS);
       
        // Service ontologies
        pss.stm_selServiceOntologies.setString(1, serviceId);
        rsS = pss.stm_selServiceOntologies.executeQuery();
        while(rsS.next()){
          sd.addLanguages(rsS.getString(LANGUAGE));
        }
        closeResultSet(rsS);
       
        // Service properties
        pss.stm_selServiceProperties.setString(1, serviceId);
        rsS = pss.stm_selServiceProperties.executeQuery();
        while(rsS.next()){
          Property prop = new Property();
          prop.setName(rsS.getString("propkey"));
          String objStrVal = rsS.getString("propval_obj");
          String strStrVal = rsS.getString("propval_str");
          Object value = ( objStrVal == null )? strStrVal : deserializeObj(objStrVal);
          prop.setValue(value);
          sd.addProperties(prop);
        }
       
        dfd.addServices(sd);
      }
    }
View Full Code Here

    }
    // Services
    iter = dfdTemplate.getAllServices();
    i = 0;
    while(iter.hasNext()){
      ServiceDescription service = (ServiceDescription)iter.next();
      String serviceName = service.getName();
      String serviceType = service.getType();
      String serviceOwner = service.getOwnership();
      // Service name, type and ownership
      String tmp = SERVICE+i;
      lAs.add(", service "+tmp);
      if(serviceName != null){
        lWhere.add(tmp+".sname='"+serviceName+"'");
      }
      if(serviceType != null){
        lWhere.add(tmp+".stype='"+serviceType+"'");
      }
      if(serviceOwner != null){
        lWhere.add(tmp+".sownership='"+serviceOwner+"'");
      }
      lWhere.add(tmp+".descrid=dfagentdescr.id");
      i++;
     
      // Service languages
      Iterator iterS = service.getAllLanguages();
      int j = 0;
      while(iterS.hasNext()){
        String tmp1 = SERVICELANGUAGE+j;
        lAs.add(", servicelanguage "+tmp1);
        lWhere.add(tmp1+".language='"+(String)iterS.next()+"'");
        lWhere.add(tmp1+".serviceid="+tmp+".id");
        j++;
      }
      // Service ontologies
      iterS = service.getAllOntologies();
      j = 0;
      while(iterS.hasNext()){
        String tmp1 = SERVICEONTOLOGY+j;
        lAs.add(", serviceontology "+tmp1);
        lWhere.add(tmp1+".ontology='"+(String)iterS.next()+"'");
        lWhere.add(tmp1+".serviceid="+tmp+".id");
        j++;
      }
      // Service protocols
      iterS = service.getAllProtocols();
      j = 0;
      while(iterS.hasNext()){
        String tmp1 = SERVICEPROTOCOL+j;
        lAs.add(", serviceprotocol "+tmp1);
        lWhere.add(tmp1+".protocol='"+(String)iterS.next()+"'");
        lWhere.add(tmp1+".serviceid="+tmp+".id");
        j++;
      }
      // Service properties
      iterS = service.getAllProperties();
      j = 0;
      while(iterS.hasNext()){
        String tmp1 = SERVICEPROPERTY+j;
        lAs.add(", serviceproperty "+tmp1);
        Property prop = (Property) iterS.next()
View Full Code Here

TOP

Related Classes of jade.domain.FIPAAgentManagement.ServiceDescription

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.