[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.technology.equinox] Declarative Service : Delayed Component vs Factory Component

Hi,

I try to find the best way to implement services in my work :

I have a bundle called 'core' which own a service 'ChromeProvider' 
(interface and impl).. I want that 'client' bundles use this service using 
the declarative services. The ChromeProvider service needs to now and store 
the registering bundle (because this bundle access to internal resources).

Delayed Component :
with this declaration (in client bundle):
<scr:component name="chromeProvider" enabled="true">

    <implementation class="core.chrome.ChromeProviderImpl" />

    <property name="authority.test" value="/test/toto" />

    <service>

        <provide interface="core.chrome.ChromeProvider" />

    </service>

</scr:component>

Everything works fine, BUT the implementation must be visible to client 
bundles (not internal). Of course, I can extends visible implementation by 
an internal one!

Factory Component :
Using this :
<scr:component name="chromeProvider" factory="chromeProviderFactory">

    <implementation class="core.chrome.ChromeProviderImpl" />

    <service>

        <provide interface="core.chrome.ChromeProvider" />

    </service>

</scr:component>

and using newInstance(..), I can put implementation into 'internal' 
packages, so everything goes right, BUT I cannot know the calling bundle 
from inside "activate" method. The usingBundle  is null (as explained in the 
doc), and the ComponentContext.getBundleContext() returns the 'core' 
bundleContext.

What can I do ?

IS there something I didn't understand in coponent factory ?

Is there a better way to respect Visible/Internal framework habits ?

Regards,

Olivier Moises