public void customResultAvailable(IComponentManagementService cms) { cms.createComponent(name, type, new CreationInfo(configname, arguments, parco, suspend, master, daemon, autosd, moni, sync, null, null, rid), killlistener) .addResultListener(new IResultListener() { public void resultAvailable(Object result) { ret.setResult(result); jcc.setStatusText("Created component: " + ((IComponentIdentifier)result).getLocalName()); } public void exceptionOccurred(Exception exception) { ret.setException(exception); // exception.printStackTrace(); jcc.displayError("Problem Starting Component", "Component could not be started.", exception); } }); } });
/** * Create a new creation info. */ public CreationInfo(CreationInfo info) { if(info!=null) { this.config = info.getConfiguration(); this.args = info.getArguments(); this.parent = info.getParent(); this.suspend = info.getSuspend(); this.master = info.getMaster(); this.daemon = info.getDaemon(); this.autoshutdown = info.getAutoShutdown(); this.monitoring = info.getMonitoring(); this.synchronous = info.getSynchronous(); this.imports = info.getImports(); this.bindings = info.getRequiredServiceBindings(); this.rid = info.getResourceIdentifier(); this.localtype = info.getLocalType(); } }
/** * Manually connects to a remote platform. * * @param platformname Name of the platform. * @param remoteaddr Transport URL. */ public static final void connectPlatform(IInternalAccess component, String platformname, String remoteaddr) { // Address of remote platform IComponentIdentifier remotecid = new ComponentIdentifier(platformname, new String[]{remoteaddr}); // Create proxy for remote platform such that remote services are found Map<String, Object> args = new HashMap<String, Object>(); args.put("component", remotecid); CreationInfo ci = new CreationInfo(args); ci.setDaemon(true); IComponentManagementService cms = SServiceProvider.getLocalService(component, IComponentManagementService.class, Binding.SCOPE_PLATFORM); cms.createComponent(platformname, "jadex/platform/service/remote/ProxyAgent.class", ci).getFirstResult(); } }
if(ci!=null && ci.getResourceIdentifier()!=null) ret.setResult(ci.getResourceIdentifier()); && (ci.getParent()==null || !isRemoteComponent(ci.getParent())) getExternalAccess(ci.getParent()==null? root.getComponentIdentifier(): ci.getParent(), true) .addResultListener(new ExceptionDelegationResultListener<IExternalAccess, IResourceIdentifier>(ret)
(CreationInfo)thread.getPropertyValue("creation info"): new CreationInfo(); if(info.getArguments()==null && args.size()>0) info.setArguments(args); if(info.getParent()==null && parent!=null) info.setParent(parent); if(info.getImports()==null && imps!=null) info.setImports(imps);
final Future<Void> resfut = new Future<Void>(); final CreationInfo cinfo = new CreationInfo(info); // Dummy default info, if null. Must be cloned as localtype is set on info later. if(cinfo.getParent()!=null) LockEntry kt = lockentries.get(cinfo.getParent()); if(kt==null) kt= new LockEntry(cinfo.getParent()); lockentries.put(cinfo.getParent(), kt); if(cinfo.getParent()!=null && isRemoteComponent(cinfo.getParent())) getRemoteCMS(cinfo.getParent()).addResultListener( new ExceptionDelegationResultListener<IComponentManagementService, IComponentIdentifier>(inited)
public void customResultAvailable(final IComponentManagementService cms) { // IResourceIdentifier rid = new ResourceIdentifier( // new LocalResourceIdentifier(root, agent.getModel().getResourceIdentifier().getLocalIdentifier().getUri()), null); boolean local = root.equals(agent.getComponentIdentifier().getRoot()); CreationInfo ci = new CreationInfo(local? agent.getComponentIdentifier(): root, agent.getModel().getResourceIdentifier()); ci.setArguments(args); ci.setConfiguration(config); cms.createComponent(null, filename, ci, reslis) .addResultListener(new DelegationResultListener<IComponentIdentifier>(ret) { public void customResultAvailable(IComponentIdentifier result) { super.customResultAvailable(result); } public void exceptionOccurred(Exception exception) { exception.printStackTrace(); super.exceptionOccurred(exception); } }); } });
public void customResultAvailable(IComponentIdentifier parent) { CreationInfo ci = new CreationInfo(args); ci.setDaemon(true); ci.setParent(parent); // System.out.println("create proxy: "+(++cnt)); cms.createComponent(dif.getComponentIdentifier().getLocalName(), "jadex/platform/service/remote/ProxyAgent.class", ci, createResultListener(new DefaultResultListener<Collection<Tuple2<String, Object>>>(getLogger()) { public void resultAvailable(Collection<Tuple2<String, Object>> result) { // System.out.println("Proxy killed: "+source); dif.setProxy(null); informListeners(dif); } public void exceptionOccurred(Exception exception) { if(!(exception instanceof ComponentTerminatedException)) super.exceptionOccurred(exception); } })).addResultListener(new DelegationResultListener<IComponentIdentifier>(ret)); } });
public void run() { try { ThreadSuspendable sus = new ThreadSuspendable(); CreationInfo ci = new CreationInfo("created", null); ci.setParent(agent.getComponentIdentifier()); ci.setResourceIdentifier(agent.getModel().getResourceIdentifier()); final String name = TesterAgent.class.getName()+".class"; IComponentIdentifier ida = cms.createComponent(name, ci).getFirstResult(); IComponentIdentifier idb = cms.createComponent(name, ci).getFirstResult(); IComponentDescription desca = cms.getComponentDescription(ida).get(); IComponentDescription descb = cms.getComponentDescription(ida).get(); System.out.println("chain a: "+ida+" "+desca.getCause().getOrigin()); System.out.println("chain b: "+idb+" "+descb.getCause().getOrigin()); } catch(ComponentTerminatedException e) { // avoid exception being printed during start test. } } }).start();
public void customResultAvailable(Object result) { IComponentManagementService cms = (IComponentManagementService)result; Map args = new HashMap(); args.put("timeout", timeout); // Todo: Use remote component for parent if any CreationInfo ci = new CreationInfo(args, plugin.getJCC().getPlatformAccess().getComponentIdentifier()); ci.setResourceIdentifier(name.getSecondEntity()); cms.createComponent(null, name.getFirstEntity(), ci, res) .addResultListener(new SwingDelegationResultListener(ret)); // Todo: timeout -> force destroy of component } });
CreationInfo ci = new CreationInfo("donothing", null, getComponentIdentifier()); ci.setSuspend(Boolean.TRUE); IComponentIdentifier cid = (IComponentIdentifier)cms.createComponent(null, "jadex/bdi/testcases/misc/Flag.agent.xml", ci , null).get(); IComponentDescription desc = (IComponentDescription)cms.getComponentDescription(cid).get(); ci = new CreationInfo("donothing", null, getComponentIdentifier()); ci.setMaster(Boolean.TRUE); cid = (IComponentIdentifier)cms.createComponent(null, "jadex/bdi/testcases/misc/Flag.agent.xml", ci , null).get(); desc = (IComponentDescription)cms.getComponentDescription(cid).get(); ci = new CreationInfo("donothing", null, getComponentIdentifier()); ci.setDaemon(Boolean.TRUE); cid = (IComponentIdentifier)cms.createComponent(null, "jadex/bdi/testcases/misc/Flag.agent.xml", ci , null).get(); desc = (IComponentDescription)cms.getComponentDescription(cid).get(); ci = new CreationInfo("donothing", null, getComponentIdentifier()); ci.setAutoShutdown(Boolean.TRUE); cid = (IComponentIdentifier)cms.createComponent(null, "jadex/bdi/testcases/misc/Flag.agent.xml", ci , null).get(); desc = (IComponentDescription)cms.getComponentDescription(cid).get(); ci = new CreationInfo("suspend", null, getComponentIdentifier()); cid = (IComponentIdentifier)cms.createComponent(null, "jadex/bdi/testcases/misc/Flag.agent.xml", ci , null).get(); desc = (IComponentDescription)cms.getComponentDescription(cid).get(); ci = new CreationInfo("master", null, getComponentIdentifier()); cid = (IComponentIdentifier)cms.createComponent(null, "jadex/bdi/testcases/misc/Flag.agent.xml", ci , null).get(); desc = (IComponentDescription)cms.getComponentDescription(cid).get(); ci = new CreationInfo("daemon", null, getComponentIdentifier());
/** * Get the parent component of a component. * @param cid The component identifier. * @return The parent component identifier. */ public IComponentIdentifier getParentIdentifier(CreationInfo ci) { IComponentIdentifier rt = root.getComponentIdentifier(); IComponentIdentifier ret = ci==null? rt: ci.getParent()==null? rt: ci.getParent(); // System.out.println("parent id: "+ret); return ret; }
boolean debugging = lmodel.getSuspend(cinfo.getConfiguration())==null? false: lmodel.getSuspend(cinfo.getConfiguration()).booleanValue(); boolean sus = cinfo.getSuspend()==null? false: cinfo.getSuspend().booleanValue(); boolean suspend = sus || pasuspend || debugging; return suspend;
componentfactory.isLoadable(model, cinfo.getImports(), rid) .addResultListener(new ExceptionDelegationResultListener<Boolean, IComponentFactory>(ret)
if(cinfo.getParent()!=null) String localtype = modelname!=null ? modelname : cinfo.getLocalType(); filename = null; IInternalAccess pad = getParentComponent(cinfo); cinfo.setLocalType(localtype); if(cinfo.getLocalType()==null && subcomps.length>0) cinfo.setLocalType((String)localtypes.get(key)); if(info!=null) for(int i=0; cinfo.getLocalType()==null && i<subcomps.length; i++) cinfo.setLocalType(subcomps[i].getName()); localtypes.put(key, cinfo.getLocalType());
final Future<Void> resfut = new Future<Void>(); final CreationInfo cinfo = new CreationInfo(info); // Dummy default info, if null. Must be cloned as localtype is set on info later. if(cinfo.getParent()!=null) LockEntry kt = lockentries.get(cinfo.getParent()); if(kt==null) kt= new LockEntry(cinfo.getParent()); lockentries.put(cinfo.getParent(), kt); if(cinfo.getParent()!=null && isRemoteComponent(cinfo.getParent())) getRemoteCMS(cinfo.getParent()).addResultListener(createResultListener( new ExceptionDelegationResultListener<IComponentManagementService, IComponentIdentifier>(inited)
CreationInfo info = new CreationInfo(getComponentIdentifier()); info.setConfiguration(getConfiguration()); Map args = new HashMap(); args.put("delay", getArgument("delay")); info.setArguments(args); for(int i=0; i<mechas.length; i++)
/** * Create the platform proxy holder component. * (Can be called multiple times). */ protected IFuture<IComponentIdentifier> createProxyHolder() { if(pcreatefut!=null) { return pcreatefut; } else { pcreatefut = new Future<IComponentIdentifier>(); CreationInfo ci = new CreationInfo(getComponentIdentifier().getRoot()); ci.setDaemon(Boolean.TRUE); cms.createComponent("platforms", RemotePlatformAgent.class.getName()+".class", ci, null) .addResultListener(new DelegationResultListener<IComponentIdentifier>(pcreatefut)); } return pcreatefut; }
public void customResultAvailable(Object result) { IComponentManagementService cms = (IComponentManagementService)result; Map args = new HashMap(); args.put("timeout", timeout); // Todo: Use remote component for parent if any CreationInfo ci = new CreationInfo(args, plugin.getJCC().getPlatformAccess().getComponentIdentifier()); ci.setResourceIdentifier(name.getSecondEntity()); cms.createComponent(null, name.getFirstEntity(), ci, res) .addResultListener(new SwingDelegationResultListener(ret)); // Todo: timeout -> force destroy of component } });
if(ci!=null && ci.getResourceIdentifier()!=null) ret.setResult(ci.getResourceIdentifier()); && (ci.getParent()==null || !isRemoteComponent(ci.getParent())) getExternalAccess(ci.getParent()==null? root.getComponentIdentifier(): ci.getParent(), true) .addResultListener(createResultListener(new ExceptionDelegationResultListener<IExternalAccess, IResourceIdentifier>(ret)