Is it true that each component in declarative services is inherently a
singleton? That is to say, if I have something like this:

<component name="foo" immediate="true">
    <implementation class="com.pkg.internal.FooImpl"/>
    <service>
        <provide interface="com.pkg.api.Foo"/>
    </service>
</component>

then there will only ever be one instance of FooImpl? My use case is that I
want the application client to be able to say to Felix: give me a new
instance of all implementors of "Foo". In my case, Foo implementations have
state, and the application doesn't want to reuse an existing Foo.

I know that I can get multiple implementors of an interface from one bundle
to another by doing this:

<component name="foo-consumer">
    ...
    <reference name="contributor"
               interface="com.pkg.api.Foo"
               bind="addFoo"
               unbind="removeFoo"
               cardinality="0..n"
               policy="dynamic" />
</component>

but that will give me a list each of the Foo implementors, where again each
one is instantiated only one.

I guess my question could be rephrased as: can an OSGi client request that a
new instance of a particular service provider be created, as opposed to
getting the existing instance?

Thanks,
Jared
-- 
View this message in context: 
http://www.nabble.com/Are-service-implementors-inherently-singletons--tp17090261p17090261.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to