> Question:   If I use a component factory as suggested above to create a 
> component instance, is there a straightforward way to associate every 
> newInstance with a separate/new configuration?

The way that this is done is to pass the configuration using the newInstance 
method. Effectively your pattern would be to register a ConfigurationListener 
or ManagedServiceFactory, passing the configuration Dictionary to the Component 
Factory for each Factory Configuration. 

The thing is - this is almost exactly the multiton pattern, so I can’t quite 
work out why setting the DS service scope to prototype isn’t enough for what 
you want to achieve… I guess I’m just not close enough to the detail.

Regards,

Tim

> On 19 Nov 2016, at 16:19, Scott Lewis <sle...@composent.com> wrote:
> 
> On 11/18/2016 2:02 PM, Scott Lewis wrote:
>> On 11/18/2016 1:58 PM, Tim Ward wrote:
>>> That sounds a lot like the DS ComponentFactory use case to me. You supply 
>>> properties to the factory and it spits out a configured instance for you to 
>>> use.
>> 
>> Yeah I agree ComponentFactory seems relevant, and I have played around with 
>> it for this use case.
>> 
>>> 
>>> Just to confirm, I assume that the standard multiton pattern using factory 
>>> configurations doesn't help you as the components are stateful and need to 
>>> be created on demand?
> 
> Question:   If I use a component factory as suggested above to create a 
> component instance, is there a straightforward way to associate every 
> newInstance with a separate/new configuration?  My first thought was to use a 
> factory configuration, but it says this in 112.7
> 
> A factory configuration must not be used if the component is a factory 
> component.   This is because SCR is not free to create component 
> configurations as necessary to support multiple Configurations. When SCR 
> detects this condition, it must log an error message with the Log Service, if 
> present, and ignore the component description. 
> 
> Thanks,
> 
> Scott
> 
> _______________________________________________
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to