/** * Is in application when target can be traced back to app. */ protected boolean isInApplication(IComponentIdentifier start, IComponentIdentifier target) { boolean ret = false; IComponentIdentifier app = start; while(app.getParent()!=null && app.getParent().getParent()!=null) { app = app.getParent(); } IComponentIdentifier tmp = target; while(tmp!=null) { if(tmp.equals(app)) { ret = true; break; } tmp = tmp.getParent(); } return ret; }
/** * Get the "semi-qualified" sub name for settings. */ protected String getSubname() { String subname = null; IComponentIdentifier cid = agent.getComponentIdentifier(); while(cid.getParent()!=null) { subname = subname==null ? cid.getLocalName() : subname+"."+cid.getLocalName(); cid = cid.getParent(); } return subname; }
/** * Get the "semi-qualified" sub name for settings. */ protected String getSubname() { String subname = null; IComponentIdentifier cid = agent.getComponentIdentifier(); while(cid.getParent()!=null) { subname = subname==null ? cid.getLocalName() : subname+"."+cid.getLocalName(); cid = cid.getParent(); } return subname; }
/** * Get the parent component of a component. * @param cid The component identifier. * @return The parent component identifier. */ public IFuture<IComponentIdentifier> getParent(final IComponentIdentifier cid) { // final Future<IComponentIdentifier> ret = new Future<IComponentIdentifier>(); // if(isRemoteComponent(cid)) // { // getRemoteCMS(cid).addResultListener(createResultListener(new ExceptionDelegationResultListener<IComponentManagementService, IComponentIdentifier>(ret) // { // public void customResultAvailable(IComponentManagementService rcms) // { // rcms.getParent(cid).addResultListener(createResultListener(new DelegationResultListener<IComponentIdentifier>(ret))); // } // })); // } // else // { // CMSComponentDescription desc = (CMSComponentDescription)getDescription(cid); // ret.setResult(desc!=null? desc.getName().getParent(): null); // } // return ret; return new Future<IComponentIdentifier>(cid.getParent()); }
/** * Get the parent component of a component. * @param cid The component identifier. * @return The parent component identifier. */ public IFuture<IComponentIdentifier> getParent(final IComponentIdentifier cid) { // final Future<IComponentIdentifier> ret = new Future<IComponentIdentifier>(); // if(isRemoteComponent(cid)) // { // getRemoteCMS(cid).addResultListener(createResultListener(new ExceptionDelegationResultListener<IComponentManagementService, IComponentIdentifier>(ret) // { // public void customResultAvailable(IComponentManagementService rcms) // { // rcms.getParent(cid).addResultListener(createResultListener(new DelegationResultListener<IComponentIdentifier>(ret))); // } // })); // } // else // { // CMSComponentDescription desc = (CMSComponentDescription)getDescription(cid); // ret.setResult(desc!=null? desc.getName().getParent(): null); // } // return ret; return new Future<IComponentIdentifier>(cid.getParent()); }
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; }
public static String getLoggerName(IComponentIdentifier cid) { //String name = getComponentIdentifier().getLocalName(); //String name = getModel().getFullName()+"."+getComponentIdentifier().getLocalName(); // Prepend parent names for nested loggers. String name = null; for(; cid!=null; cid=cid.getParent()) { name = name==null ? cid.getLocalName() : cid.getLocalName() + "." +name; } // System.out.println("logname: "+name); return name; }
/** * Get the logger name. * @param cid The component identifier. * @return The name. */ 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; }
/** * 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); } } } }
/** * 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); } } } } }
/** * Check if no agent is running whenever the clock advances. */ protected static void monitorExecution(IExternalAccess ea, IExecutionService exe) { // System.out.println("Monitoring execution..."); IExecutable[] tasks = exe.getRunningTasks(); for(IExecutable task: tasks) { // Only print warning for sub-components if(task instanceof ExecutionComponentFeature) { IComponentIdentifier cid = ((ExecutionComponentFeature)task).getComponent().getComponentIdentifier(); IComponentIdentifier test = cid; while(test!=null && !test.equals(ea.getComponentIdentifier())) { test = test.getParent(); } if(test!=null && !cid.equals(ea.getComponentIdentifier())) { System.out.println("Non-idle component at time switch: "+cid); } } } } }
/** * Get the component property provider. */ public INFPropertyProvider getComponentPropertyProvider() { if(compprovider==null) { this.compprovider = new NFPropertyProvider(getComponent().getComponentIdentifier().getParent(), getComponent()); } return compprovider; }
public void resultAvailable(IComponentManagementService cms) { cms.getComponentAdapter(getComponentIdentifier().getParent()) .addResultListener(new DefaultResultListener<IComponentAdapter>() { public void resultAvailable(IComponentAdapter result) { parenta = (StandaloneComponentAdapter)result; parenta.addSubcomponent(StandaloneComponentAdapter.this); parenta.wakeup(); } public void exceptionOccurred(Exception exception) { exception.printStackTrace(); } }); } });
/** * Called from cleanupComponent. */ public IFuture<Void> terminateServiceContainer() { final Future<Void> ret = new Future<Void>(); IResultListener<Void> reslis = new IResultListener<Void>() { public void resultAvailable(Void result) { nosteps = true; exitState(); ret.setResult(result); } public void exceptionOccurred(final Exception exception) { nosteps = true; exitState(); ret.setException(exception); } }; // If platform, do not schedule listener on component as execution service already terminated after terminate service container. if(getComponentIdentifier().getParent()!=null) reslis = createResultListener(reslis); super.terminateServiceContainer().addResultListener(reslis); return ret; }
IComponentIdentifier parent = RequiredServiceInfo.SCOPE_PARENT.equals(binding.getScope())? ((IComponentIdentifier)provider.getId()).getParent(): (IComponentIdentifier)provider.getId(); getExternalAccess(provider, binding.getComponentName(), parent).addResultListener(new DelegationResultListener<IExternalAccess>(ret)
IComponentIdentifier parent = RequiredServiceInfo.SCOPE_PARENT.equals(binding.getScope())? provider.getComponentIdentifier().getParent(): provider.getComponentIdentifier(); getExternalAccess(provider, binding.getComponentName(), parent).addResultListener(new DelegationResultListener<IExternalAccess>(ret)
/** * Get the parent component of a component. * @param cid The component identifier. * @return The parent component identifier. */ public IFuture<IComponentIdentifier> getParent(final IComponentIdentifier cid) { final Future<IComponentIdentifier> ret = new Future<IComponentIdentifier>(); if(isRemoteComponent(cid)) { getRemoteCMS(cid).addResultListener(new ExceptionDelegationResultListener<IComponentManagementService, IComponentIdentifier>(ret) { public void customResultAvailable(IComponentManagementService rcms) { rcms.getParent(cid).addResultListener(new DelegationResultListener<IComponentIdentifier>(ret)); } }); } else { CMSComponentDescription desc = (CMSComponentDescription)getDescription(cid); ret.setResult(desc!=null? desc.getName().getParent(): null); } return ret; }
/** * Get the parent component of a component. * @param cid The component identifier. * @return The parent component identifier. */ public IFuture<IComponentIdentifier> getParent(final IComponentIdentifier cid) { final Future<IComponentIdentifier> ret = new Future<IComponentIdentifier>(); if(isRemoteComponent(cid)) { getRemoteCMS(cid).addResultListener(createResultListener(new ExceptionDelegationResultListener<IComponentManagementService, IComponentIdentifier>(ret) { public void customResultAvailable(IComponentManagementService rcms) { rcms.getParent(cid).addResultListener(createResultListener(new DelegationResultListener<IComponentIdentifier>(ret))); } })); } else { CMSComponentDescription desc = (CMSComponentDescription)getDescription(cid); ret.setResult(desc!=null? desc.getName().getParent(): null); } return ret; }
public void body() { IComponentManagementService cms = getAgent().getComponentFeature(IRequiredServicesFeature.class) .searchService(IComponentManagementService.class, RequiredServiceInfo.SCOPE_PLATFORM).get(); Environment en = (Environment)getBeliefbase().getBelief("environment").getFact(); Creature[] creatures = en.getCreatures(); Future<Void> destroyed = new Future<Void>(); IResultListener<Map<String, Object>> lis = new CounterResultListener<Map<String, Object>>(creatures.length, new DelegationResultListener<Void>(destroyed)); for(int i = 0; i < creatures.length; i++) { // System.out.println(creatures[i].getAID()); en.removeCreature(creatures[i]); cms.destroyComponent(creatures[i].getAID()).addResultListener(lis); } destroyed.get(); cms.destroyComponent(getScope().getComponentIdentifier().getParent()); } }