Hi,
Creating instances like this have an inherent problem. You can't assert that
you're the only user of the created instances. Any consumers have access to
the service exposed by the new component instances (despite they dont have
create the instance).
In iPOJO, we provide a composition model doing this instantiation for you
but asserting that only instances from the same composite have access to the
created instance.
For example, the following composition will create two instances from the
specified factories. Services provided by these instances are only available
for instances living in the composite. You could see composite as another
service registry (in fact, it is exactly another service registry) isolated
from the global (i.e. OSGi) service registry.
<composite name="mycomposite">
<instance component="your-factory-name"/>
<instance component="your-second-factory-name"/>
</composite>
<instance component="mycomposite"/> <!-- just to create an instance of the
composition -->
The specified factories (component attribute) can be in any other bundles.
In fact, composites goes further and you can create composites like this :
<composite name="mysecondcomposite">
<subservice action="instantiate"
specification="your_service_interface"/>
<subservice action="instantiate"
specification="your_second_service_interface"/>
</composite>
<instance component="mysecondcomposite"/> <!-- just to create an instance of
the composition -->
In this case, the composite tracks service implementation (i.e. component
factories) able to create instances providing the specified service
interfaces.
If these service implementations disappears or appears, the composite will
deal with this dynamism by looking for new service implementation, replace
the disposed instance...
Of course, composites can import services from the global service registry,
or can export services from the composite to OSGi.
Clement
-----Message d'origine-----
De : jaredmac [mailto:[EMAIL PROTECTED]
Envoyé : mardi 6 mai 2008 16:49
À : [email protected]
Objet : Re: Are service implementors inherently singletons?
Felix Meschberger-2 wrote:
>
> Not as per the OSGi framework specification. You might of course - as I
> said above - create a FooFactory and register that factory as a service.
> Your application would then get the FooFactory service and ask that
> FooFactory for Foo instances.
>
> Hope this helps.
>
Great, thank you - that does help. A FooFactory is exactly where I was
headed, and I wanted to make sure that I wasn't creating extra work for
myself if there were some factory-like capabilities built in to OSGi.
Thanks again,
Jared
--
View this message in context:
http://www.nabble.com/Are-service-implementors-inherently-singletons--tp1709
0261p17092093.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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]