/** * Create a df service description. * @param name The name. * @param type The type. * @param ownership The ownership. * @param languages The languages. * @param ontologies The ontologies. * @param protocols The protocols. * @param properties The properties. * @return The service description. */ public IDFServiceDescription createDFServiceDescription(String name, String type, String ownership, String[] languages, String[] ontologies, String[] protocols, IProperty[] properties) { DFServiceDescription ret = new DFServiceDescription(name, type, ownership); for(int i=0; languages!=null && i<languages.length; i++) ret.addLanguage(languages[i]); for(int i=0; ontologies!=null && i<ontologies.length; i++) ret.addOntology(ontologies[i]); for(int i=0; protocols!=null && i<protocols.length; i++) ret.addProtocol(protocols[i]); for(int i=0; properties!=null && i<properties.length; i++) ret.addProperty(properties[i]); return ret; }
/** * @param obj * @return true if obj is an ServiceDescription and both are equal * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if(!(obj instanceof DFServiceDescription)) return false; DFServiceDescription sd = (DFServiceDescription)obj; return eq(sd.name, name) && eq(sd.ownership, ownership) && eq(sd.type, type) && eq(sd.languages, languages) && eq(sd.ontologies, ontologies) && eq(sd.protocols, protocols) && eq(sd.properties, properties); }
/** * Create a new service description. * @param name The name. * @param type The type expression. * @param ownership The ownership. */ public DFServiceDescription(String name, String type, String ownership) { this.languages = new ArrayList(); this.properties = new ArrayList(); this.ontologies = new ArrayList(); this.protocols = new ArrayList(); this.setName(name); this.setType(type); this.setOwnership(ownership); }
/** * Create a df service description. * @param name The name. * @param type The type. * @param ownership The ownership. * @return The service description. */ public IDFServiceDescription createDFServiceDescription(String name, String type, String ownership) { return new DFServiceDescription(name, type, ownership); }
/** * Clone a component description. */ public Object clone() { try { DFComponentDescription ret = (DFComponentDescription)super.clone(); ret.services = new ArrayList(); ret.protocols = (List)((ArrayList)protocols).clone(); ret.languages = (List)((ArrayList)languages).clone(); ret.ontologies = (List)((ArrayList)ontologies).clone(); for(int i = 0; i < services.size(); i++) { ret.services.add(((DFServiceDescription)services.get(i)).clone()); } return ret; } catch(CloneNotSupportedException e) { throw new RuntimeException("Cannot clone: " + this); } }
/** * Create a df service description. * @param name The name. * @param type The type. * @param ownership The ownership. * @return The service description. */ public IDFServiceDescription createDFServiceDescription(String name, String type, String ownership) { return new DFServiceDescription(name, type, ownership); }
/** * Clone a component description. */ public Object clone() { try { DFComponentDescription ret = (DFComponentDescription)super.clone(); ret.services = new ArrayList(); ret.protocols = (List)((ArrayList)protocols).clone(); ret.languages = (List)((ArrayList)languages).clone(); ret.ontologies = (List)((ArrayList)ontologies).clone(); for(int i = 0; i < services.size(); i++) { ret.services.add(((DFServiceDescription)services.get(i)).clone()); } return ret; } catch(CloneNotSupportedException e) { throw new RuntimeException("Cannot clone: " + this); } }
/** * Create a df service description. * @param name The name. * @param type The type. * @param ownership The ownership. * @param languages The languages. * @param ontologies The ontologies. * @param protocols The protocols. * @param properties The properties. * @return The service description. */ public IDFServiceDescription createDFServiceDescription(String name, String type, String ownership, String[] languages, String[] ontologies, String[] protocols, IProperty[] properties) { DFServiceDescription ret = new DFServiceDescription(name, type, ownership); for(int i=0; languages!=null && i<languages.length; i++) ret.addLanguage(languages[i]); for(int i=0; ontologies!=null && i<ontologies.length; i++) ret.addOntology(ontologies[i]); for(int i=0; protocols!=null && i<protocols.length; i++) ret.addProtocol(protocols[i]); for(int i=0; properties!=null && i<properties.length; i++) ret.addProperty(properties[i]); return ret; }
/** * Create a df service description. * @param name The name. * @param type The type. * @param ownership The ownership. * @return The service description. */ public IDFServiceDescription createDFServiceDescription(String name, String type, String ownership) { return new DFServiceDescription(name, type, ownership); }
/** * Create a new service description. * @param name The name. * @param type The type expression. * @param ownership The ownership. */ public DFServiceDescription(String name, String type, String ownership) { this.languages = new ArrayList(); this.properties = new ArrayList(); this.ontologies = new ArrayList(); this.protocols = new ArrayList(); this.setName(name); this.setType(type); this.setOwnership(ownership); }
/** * @param obj * @return true if obj is an ServiceDescription and both are equal * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if(!(obj instanceof DFServiceDescription)) return false; DFServiceDescription sd = (DFServiceDescription)obj; return eq(sd.name, name) && eq(sd.ownership, ownership) && eq(sd.type, type) && eq(sd.languages, languages) && eq(sd.ontologies, ontologies) && eq(sd.protocols, protocols) && eq(sd.properties, properties); }
/** * Create a df service description. * @param name The name. * @param type The type. * @param ownership The ownership. * @param languages The languages. * @param ontologies The ontologies. * @param protocols The protocols. * @param properties The properties. * @return The service description. */ public IDFServiceDescription createDFServiceDescription(String name, String type, String ownership, String[] languages, String[] ontologies, String[] protocols, IProperty[] properties) { DFServiceDescription ret = new DFServiceDescription(name, type, ownership); for(int i=0; languages!=null && i<languages.length; i++) ret.addLanguage(languages[i]); for(int i=0; ontologies!=null && i<ontologies.length; i++) ret.addOntology(ontologies[i]); for(int i=0; protocols!=null && i<protocols.length; i++) ret.addProtocol(protocols[i]); for(int i=0; properties!=null && i<properties.length; i++) ret.addProperty(properties[i]); return ret; }
/** * First the player searches a dealer, then sends a join-request to this * dealer. */ public void body() { //System.out.println("Searching dealer..."); // Create a service description to search for. IDF df = (IDF)SServiceProvider.getService(getAgent(), IDF.class, RequiredServiceInfo.SCOPE_PLATFORM).get(); IDFServiceDescription sd = new DFServiceDescription(null, "blackjack", null); IDFComponentDescription ad = new DFComponentDescription(null, sd); ISearchConstraints sc = new SearchConstraints(-1, 0); IDFComponentDescription[] result = df.search(ad, sc).get(); if(result==null || result.length==0) { getLogger().warning("No blackjack-dealer found."); fail(); } else { // at least one matching description found, getLogger().info(result.length + " blackjack-dealer found"); // choose one dealer randomly out of all the dealer-agents IComponentIdentifier dealer = result[new Random().nextInt(result.length)].getName(); getBeliefbase().getBelief("dealer").setFact(dealer); } }
/** * Search the environent agent and store its AID in the beliefbase. */ protected void searchEnvironmentAgent() { try { IDF df = (IDF)SServiceProvider.getService(getAgent(), IDF.class, RequiredServiceInfo.SCOPE_PLATFORM).get(); IDFServiceDescription sd = new DFServiceDescription(null, "dispatch vision", null); IDFComponentDescription ad = new DFComponentDescription(null, sd); IDFComponentDescription[] tas = df.search(ad, null).get(); if(tas.length!=0) { getBeliefbase().getBelief("environmentagent").setFact(tas[0].getName()); if(tas.length>1) System.out.println("WARNING: more than environment agent found."); } } catch(GoalFailureException gfe) { getLogger().warning("DF search failed: "+gfe); } } }
/** * Search the environent agent and store its AID in the beliefbase. */ protected IComponentIdentifier searchEnvironmentAgent() { IComponentIdentifier res = (IComponentIdentifier)getBeliefbase().getBelief("environmentagent").getFact(); if(res==null) { IDF df = (IDF)SServiceProvider.getService(getAgent(), IDF.class, RequiredServiceInfo.SCOPE_PLATFORM).get(); IDFServiceDescription sd = new DFServiceDescription(null, "dispatch vision", null); IDFComponentDescription ad = new DFComponentDescription(null, sd); IDFComponentDescription[] tas = df.search(ad, null).get(); if(tas.length!=0) { // Found. res = tas[0].getName(); getBeliefbase().getBelief("environmentagent").setFact(res); if(tas.length>1) getLogger().warning("More than environment agent found."); } else { // Not found. throw new PlanFailureException(); } } return res; }
/** * Search the environent agent and store its AID in the beliefbase. */ protected IComponentIdentifier searchEnvironmentAgent() { IComponentIdentifier res = (IComponentIdentifier)getBeliefbase().getBelief("environmentagent").getFact(); if(res==null) { IDF df = (IDF)SServiceProvider.getService(getAgent(), IDF.class, RequiredServiceInfo.SCOPE_PLATFORM).get(); IDFServiceDescription sd = new DFServiceDescription(null, "hunter-prey environment", null); IDFComponentDescription ad = new DFComponentDescription(null, sd); IDFComponentDescription[] tas = df.search(ad, null).get(); if(tas.length!=0) { // Found. res = tas[0].getName(); getBeliefbase().getBelief("environmentagent").setFact(res); if(tas.length>1) getLogger().warning("More than environment agent found."); } else { // Not found. throw new PlanFailureException(); } } return res; }
IDFServiceDescription sd = new DFServiceDescription("service_produce", null, null); IDFComponentDescription dfadesc = new DFComponentDescription(null, sd);
IDFServiceDescription sd = new DFServiceDescription("service_sentry", null, null); IDFComponentDescription dfadesc = new DFComponentDescription(null, sd);
IDFServiceDescription sd = new DFServiceDescription("service_sentry", null, null); IDFComponentDescription dfadesc = new DFComponentDescription(null, sd);
IDFServiceDescription sd = new DFServiceDescription("service_carry", null, null); IDFComponentDescription dfadesc = new DFComponentDescription(null, sd);