/** * Update component identifier. * @param cid The component identifier. * @return The component identifier. */ public IComponentIdentifier internalUpdateComponentIdentifier(IComponentIdentifier cid) { ComponentIdentifier ret = null; if(cid.getPlatformName().equals(component.getComponentIdentifier().getRoot().getLocalName())) { ret = new ComponentIdentifier(cid.getName(), internalGetAddresses()); // System.out.println("Rewritten cid: "+ret+" :"+SUtil.arrayToString(ret.getAddresses())); } return ret==null? cid: ret; }
public static String getLoggerName(IComponentIdentifier cid) { // Prepend parent names for nested loggers. String name = null; for(; cid!=null; cid=cid.getParent()) { name = name==null ? cid.getLocalName() : cid.getLocalName() + "." +name; } return name; }
/** * Get the certificate of a platform. * @param cid The platform component identifier (null for own certificate). * @return The certificate. */ public IFuture<Certificate> getPlatformCertificate(IComponentIdentifier cid) { return getCertificate(cid==null? null: cid.getPlatformPrefix()); }
/** * Copy a component identifier. * @param cid The id to copy from. */ public ComponentIdentifier(IComponentIdentifier cid) { this(cid.getName(), cid.getAddresses()); }
/** * Test if a call is remote. */ public boolean isRemoteCall() { return caller==null? false: !caller.getRoot().equals(platform) || (caller.getLocalName().equals("rms") && caller.getRoot().equals(platform)); // Hack? Shouldn't be caller be set to the remote component? }
/** * Test if a call is remote. */ public boolean isRemoteCall() { return caller==null? false: !caller.getRoot().equals(platform); }
/** * Shutdown the rescue thread of a platform. */ public static synchronized void shutdownRescueThread(IComponentIdentifier cid) { assert cid.getParent()==null : cid; Tuple2<BlockingQueue, Thread> tup = rescuethreads==null? null: rescuethreads.remove(cid.getRoot()); if(tup!=null) { List<Runnable> steps = tup.getFirstEntity().setClosed(true); for(Runnable next: steps) { try { next.run(); } catch(Exception e) { Logger.getLogger(cid.getLocalName()).severe("Exception during step on rescue thread: "+e); } } } }
/** * Create a string representation. */ public String toString() { return cid==null? desc.getName().getLocalName(): desc.getName().getLocalName()+"("+cid+")"; }
/** * Create an component termination exception. */ public ComponentTerminatedException(IComponentIdentifier cid) { super(cid.getName()); this.cid = cid; }
/** * Test if a component identifier is a remote component. */ protected boolean isRemoteComponent(IComponentIdentifier cid) { return !cid.getPlatformName().equals(root.getComponentIdentifier().getName()); }
public void intermediateResultAvailable(final ISecurityService ss) { if(!found && ((IService)ss).getServiceIdentifier().getProviderId().getPlatformPrefix().equals(ttpcid.getName())) { found = true; verifyTTP(ss).addResultListener(new ExceptionDelegationResultListener<Void, ISecurityService>(ret) { public void customResultAvailable(Void result) { ret.setResult(ss); } }); } }
/** * Test if a target is a remote component. */ protected boolean isSamePlatform(IComponentIdentifier source, IComponentIdentifier target) { return source==null || (target!=null && source.getPlatformName().equals(target.getPlatformName())); } }
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; } });
/** * 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})); }
/** * 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()); }
/** * Get a global platform value. * @param platform The platform name. */ public static synchronized void removePlatformMemory(IComponentIdentifier platform) { platformmem.remove(platform.getRoot()); }
/** * Shutdown the rescue thread of a platform. */ public static synchronized void shutdownRescueThread(IComponentIdentifier cid) { assert cid.getParent()==null : cid; Tuple2<BlockingQueue, Thread> tup = rescuethreads==null? null: rescuethreads.remove(cid.getRoot()); if(tup!=null) { List<Runnable> steps = tup.getFirstEntity().setClosed(true); for(Runnable next: steps) { try { next.run(); } catch(Exception e) { Logger.getLogger(cid.getLocalName()).severe("Exception during step on rescue thread: "+e); } } } } }
/** * Get the agent name. * @return The agent name. */ public String getAgentName() { return agent.getComponentIdentifier().getLocalName(); }
/** * @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; } }