/** * Modify a component description. * @throws RuntimeException when the component is not registered. */ public IFuture<IDFComponentDescription> modify(IDFComponentDescription cdesc) { Future<IDFComponentDescription> ret = new Future<IDFComponentDescription>(); // Use clone to avoid caller manipulating object after insertion. IDFComponentDescription clone = SFipa.cloneDFComponentDescription(cdesc, cms, this); // Change description, when valid. if(clone.getLeaseTime()==null || clone.getLeaseTime().getTime()>clockservice.getTime()) { // Automatically throws exception, when key does not exist. components.replace(clone.getName(), clone); //System.out.println("modified: "+clone.getName()); ret.setResult(clone); } else { //throw new RuntimeException("Invalid lease time: "+clone.getLeaseTime()); ret.setException(new RuntimeException("Invalid lease time: "+clone.getLeaseTime())); } return ret; }
/** * Clone the df component description. * @param source The source df component description. * @param df The df service. */ public static IDFComponentDescription cloneDFComponentDescription(IDFComponentDescription source, IComponentManagementService cms, IDF df) { IDFServiceDescription[] sds = source.getServices(); IDFServiceDescription[] tds = null; if(sds!=null) { tds = new IDFServiceDescription[sds.length]; for(int i=0; i<sds.length; i++) { tds[i] = cloneDFServiceDescription(sds[i], df); } } IComponentIdentifier id = source.getName(); // id = cms.createComponentIdentifier(id.getName(), false, id.getAddresses()); id = id!=null ? new BasicComponentIdentifier(id.getName()) : null;//, id.getAddresses()); return df.createDFComponentDescription(id, tds, source.getLanguages(), source.getOntologies(), source.getProtocols(), source.getLeaseTime()); }
/** * Clone the df component description. * @param source The source df component description. * @param df The df service. */ public static IDFComponentDescription cloneDFComponentDescription(IDFComponentDescription source, IComponentManagementService cms, IDF df) { IDFServiceDescription[] sds = source.getServices(); IDFServiceDescription[] tds = null; if(sds!=null) { tds = new IDFServiceDescription[sds.length]; for(int i=0; i<sds.length; i++) { tds[i] = cloneDFServiceDescription(sds[i], df); } } IComponentIdentifier id = source.getName(); // id = cms.createComponentIdentifier(id.getName(), false, id.getAddresses()); id = new ComponentIdentifier(id.getName(), id.getAddresses()); return df.createDFComponentDescription(id, tds, source.getLanguages(), source.getOntologies(), source.getProtocols(), source.getLeaseTime()); }
/** * Modify a component description. * @throws RuntimeException when the component is not registered. */ public IFuture<IDFComponentDescription> modify(IDFComponentDescription cdesc) { Future<IDFComponentDescription> ret = new Future<IDFComponentDescription>(); // Use clone to avoid caller manipulating object after insertion. IDFComponentDescription clone = SFipa.cloneDFComponentDescription(cdesc, cms, this); // Change description, when valid. if(clone.getLeaseTime()==null || clone.getLeaseTime().getTime()>clockservice.getTime()) { // Automatically throws exception, when key does not exist. components.replace(clone.getName(), clone); //System.out.println("modified: "+clone.getName()); ret.setResult(clone); } else { //throw new RuntimeException("Invalid lease time: "+clone.getLeaseTime()); ret.setException(new RuntimeException("Invalid lease time: "+clone.getLeaseTime())); } return ret; }
/** * Modify a component description. * @throws RuntimeException when the component is not registered. */ public IFuture<IDFComponentDescription> modify(IDFComponentDescription cdesc) { Future<IDFComponentDescription> ret = new Future<IDFComponentDescription>(); // Use clone to avoid caller manipulating object after insertion. IDFComponentDescription clone = SFipa.cloneDFComponentDescription(cdesc, cms, this); // Change description, when valid. if(clone.getLeaseTime()==null || clone.getLeaseTime().getTime()>clockservice.getTime()) { // Automatically throws exception, when key does not exist. synchronized(components) { components.replace(clone.getName(), clone); } //System.out.println("modified: "+clone.getName()); ret.setResult(clone); } else { //throw new RuntimeException("Invalid lease time: "+clone.getLeaseTime()); ret.setException(new RuntimeException("Invalid lease time: "+clone.getLeaseTime())); } return ret; }
IDFComponentDescription clone = SFipa.cloneDFComponentDescription(cdesc, cms, this);
IDFComponentDescription clone = SFipa.cloneDFComponentDescription(cdesc, cms, this);
IDFComponentDescription clone = SFipa.cloneDFComponentDescription(cdesc, cms, this);