/** * 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(); } }
/** * 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(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)); } });
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();