/** * Start the service. * @return A future that is done when the service has completed starting. */ public IFuture<Void> start() { final Future<Void> ret = new Future<Void>(); // System.out.println("search clock: "+getId()); SServiceProvider.getServiceUpwards(ComponentServiceContainer.this, IComponentManagementService.class) .addResultListener(new ExceptionDelegationResultListener<IComponentManagementService, Void>(ret) { public void customResultAvailable(IComponentManagementService result) { cms = result; // System.out.println("Has cms: "+getId()+" "+cms); // Services may need other services and thus need to be able to search // the container. ComponentServiceContainer.super.start().addResultListener(new DelegationResultListener<Void>(ret)); } }); return ret; }
SServiceProvider.getServiceUpwards(provider, IComponentManagementService.class) .addResultListener(new ExceptionDelegationResultListener<IComponentManagementService, T>(ret)
/** * Get the (cached) cms. */ protected IFuture<IComponentManagementService> getCMS() { // Change comments below to test performance of cached cms vs. direct access. if(getServiceContainer()==null) { System.out.println("container is null: "+component+", "+getComponentIdentifier()); } // return SServiceProvider.getServiceUpwards(getServiceContainer(), IComponentManagementService.class); if(cms==null || cms.getException()!=null) { cms = SServiceProvider.getServiceUpwards(getServiceContainer(), IComponentManagementService.class); } return cms; }
SServiceProvider.getServiceUpwards(provider, IComponentManagementService.class) .addResultListener(new ExceptionDelegationResultListener<IComponentManagementService, T>(ret)
SServiceProvider.getServiceUpwards(provider, IThreadPoolService.class) .addResultListener(new DelegationResultListener(ret)
/** * Execute the task. */ public IFuture<Void> execute(final ITaskContext context, final IInternalAccess process) { final Future<Void> ret = new Future<Void>(); IFuture<IClockService> clockfut = SServiceProvider.getServiceUpwards(process.getServiceContainer(), IClockService.class); clockfut.addResultListener(new IResultListener<IClockService>() { public void resultAvailable(final IClockService clock) { ((BpmnInterpreter) process).getComponentAdapter().invokeLater(new Runnable() { public void run() { context.setParameterValue("time", Long.valueOf(clock.getTime())); ret.setResult(null); } }); } public void exceptionOccurred(Exception exception) { ret.setException(exception); } }); return ret; }
SServiceProvider.getServiceUpwards(getServiceContainer(), IComponentManagementService.class) .addResultListener(new ExceptionDelegationResultListener<IComponentManagementService, Collection<IExternalAccess>>(ret)
SServiceProvider.getServiceUpwards(component.getServiceContainer(), IComponentManagementService.class) .addResultListener(new ExceptionDelegationResultListener<IComponentManagementService, Collection<IExternalAccess>>(ret)
cms = SServiceProvider.getServiceUpwards(getServiceContainer(), IComponentManagementService.class); cms.addResultListener(new IResultListener<IComponentManagementService>()
SServiceProvider.getServiceUpwards(access.getServiceContainer(), IThreadPoolService.class) .addResultListener(access.createResultListener(new DelegationResultListener(fut)
SServiceProvider.getServiceUpwards(jcc.getJCCAccess().getServiceProvider(), IComponentManagementService.class) .addResultListener(new ExceptionDelegationResultListener<IComponentManagementService, ClassLoader>(ret)
/** * Get the thread pool. */ protected IFuture<IThreadPool> getThreadPool() { final Future<IThreadPool> ret = new Future<IThreadPool>(); if(tp==null) { // SServiceProvider.getServiceUpwards(treepanel.localexta.getServiceProvider(), IDaemonThreadPoolService.class) SServiceProvider.getServiceUpwards(treepanel.getGUIExternalAccess().getServiceProvider(), IDaemonThreadPoolService.class) .addResultListener(new SwingDefaultResultListener<IDaemonThreadPoolService>() { public void customResultAvailable(IDaemonThreadPoolService result) { tp = result; ret.setResult(tp); } }); } else { ret.setResult(tp); } return ret; }
/** * Get the thread pool. */ protected IFuture<IThreadPool> getThreadPool() { final Future<IThreadPool> ret = new Future<IThreadPool>(); if(tp==null) { SServiceProvider.getServiceUpwards(jcc.getJCCAccess().getServiceProvider(), IDaemonThreadPoolService.class) .addResultListener(new SwingDefaultResultListener<IDaemonThreadPoolService>() { public void customResultAvailable(IDaemonThreadPoolService result) { tp = result; ret.setResult(tp); } }); } else { ret.setResult(tp); } return ret; }
SServiceProvider.getServiceUpwards(agent.getServiceProvider(), IMessageService.class) .addResultListener(agent.createResultListener(new ExceptionDelegationResultListener<IMessageService, Void>(ret)
SServiceProvider.getServiceUpwards(getServiceContainer(), IComponentManagementService.class) .addResultListener(createResultListener(new ExceptionDelegationResultListener<IComponentManagementService, IComponentIdentifier>(ret)
/** * */ public static void main(String[] args) { String[] pargs = new String[] { "-gui", "false" }; IExternalAccess rootcomp = (IExternalAccess)Starter.createPlatform(pargs).get(new ThreadSuspendable()); IComponentManagementService cms = (IComponentManagementService)SServiceProvider.getServiceUpwards(rootcomp.getServiceProvider(), IComponentManagementService.class).get(new ThreadSuspendable()); dorun(cms, "jadex/micro/testcases/blocking/ShutdownAgent.class"); // dorun(cms, "jadex/micro/benchmarks/MessagePerformanceAgent.class"); // dorun(cms, "jadex/micro/examples/ping/PingScenario.application.xml"); } }
SServiceProvider.getServiceUpwards(agent.getServiceProvider(), IMessageService.class) .addResultListener(agent.createResultListener(new ExceptionDelegationResultListener<IMessageService, Void>(ret)
public void customResultAvailable(Object result) SServiceProvider.getServiceUpwards(provider, IComponentManagementService.class) .addResultListener(new DelegationResultListener(ret)
ConfigurationInfo conf = model.getConfiguration(config); final ComponentInstanceInfo[] components = conf.getComponentInstances(); SServiceProvider.getServiceUpwards(getServiceContainer(), IComponentManagementService.class) .addResultListener(createResultListener(new ExceptionDelegationResultListener<IComponentManagementService, Void>(ret)
/** * Get one service of a type and only search upwards (parents). * @param type The class. * @return The corresponding service. */ public <T> IFuture<T> searchServiceUpwards(final Class<T> type) { if(shutdowned) { return new Future<T>(new ComponentTerminatedException(id)); } final Future<T> fut = new Future<T>(); SServiceProvider.getServiceUpwards(this, type).addResultListener(new DelegationResultListener(fut) { public void customResultAvailable(Object result) { if(shutdowned) { fut.setException(new ComponentTerminatedException(id)); } else { fut.setResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(instance, instance.getExternalAccess(), adapter, (IService)result, null, new RequiredServiceInfo(type), null, realtime)); } } }); return (IFuture<T>)FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(instance.getExternalAccess(), adapter)); }