Furthermore, with the suggested approach there is still no simple way for the client to see _what_ went wrong (was there a missing property? a wrong-typed property? what?). It would just detect that the service wasn't properly created.
best regards, Peter 2012/1/30 Peter Gardfjäll <[email protected]> > Thanks Filippo, > > but I believe that a straight service lookup wouldn't work. > I don't think that there are any guarantees that the service instance has > been registered right after the config.update(...) call. > Thus, I would need to wait for the service to appear (how long?), for > example using a ServiceTracker. > Although clearly doable, such a solution sounds a bit ugly/cumbersome. > I was hoping for a more elegant solution. > > best regards, Peter > > > On Mon, Jan 30, 2012 at 2:13 PM, Filippo Balicchia > <[email protected]>wrote: > >> Why, >> don't you use a lookup that after the call to the factory check if the >> registration was successful ? >> If lookup fail you thrown a ServiceUnavailableException. >> >> >> --Filippo >> >> Il 30 gennaio 2012 09:24, Peter Gardfjäll >> <[email protected]> ha scritto: >> > Hi all, >> > >> > thought I'd ask this general OSGi question on this list full of >> > OSGi-knowledgeable people. >> > Please tell me if it belongs better on a more OSGi-standard specific >> forum >> > (such as Felix/Equinox perhaps). >> > >> > So I have a ManagedFactoryService that creates service instances and I >> have >> > another (client-)bundle that creates instances by registering new >> > configurations with the factory. >> > What I currently find difficult is to propagate errors (such as a >> required >> > configuration property missing) from the ManagedFactoryService to the >> > client. >> > >> > When the client uses an invalid configuration dictionary to instantiate >> a >> > new service instance as follows >> > >> > // instantiate new service with serviceConfig as instantiation >> > parameters >> > Configuration config = >> > configurationAdmin.createFactoryConfiguration(factoryPid, null); >> > config.update(serviceConfig); >> > >> > no exception is raised despite the ManagedFactoryService throwing a >> > ConfigurationException. >> > I guess this is expected since configuration updates are handled on a >> > separate thread of execution. >> > But this is problematic since, from the client bundle's perspective, the >> > configuration update appears to have been successful. >> > >> > So what I really need to know is if there is a best practice for >> propagating >> > the configuration error from the ManagedFactoryService to the client? >> > Any suggestions would be appreciated. >> > >> > best regards, Peter >> > >
