Hi Daniel,

This is a known bug, but it was already fixed (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=285464).
The fix exists in the last Eclipse 3.6 integration build and 3.5.1RC1 build.

Stoyan

Daniel Bimschas wrote:
Just tried using the service factory mechanism. The result is the following error message:

"ComponentReference.bind(): service reference {org.osgi.service.log.LogService, org.eclipse.equinox.log.ExtendedLogService}={service.id=30} is already bound to another instance: ..."

The reference here is used for getting the OSGi LogService in the Logger service that is now declared with servicefactory="true" like this:

<reference name="logService" interface="org.osgi.service.log.LogService" cardinality="1..1" policy="static" bind="bindLogService" unbind="unbindLogService"/>

Can you also help me with that? It seems there's only one reference allowed for this component. Didn't find anything about that in 112.3...

Thanks, Daniel

Am 18.08.2009 um 03:54 schrieb Simon J Archer:


Daniel

>>Consider a logging service that wants to provide a different logger
>>instance for every bundle requesting a logger.

If all you want to do is provide a unique instance of the Logger service to each bundle that requires one, consider using a service factory rather than a component factory:

         <service servicefactory="true">
            <provide interface="the.package.Logger"/>
        </service>

// 112.4.6
"If servicefactory is set to true, a different component configuration is created, activated and its component instance returned as the service object for each distinct bundle that requests the service. Each of these component configurations has the same component properties."

The bundle that references the Logger service does not know that its getting a unique instance.

I hope this help.

Simon


From:
Daniel Bimschas <[email protected]>
To:
[email protected]
Date:
08/17/2009 04:09 PM
Subject:
[osgi-dev] Declarative Services and Component Factories
Sent by:
[email protected]




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


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

----------------------
Daniel Bimschas
Fleischhauer Straße 45
23552 Lübeck
[email protected]
----------------------


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

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

Reply via email to