Hi,

I'm using the OSGi DS spec, respectively the SCR runtime, to declare my components and their required references. Now I have the following use-case for which I'm unsure about on how to implement it:

Consider a logging service that want's to provide a different logger instance for every bundle requesting a logger. Therefore I've implemented a service implement, class Logger and declared it the following way:

<scr:component enabled="true" name="LoggerService" factory="LoggerServiceFactory">
        <implementation class="the.package.impl.LoggerImpl"/>
        <service>
            <provide interface="the.package.Logger"/>
        </service>
</scr:component>

So now, the only way I found out on how to get a reference to a LoggerService instance is to get a reference to the ComponentFactory "LoggerServiceFactory" and programmatically calling newInstance(Dictionary) on it.

I wonder if there's no "more declarative" way for referencing a component produced by the declared component factory. Something like this would be straightforward in my opinion, allowing to declare references with passing configuration:

<reference name="log" interface="the.package.Logger" cardinality="1..1" policy="static" bind="bindLog" unbind="unbindLog">
    <property key="loggername" value="The loggers instance name" />
</reference>

Thanks for your help or clarification in advance!

Kind regards,
        Daniel Bimschas
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to