felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ferry Huberts <maili...@hupie.com>
Subject Re: @Reference multi binding & dynamics
Date Wed, 07 Oct 2015 16:13:30 GMT

On 07/10/15 18:01, Neil Bartlett wrote:
>> On 7 Oct 2015, at 13:56, Ferry Huberts <mailings@hupie.com> wrote:
>> Hi,
>> Cross-posting because I don't know if the situation/problem below is by design, a
bug in bnd, or a bug in SCR
>> I have a R6 component that does
>>   @Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE)
>> This appears to not bind new matching services, because the policy appears to be
STATIC by default.
> Yes, static policy has always been the default in DS. You can see this right back in
the very first DS specification found in OSGi Compendium R4.0, section 112.3.3: "The static
policy is the most simple policy and is the default policy”. Also section 112.10 that gives
the XML schema, where the reference element has the policy attribute defined as:
>      <attribute name="policy" type="scr:Tpolicy" default="static" use="optional"/>
>> I did expect the ReferenceCardinality.AT_LEAST_ONE to imply ReferencePolicy.DYNAMIC,
just like the bnd annotations did.
> Nope. These are new annotations in a new namespace. There is no reason to expect them
to have the same behaviour as the bnd annotations.

However, I challenge you to give me _one_ use-case where 
ReferencePolicy.STATIC && ReferencePolicy.(MULTIPLE|AT_LEAST_ONE) makes 

That combination _creates_ a timing dependency, services might or might 
not be bound, depending on startup order.

A warning in bndtools like 'you probably meant to use 
ReferencePolicy.DYNAMIC' when havingReferencePolicy.MULTIPLE or 
ReferencePolicy.AT_LEAST_ONE would be nice IMHO

>> Changing it to
>>   @Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.AT_LEAST_ONE)
>> appears to make it work like I expected.
>> Is this by design?
>> Coming from bnd annotations this - to me - seems like another (breaking) subtlety.
> It’s a subtlety perhaps because the standard annotations are just a direct, literal
transformation to the XML, whereas the bnd ones tried to be “smart”. Yes, this is by design.
> It’s certainly not breaking because, again, these are new annotations and there is
no reason to expect them to do the same thing…
>> -- 
>> Ferry Huberts
>> -- 
>> You received this message because you are subscribed to the Google Groups "bndtools-users"
>> To unsubscribe from this group and stop receiving emails from it, send an email to
>> For more options, visit https://groups.google.com/d/optout.
> -- 
> Ferry Huberts

To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org

View raw message