/** * Find a component factory for loading a specific component type. * @param type The component type. */ public ComponentFactorySelector(String type) { super(new FactoryFilter(type)); }
/** * Find a matching component factory. * @param model The model to be loaded. * @param imports The imports (if any). * @param classloader The class loader (if any). */ public ComponentFactorySelector(String model, String[] imports, IResourceIdentifier rid) { super(new FactoryFilter(model, imports, rid)); }
/** * Execute the functional body of the agent. * Is only called once. */ @AgentBody public void executeBody() { // IFuture<IComponentFactory> factory = SServiceProvider.getService(agent.getServiceContainer(), // new ComponentFactorySelector(MicroAgentFactory.FILETYPE_MICROAGENT)); IFuture<IComponentFactory> factory = SServiceProvider.getService(agent, IComponentFactory.class, RequiredServiceInfo.SCOPE_PLATFORM, new FactoryFilter(MicroAgentFactory.FILETYPE_MICROAGENT)); //factory.addResultListener(agent.getCompocreateResultListener(new IResultListener<IComponentFactory>() factory.addResultListener(new IResultListener<IComponentFactory>() { public void resultAvailable(IComponentFactory result) { System.out.println("Found: "+result); } public void exceptionOccurred(Exception e) { System.out.println("Not found: "+e); } }); } }
public void customResultAvailable(final ILibraryService ls) { IFuture<IComponentFactory> fut = SServiceProvider.getService(agent, IComponentFactory.class, RequiredServiceInfo.SCOPE_PLATFORM, new FactoryFilter(filename, null, rid)); fut.addResultListener(createResultListener(new ExceptionDelegationResultListener<IComponentFactory, IModelInfo>(ret) { public void customResultAvailable(IComponentFactory factory) { factory.loadModel(filename, null, rid) .addResultListener(new DelegationResultListener<IModelInfo>(ret)); } public void exceptionOccurred(Exception exception) { if(exception instanceof ServiceNotFoundException) { ret.setResult(null); } else { super.exceptionOccurred(exception); } } })); } }));
IFuture<IComponentFactory> fut = getFactory(new FactoryFilter(model, null, rid), ia); fut.addResultListener(ia.getComponentFeature(IExecutionFeature.class).createResultListener(new ExceptionDelegationResultListener<IComponentFactory, Boolean>(ret)
IFuture<IComponentFactory> fut = getFactory(new FactoryFilter(model, null, rid), ia); fut.addResultListener(ia.getComponentFeature(IExecutionFeature.class).createResultListener(new ExceptionDelegationResultListener<IComponentFactory, IModelInfo>(ret)
getFactory(new FactoryFilter(model, null, rid), ia) .addResultListener(ia.getComponentFeature(IExecutionFeature.class).createResultListener(new ExceptionDelegationResultListener<IComponentFactory, Boolean>(ret)