/** * Create a new df component description. * @param component The component id. * @param services The services. * @param languages The languages. * @param ontologies The ontologies. * @param protocols The protocols. * @return The component description. */ public IDFComponentDescription createDFComponentDescription(IComponentIdentifier component, IDFServiceDescription[] services, String[] languages, String[] ontologies, String[] protocols, Date leasetime) { DFComponentDescription ret = new DFComponentDescription(); ret.setName(component); ret.setLeaseTime(leasetime); for(int i=0; services!=null && i<services.length; i++) ret.addService(services[i]); 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]); return ret; }
/** * Get a string representation of this ComponentDescription. * @return The string representation. */ public String toString() { return "ComponentDescription(" + getName() + (leasetime!=null ? ", "+leasetime.getTime()+")" : ")"); } }
/** * Create a df component description. * @param component The component. * @param service The service. * @return The df component description. */ public IDFComponentDescription createDFComponentDescription(IComponentIdentifier component, IDFServiceDescription service) { DFComponentDescription ret = new DFComponentDescription(); ret.setName(component); if(service!=null) ret.addService(service); return ret; }
/** * Create a df component description. * @param component The component. * @param service The service. * @return The df component description. */ public IDFComponentDescription createDFComponentDescription(IComponentIdentifier component, IDFServiceDescription service, long leasetime) { DFComponentDescription ret = new DFComponentDescription(); ret.setName(component); if(service!=null) ret.addService(service); ret.setLeaseTime(new Date(clockservice.getTime()+leasetime)); return ret; }
/** * Refresh the view. */ protected void refresh() { // df.search(df.createDFComponentDescription(null, null), null).addResultListener(new SwingDefaultResultListener(this) df.search(new DFComponentDescription(null), null, remotecb.isSelected()).addResultListener(new SwingDefaultResultListener(this) { public void customResultAvailable(Object result) { IDFComponentDescription[] ads = (IDFComponentDescription[])result; // System.out.println("Found: "+SUtil.arrayToString(ads)); if(old_ads == null || !Arrays.equals(old_ads, ads)) { component_table.setComponentDescriptions(ads); updateServices(ads); updateDetailedService(); old_ads = ads; } } }); }
if(ad.getLeaseTime()!=null && ad.getLeaseTime().getTime()<clockservice.getTime()) components.removeKey(ad.getName()); else ret.add(ad); if(descs[i].getLeaseTime()!=null && descs[i].getLeaseTime().getTime()<clockservice.getTime()) components.removeKey(descs[i].getName());
public void body() { DFComponentDescription desc = (DFComponentDescription)getParameter("description").getValue(); long lease = -1; if(desc.getLeaseTime()!=null) { lease = desc.getLeaseTime().getTime()-getTime(); } IDF df = SServiceProvider.getLocalService(getAgent(), IDF.class, RequiredServiceInfo.SCOPE_PLATFORM); df.register(desc).get(); while(lease!=-1) { waitFor((long)(lease*0.8)); desc.setLeaseTime(new Date(getTime()+lease)); df.modify(desc).get(); } } }
/** * Create a df component description. * @param component The component. * @param service The service. * @return The df component description. */ public IDFComponentDescription createDFComponentDescription(IComponentIdentifier component, IDFServiceDescription service) { DFComponentDescription ret = new DFComponentDescription(); ret.setName(component); if(service!=null) ret.addService(service); return ret; }
/** * Refresh the view. */ protected void refresh() { // df.search(df.createDFComponentDescription(null, null), null).addResultListener(new SwingDefaultResultListener(this) df.search(new DFComponentDescription(null), null, remotecb.isSelected()).addResultListener(new SwingDefaultResultListener(this) { public void customResultAvailable(Object result) { IDFComponentDescription[] ads = (IDFComponentDescription[])result; // System.out.println("Found: "+SUtil.arrayToString(ads)); if(old_ads == null || !Arrays.equals(old_ads, ads)) { component_table.setComponentDescriptions(ads); updateServices(ads); updateDetailedService(); old_ads = ads; } } }); }
if(ad.getLeaseTime()!=null && ad.getLeaseTime().getTime()<clockservice.getTime()) components.removeKey(ad.getName()); else ret.add(ad); if(descs[i].getLeaseTime()!=null && descs[i].getLeaseTime().getTime()<clockservice.getTime()) components.removeKey(descs[i].getName());
/** * Create a new df component description. * @param component The component id. * @param services The services. * @param languages The languages. * @param ontologies The ontologies. * @param protocols The protocols. * @return The component description. */ public IDFComponentDescription createDFComponentDescription(IComponentIdentifier component, IDFServiceDescription[] services, String[] languages, String[] ontologies, String[] protocols, Date leasetime) { DFComponentDescription ret = new DFComponentDescription(); ret.setName(component); ret.setLeaseTime(leasetime); for(int i=0; services!=null && i<services.length; i++) ret.addService(services[i]); 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]); return ret; }
/** * Create a df component description. * @param component The component. * @param service The service. * @return The df component description. */ public IDFComponentDescription createDFComponentDescription(IComponentIdentifier component, IDFServiceDescription service) { DFComponentDescription ret = new DFComponentDescription(); ret.setName(component); if(service!=null) ret.addService(service); 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); } }
if(ad.getLeaseTime()!=null && ad.getLeaseTime().getTime()<clockservice.getTime()) components.removeKey(ad.getName()); else ret.add(ad); if(descs[i].getLeaseTime()!=null && descs[i].getLeaseTime().getTime()<clockservice.getTime()) components.removeKey(descs[i].getName());
/** * Get a string representation of this ComponentDescription. * @return The string representation. */ public String toString() { return "ComponentDescription(" + getName() + (leasetime!=null ? ", "+leasetime.getTime()+")" : ")"); } }
/** * Create a new df component description. * @param component The component id. * @param services The services. * @param languages The languages. * @param ontologies The ontologies. * @param protocols The protocols. * @return The component description. */ public IDFComponentDescription createDFComponentDescription(IComponentIdentifier component, IDFServiceDescription[] services, String[] languages, String[] ontologies, String[] protocols, Date leasetime) { DFComponentDescription ret = new DFComponentDescription(); ret.setName(component); ret.setLeaseTime(leasetime); for(int i=0; services!=null && i<services.length; i++) ret.addService(services[i]); 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]); return ret; }
/** * Test registering. */ protected int testRegister(int num, IDF df, Date lt) { // Try to register by the df TestReport tr = new TestReport("#"+num++, lt!=null ? "Test register with lease time." : "Test register."); getLogger().info(tr.getDescription()); try { df.register(new DFComponentDescription(getAgent().getComponentIdentifier(), SERVICES, null, null, null, lt)).get(); getLogger().info(" register ok."); tr.setSucceeded(true); } catch(GoalFailureException gfe) { getLogger().info(" register failed: "+gfe); tr.setFailed(gfe); } getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); return num; }
/** * Create a new component description. * @param name The name. * @param services The services. * @param protocols The protocols. * @param ontologies The ontologies. * @param languages The languages. */ public DFComponentDescription(IComponentIdentifier name, IDFServiceDescription[] services, String[] protocols, String[] ontologies, String[] languages, Date leasetime) { this.languages = new ArrayList(); this.ontologies = new ArrayList(); this.services = new ArrayList(); this.protocols = new ArrayList(); this.setName(name); this.setLeaseTime(leasetime); if(services != null) for(int i = 0; i < services.length; i++) this.addService(services[i]); if(protocols != null) for(int i = 0; i < protocols.length; i++) this.addProtocol(protocols[i]); if(languages != null) for(int i = 0; i < languages.length; i++) this.addLanguage(languages[i]); if(ontologies != null) for(int i = 0; i < ontologies.length; i++) this.addOntology(ontologies[i]); }
/** * Test deregistering. */ protected int testDeregister(int num, IDF df) { // Try to deregister by the df TestReport tr = new TestReport("#"+num++, "Test deregister."); getLogger().info(tr.getDescription()); try { df.deregister(new DFComponentDescription(getAgent().getComponentIdentifier())).get(); getLogger().info(" deregister ok."); tr.setSucceeded(true); } catch(GoalFailureException gfe) { getLogger().info(" deregister failed: "+gfe); tr.setFailed(gfe); } getBeliefbase().getBeliefSet("testcap.reports").addFact(tr); return num; } }
/** * Create a new component description. * @param name The name. * @param services The services. * @param protocols The protocols. * @param ontologies The ontologies. * @param languages The languages. */ public DFComponentDescription(IComponentIdentifier name, IDFServiceDescription[] services, String[] protocols, String[] ontologies, String[] languages, Date leasetime) { this.languages = new ArrayList(); this.ontologies = new ArrayList(); this.services = new ArrayList(); this.protocols = new ArrayList(); this.setName(name); this.setLeaseTime(leasetime); if(services != null) for(int i = 0; i < services.length; i++) this.addService(services[i]); if(protocols != null) for(int i = 0; i < protocols.length; i++) this.addProtocol(protocols[i]); if(languages != null) for(int i = 0; i < languages.length; i++) this.addLanguage(languages[i]); if(ontologies != null) for(int i = 0; i < ontologies.length; i++) this.addOntology(ontologies[i]); }