/** * Create component identifier. * @param name The local name. * @param parent The parent. * @param addresses The addresses. */ public ComponentIdentifier(String name, IComponentIdentifier parent) { this(name, parent, parent.getAddresses()); }
/** * Copy a component identifier. * @param cid The id to copy from. */ public ComponentIdentifier(IComponentIdentifier cid) { this(cid.getName(), cid.getAddresses()); }
public void customResultAvailable(Object result) { IComponentManagementService cms = (IComponentManagementService)result; nameediting = true; // ComponentIdentifierPanel.this.cid = cms.createComponentIdentifier(tfname.getText(), false, cid.getAddresses()); ComponentIdentifierPanel.this.cid = new ComponentIdentifier(tfname.getText(), cid.getAddresses()); cidChanged(); nameediting = false; } });
public void customResultAvailable(String[] addresses) { IComponentIdentifier[] ret; ret = (IComponentIdentifier[])adapters.keySet().toArray(new IComponentIdentifier[adapters.size()]); if(ret.length>0) { if(!Arrays.equals(ret[0].getAddresses(), addresses)) { // addresses required for inter-platform comm. for(int i=0; i<ret.length; i++) ret[i] = new ComponentIdentifier(ret[i].getName(), addresses); // ret[i] = refreshComponentIdentifier(ret[i]); // Hack! } } fut.setResult(ret); } }));
public void customResultAvailable(String[] addresses) { IComponentIdentifier[] ret; ret = (IComponentIdentifier[])adapters.keySet().toArray(new IComponentIdentifier[adapters.size()]); if(ret.length>0) { if(!Arrays.equals(ret[0].getAddresses(), addresses)) { // addresses required for inter-platform comm. for(int i=0; i<ret.length; i++) ret[i] = new ComponentIdentifier(ret[i].getName(), addresses); // ret[i] = refreshComponentIdentifier(ret[i]); // Hack! } } fut.setResult(ret); } }));
public void customResultAvailable(String[] addresses) { IComponentIdentifier[] ret; synchronized(adapters) { ret = (IComponentIdentifier[])adapters.keySet().toArray(new IComponentIdentifier[adapters.size()]); if(ret.length>0) { if(!Arrays.equals(ret[0].getAddresses(), addresses)) { // addresses required for inter-platform comm. for(int i=0; i<ret.length; i++) ret[i] = new ComponentIdentifier(ret[i].getName(), addresses); // ret[i] = refreshComponentIdentifier(ret[i]); // Hack! } } } fut.setResult(ret); } });
/** * Create a new task. */ public AbstractSendTask(IComponentIdentifier[] receivers, ITransport[] transports, ICodec[] codecs, Map<String, Object> nonfunc) { codecs = codecs==null? new ICodec[0]: codecs; for(int i=0; i<receivers.length; i++) { if(receivers[i].getAddresses()==null) throw new IllegalArgumentException("Addresses must not null"); } codecids = new byte[codecs.length]; for(int i=0; i<codecids.length; i++) codecids[i] = codecs[i].getCodecId(); this.receivers = receivers.clone(); this.transports = new ArrayList<ITransport>(Arrays.asList(transports)); this.codecs = codecs.clone(); this.nonfunc = nonfunc; this.future = new Future<Void>(); }
/** * Create a new task. */ public AbstractSendTask(IComponentIdentifier[] receivers, ITransport[] transports, ICodec[] codecs, Map<String, Object> nonfunc) { codecs = codecs==null? new ICodec[0]: codecs; for(int i=0; i<receivers.length; i++) { if(receivers[i].getAddresses()==null) throw new IllegalArgumentException("Addresses must not null"); } codecids = new byte[codecs.length]; for(int i=0; i<codecids.length; i++) codecids[i] = codecs[i].getCodecId(); this.receivers = receivers.clone(); this.transports = new ArrayList<ITransport>(Arrays.asList(transports)); this.codecs = codecs.clone(); this.nonfunc = nonfunc; this.future = new Future<Void>(); }
public IFuture<Void> execute(IInternalAccess ia) { Map<String, Object> msg = new HashMap<String, Object>(); ComponentIdentifier rec = new ComponentIdentifier("rms@"+cid.getPlatformName(), cid.getAddresses()); msg.put(SFipa.RECEIVERS, new IComponentIdentifier[]{rec}); msg.put(SFipa.CONTENT, "ping"); msg.put(SFipa.PERFORMATIVE, SFipa.QUERY_IF); msg.put(SFipa.CONVERSATION_ID, SUtil.createUniqueId("msg_dis")); getMicroAgent().sendMessageAndWait(msg, SFipa.FIPA_MESSAGE_TYPE, new AbstractMessageHandler(5000, true) { public void handleMessage(Map msg, MessageType type) { // System.out.println("received reply: "+msg); performAnnouncements(cid); } public void timeoutOccurred() { // System.out.println("Received no ping reply, removed: "+cid); announcements.remove(cid); } }); return IFuture.DONE; } });
public void customResultAvailable(IComponentManagementService cms) { if(name.indexOf("@")==-1) { ret.setResult(new ComponentIdentifier(name, parent, parent.getAddresses())); // ret.setResult(cms.createComponentIdentifier(name, parent, parent.getAddresses())); } else { ret.setResult(new ComponentIdentifier(name)); // ret.setResult(cms.createComponentIdentifier(name, false)); } } });
ComponentIdentifier rec = new ComponentIdentifier("rms@"+cid.getPlatformName(), cid.getAddresses()); msg.put(SFipa.RECEIVERS, new IComponentIdentifier[]{rec}); msg.put(SFipa.CONTENT, "ping");
/** * Set the ttpcid. * @param ttpcid The ttpcid to set. */ public void setTTPCid(IComponentIdentifier ttpcid) { if(ttpcid!=null) ttpcid = new ComponentIdentifier(ttpcid.getPlatformPrefix(), ttpcid.getAddresses()); this.ttpcid = ttpcid; getSecurityService().publishEvent(new ChangeEvent<Object>(getClass(), ISecurityService.PROPERTY_MECHANISMPARAMETER, new Object[]{"ttpcid", ttpcid})); }
final IComponentIdentifier rec = node.getDescription().getName(); IComponentIdentifier receiver = new ComponentIdentifier(rec.getName(), rec.getAddresses()); Map message = convcenter.getMessagePanel().getMessage(); MessageType mt = (MessageType)message.get(ConversationPanel.MESSAGE_TYPE);
/** * @param table * @param value * @param isSelected * @param hasFocus * @param row * @param column * @return this * @see javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, Object, boolean, boolean, int, int) */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column); IComponentIdentifier aid = (IComponentIdentifier)value; setText(aid.getName()); String[] addresses = aid.getAddresses(); String tooltip = aid.getName(); for(int i = 0; i < addresses.length; i++) { tooltip += "<br>" + addresses[i]; } setToolTipText("<html>" + tooltip + "</html>"); return this; } }
/** * @see javax.swing.table.DefaultTableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, * Object, boolean, boolean, int, int) */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column); IComponentIdentifier cid = (IComponentIdentifier)value; if(cid!=null) { setText(cid.getName()); String[] addresses = cid.getAddresses(); String tooltip = "<b>" + cid.getName() + "</b>"; if(addresses!=null) { for(int i = 0; i < addresses.length; i++) { tooltip += "<br>" + addresses[i]; } } setToolTipText("<html>" + tooltip + "</html>"); } return this; } }
/** * Update the ui, when the aid has changed. */ protected void refresh() { // Update the gui. if(!nameediting) { // tfname.getDocument().removeDocumentListener(namelistener); tfname.setText(this.cid.getName()); // tfname.getDocument().addDocumentListener(namelistener); } taddresses.setEntries(this.cid.getAddresses()); taddresses.refresh(); this.invalidate(); this.validate(); this.repaint(); }
/** * */ protected void addSelected() { if(!isTreeViewSelectionEmpty()) { IComponentIdentifier cid = getSelectedObject(); if(cid!=null) { addSelectedAgent(new ComponentIdentifier(cid.getName(), cid.getAddresses()), list); } } }
String[] addrs = ((IComponentIdentifier)ad.getName()).getAddresses(); // Hack!!! String tooltip = "<html>" + ad.getName().getName(); for(int addr = 0; addr < addrs.length; addr++)
/** * Set the description. */ public void setDescription(IComponentDescription desc) { getTextField("Name").setText(desc.getName().getName()); getTextField("Type").setText(desc.getType()); getTextField("Model name").setText(desc.getModelName()); getTextField("Creator").setText(desc.getCreator()!=null? desc.getCreator().getName(): "n/a"); getTextField("Ownership").setText(desc.getOwnership()); getTextField("State").setText(desc.getState()); String gid = desc.getResourceIdentifier().getGlobalIdentifier()!=null? desc.getResourceIdentifier().getGlobalIdentifier().getResourceId(): "n/a"; ILocalResourceIdentifier lid = desc.getResourceIdentifier().getLocalIdentifier(); getTextField("Resource Identifier").setText(gid==null? "n/a": gid); getTextField("(global / local)").setText(lid==null? "n/a": lid.toString()); // getTextField("Processing state").setText(desc.getProcessingState()); getCheckBox("Master").setSelected(desc.getMaster()==null? false: desc.getMaster().booleanValue()); getCheckBox("Daemon").setSelected(desc.getDaemon()==null? false: desc.getDaemon().booleanValue()); getCheckBox("Auto shutdown").setSelected(desc.getAutoShutdown()==null? false: desc.getAutoShutdown().booleanValue()); JTable list = (JTable)getComponent("Addresses"); String[] addresses = desc.getName().getAddresses(); DefaultTableModel dtm = new DefaultTableModel(); dtm.addColumn("Addresses", addresses!=null?addresses:SUtil.EMPTY_STRING_ARRAY); list.setModel(dtm); } }
/** * 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()); }