There is a life cycle mismatch here. For a prototype scope service, a new instance is created for each consumer of the service. So there are potentially an infinite number of service instances.
For factory configurations, there are a finite number of configuration instances because someone has to set them and they are set in advance of the prototype service instance creation.
So there is no way to match a prototype scope service instance with any specific factory configuration instance.
Prototype scope services are for the use case of managing resources on behalf of the service consumer such that for each instance, some resources are allocated which must be deallocated when then service instance is released. The notion of prototype scoped services was created in support of EJB and CDI beans (see RFC 195 for some background).
If you want to create a specific number of services each configured by a factory configuration instance, then prototype scopes services are orthogonal to your needs.
--
BJ Hargrave
Senior Technical Staff Member, IBM // office: +1 386 848 1781
OSGi Fellow and CTO of the OSGi Alliance // mobile: +1 386 848 3788
hargr...@us.ibm.com
BJ Hargrave
Senior Technical Staff Member, IBM // office: +1 386 848 1781
OSGi Fellow and CTO of the OSGi Alliance // mobile: +1 386 848 3788
hargr...@us.ibm.com
----- Original message -----
From: Scott Lewis <sle...@composent.com>
Sent by: osgi-dev-boun...@mail.osgi.org
To: osgi-dev@mail.osgi.org
Cc:
Subject: Re: [osgi-dev] component factory and configuration
Date: Mon, Nov 21, 2016 10:33 AM
On 11/21/2016 12:50 AM, Timothy Ward wrote:<stuff deleted>
Any thoughts/comments about method for getting a distinct configuration associated with every service instance?
This is fine for my use case WRT creating service instances on demand via the FooConsumer. However, I would like to be able to have a distinct/new configuration associated with each new FooImpl, rather than a single FooConfig instance assigned to all of them. Is this possible using the PROTOTYPE pattern, or is it necessary to use the ComponentFactory in the manner Tim describes to accomplish this:
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._______________________________________________
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