/** * Create a service proxy for registering a provided service. */ public IInternalService createInternalService(Object service, Class<?> type) { // boolean moni = getComponentDescription().getMonitoring()!=null? getComponentDescription().getMonitoring().booleanValue(): false; PublishEventLevel elm = getComponentDescription().getMonitoring()!=null? getComponentDescription().getMonitoring(): null; // todo: remove this? currently the level cannot be turned on due to missing interceptor boolean moni = elm!=null && !PublishEventLevel.OFF.equals(elm); IInternalService is = BasicServiceInvocationHandler.createProvidedServiceProxy( getInternalAccess(), getComponentAdapter(), service, null, type, BasicServiceInvocationHandler.PROXYTYPE_DECOUPLED, null, isCopy(), isRealtime(), getModel().getResourceIdentifier(), moni, null); return is; }
public void customResultAvailable(Void result) { initProvidedServices(i+1, services, model) .addResultListener(createResultListener(new DelegationResultListener<Void>((Future<Void>)ret))); } }));
public void customResultAvailable(Void result) { // Start service container. startServiceContainer().addResultListener(createResultListener(new DelegationResultListener(ret))); } }));
/** * Create an external access. */ public ExternalAccess(StatelessAbstractInterpreter interpreter) { this.interpreter = interpreter; this.adapter = interpreter.getComponentAdapter(); this.tostring = interpreter.getComponentIdentifier().getLocalName(); this.provider = interpreter.getServiceContainer(); }
/** * Get a raw reference to a provided service implementation. */ public Object getRawService(Class type) { assert !getComponentAdapter().isExternalThread(); IService[] sers = getServiceContainer().getProvidedServices(type); return convertRawService(sers[0]); }
assert !getComponentAdapter().isExternalThread(); getClassLoader()))+":virtual", info.getType().getType(getClassLoader())); IServiceIdentifier sid = BasicService.createServiceIdentifier(getExternalAccess().getServiceProvider().getId(), rsi.getName(), rsi.getType().getType(getClassLoader()), BasicServiceInvocationHandler.class, getModel().getResourceIdentifier()); final IInternalService service = BasicServiceInvocationHandler.createDelegationProvidedServiceProxy( getInternalAccess(), getComponentAdapter(), sid, rsi, impl.getBinding(), getClassLoader(), isRealtime()); getServiceContainer().addService(service, info).addResultListener(createResultListener(new DelegationResultListener<Void>(ret))); Object ser = createServiceImplementation(info, model); ics[i] = (IServiceInvocationInterceptor)SJavaParser.evaluateExpression(ins[i].getValue(), model.getAllImports(), getFetcher(), getClassLoader()); ics[i] = (IServiceInvocationInterceptor)ins[i].getClazz().getType(getClassLoader(), model.getAllImports()).newInstance(); final Class<?> type = info.getType().getType(getClassLoader()); addService(info.getName(), type, info.getImplementation().getProxytype(), ics, ser, info, componentfetcher) .addResultListener(new ExceptionDelegationResultListener<IInternalService, Void>(ret)
assert !getComponentAdapter().isExternalThread(); Class<?> clazz = nfprop.getClazz().getType(getClassLoader()); INFProperty<?, ?> nfp = AbstractNFProperty.createProperty(clazz, getInternalAccess(), null, null); addNFProperty(nfp); getLogger().warning("Property creation problem: "+e); Class<?> clazz = unexp.getClazz()!=null? unexp.getClazz().getType(getClassLoader(), model.getAllImports()): null; Object tmp; if(unexp.getValue()==null || unexp.getValue().length()==0 && clazz!=null) tmp = SJavaParser.evaluateExpression(unexp.getValue(), model.getAllImports(), getFetcher(), getClassLoader()); ((IFuture)val).addResultListener(createResultListener(new DefaultResultListener() addProperty(name, val);
assert !getComponentAdapter().isExternalThread(); addArgument(entry.getKey(), entry.getValue()); for(int i=0; i<upes.length; i++) addArgument(upes[i].getName(), SJavaParser.getParsedValue(upes[i], model.getAllImports(), getFetcher(), getClassLoader())); done.add(upes[i].getName()); addArgument(margs[i].getName(), SJavaParser.getParsedValue(margs[i].getDefaultValue(), model.getAllImports(), getFetcher(), getClassLoader())); setResultValue(IComponentIdentifier.RESULTCID, getComponentIdentifier()); for(int i=0; i<upes.length; i++) addDefaultResult(upes[i].getName(), SJavaParser.getParsedValue(upes[i], model.getAllImports(), getFetcher(), getClassLoader())); done.add(upes[i].getName()); addDefaultResult(res[i].getName(), SJavaParser.getParsedValue(res[i].getDefaultValue(), model.getAllImports(), getFetcher(), getClassLoader()));
assert !getComponentAdapter().isExternalThread(); for(int i=0; i<ms.length; i++) ms[i] = new RequiredServiceInfo(getServicePrefix()+ms[i].getName(), ms[i].getType().getType(getClassLoader()), ms[i].isMultiple(), ms[i].getMultiplexType()==null? null: ms[i].getMultiplexType().getType(getClassLoader()), ms[i].getDefaultBinding(), ms[i].getNFRProperties()); sermap.put(ms[i].getName(), ms[i]); RequiredServiceInfo rsi = (RequiredServiceInfo)sermap.get(getServicePrefix()+cs[i].getName()); RequiredServiceInfo newrsi = new RequiredServiceInfo(rsi.getName(), rsi.getType().getType(getClassLoader()), rsi.isMultiple(), ms[i].getMultiplexType()==null? null: ms[i].getMultiplexType().getType(getClassLoader()), new RequiredServiceBinding(cs[i].getDefaultBinding()), ms[i].getNFRProperties()); sermap.put(rsi.getName(), newrsi); RequiredServiceBinding[] bindings = getBindings(); if(bindings!=null) RequiredServiceInfo newrsi = new RequiredServiceInfo(rsi.getName(), rsi.getType().getType(getClassLoader()), rsi.isMultiple(), rsi.getMultiplexType()==null? null: rsi.getMultiplexType().getType(getClassLoader()), new RequiredServiceBinding(bindings[i]), ms[i].getNFRProperties()); sermap.put(rsi.getName(), newrsi); getServiceContainer().addRequiredServiceInfos(rservices); for(RequiredServiceInfo rsi: rservices) INFMixedPropertyProvider nfpp = getServiceContainer().getRequiredServicePropertyProvider(null); // null for unbound Class<?> clazz = nfprop.getClazz().getType(getClassLoader()); INFProperty<?, ?> nfp = AbstractNFProperty.createProperty(clazz, getInternalAccess(), null, nfprop.getMethodInfo()); if(mi==null)
/** * Create a result listener which is executed as an component step. * @param The original listener to be called. * @return The listener. */ public <T> IIntermediateResultListener<T> createResultListener(IIntermediateResultListener<T> listener) { return new IntermediateComponentResultListener<T>(listener, getComponentAdapter()); }
/** * Get the number of components to start. * @return The number. */ public int getNumber(ComponentInstanceInfo component, IModelInfo model) { assert !getComponentAdapter().isExternalThread(); Object ret = component.getNumber()!=null? SJavaParser.evaluateExpression(component.getNumber(), model.getAllImports(), getFetcher(), getClassLoader()): null; return ret instanceof Integer? ((Integer)ret).intValue(): 1; }
assert !getComponentAdapter().isExternalThread(); for(int i=0; i<ps.length; i++) Object key = ps[i].getName()!=null? ps[i].getName(): ps[i].getType().getType(getClassLoader()); if(sermap.put(key, ps[i])!=null) throw new RuntimeException("Services with same type must have different name."); // Is catched and set to ret below for(int i=0; i<cs.length; i++) Object key = cs[i].getName()!=null? cs[i].getName(): cs[i].getType().getType(getClassLoader()); ProvidedServiceInfo psi = (ProvidedServiceInfo)sermap.get(key); ProvidedServiceInfo newpsi= new ProvidedServiceInfo(psi.getName(), psi.getType().getType(getClassLoader()), new ProvidedServiceImplementation(cs[i].getImplementation()), psi.getPublish()); sermap.put(key, newpsi); initProvidedServices(0, services, model).addResultListener(createResultListener(new DelegationResultListener<Void>(ret)
assert !getComponentAdapter().isExternalThread(); int num = getNumber(components[i], model); IResultListener<IComponentIdentifier> crl = new CollectionResultListener<IComponentIdentifier>(num, false, createResultListener(new ExceptionDelegationResultListener<Collection<IComponentIdentifier>, Void>(fut) cms.createComponent(getName(components[i], model, j+1), type.getName(), new CreationInfo(components[i].getConfiguration(), getArguments(components[i], model), getComponentAdapter().getComponentIdentifier(), suspend, master, daemon, autoshutdown, monitoring, synchronous, model.getAllImports(), bindings, null), null).addResultListener(crl);
assert !getComponentAdapter().isExternalThread(); IFuture<IClockService> fut = SServiceProvider.getService(getServiceContainer(), IClockService.class, RequiredServiceInfo.SCOPE_PLATFORM); fut.addResultListener(createResultListener(new ExceptionDelegationResultListener<IClockService, Void>(ret)
/** * Terminate all extensions. */ public IFuture<Void> terminateExtensions() { // Hack!!! When init fails , terminateExtensions() can not be called on component thread // as component already terminated. assert !getComponentAdapter().isExternalThread() || IComponentDescription.STATE_TERMINATED.equals(getComponentDescription().getState()); Future<Void> ret = new Future<Void>(); IExtensionInstance[] exts = getExtensions(); CounterResultListener<Void> lis = new CounterResultListener<Void>(exts.length, false, new DelegationResultListener<Void>(ret)); for(int i=0; i<exts.length; i++) { exts[i].terminate().addResultListener(lis); } return ret; }
assert !getComponentAdapter().isExternalThread(); initArguments(model, config, arguments).addResultListener( createResultListener(new DelegationResultListener<Void>(fut) fut.addResultListener(createResultListener(new DelegationResultListener<Void>(iret)
/** * Start the services. */ public IFuture startServiceContainer() { assert !getComponentAdapter().isExternalThread(); return getServiceContainer().start(); }
startEndSteps().addResultListener(createResultListener(new DelegationResultListener<Void>(ret)
/** * Init the extensions. */ public IFuture<Void> initExtensions(IModelInfo model, String config) { assert !getComponentAdapter().isExternalThread(); final Future<Void> ret = new Future<Void>(); if(config!=null) { ConfigurationInfo conf = model.getConfiguration(config); final IExtensionInfo[] exts = conf.getExtensions(); if(exts.length>0) { initExtension(exts, 0).addResultListener(new DelegationResultListener<Void>(ret)); } else { ret.setResult(null); } } else { ret.setResult(null); } return ret; }
/** * Start the services. */ public IFuture startServiceContainer() { // Overriden to do nothing when this is called for a capability. // Hack!!! Container started, but capability services added later. return initcapa==model.getHandle() ? super.startServiceContainer() : IFuture.DONE; }