You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by João Ferreira <jt...@gmail.com> on 2009/05/25 06:06:53 UTC

Service Rankings

Hi

I think i found a bug with service rankings since the comparator method
of service reference isn't being called. I placed a breakpoint in the
method and got no stop.
Could someone confirm this? I'm creating the services with ipojo but i
dont think thats the prob since the services have the service.ranking
property set.

Thanks
João Ferreira

Re: Service Rankings

Posted by Clement Escoffier <cl...@gmail.com>.
Hi,


On 25.05.2009, at 08:10, Stuart McCulloch wrote:

> 2009/5/25 João Ferreira <jt...@gmail.com>
>
>> Hi
>>
>> I think i found a bug with service rankings since the comparator  
>> method
>> of service reference isn't being called. I placed a breakpoint in the
>> method and got no stop.
>
>
> you'll need to provide more details like which version of Felix  
> you're using
> and
> where you're setting the breakpoint (in trunk the  
> ServiceReference.compareTo
> implementation is actually in ServiceRegistrationImpl.java:452)
>
> also it depends how you're getting the service - if you use the bundle
> context
> method "getServiceReference(String clazz)" this definitely uses  
> compareTo
> - see the "getBestServiceReference" utility method in  
> BundleContextImpl:271
>
> but if you're using a high-level framework like iPOJO then it might  
> be using
> its
> own implementation of the ranking algorithm to sort services (the  
> compareTo
> method in ServiceReference only appeared in r4.1 of the OSGi spec,  
> before
> that the service ordering was defined in the spec but there was no  
> compareTo
> method defined in the ServiceReference interface)

Could you try an iPOJO trick: set the binding policy of your  
'requires' to 'dynamic-priority'.
So, in XML add 'policy="dynamic-priority"', in annotations add:  
policy="dynamic-priority".

If it works like this, it's a bug in the 'dynamic' binding policy :-)

Regards,

Clement


>
>
> Could someone confirm this? I'm creating the services with ipojo but i
>> dont think thats the prob since the services have the service.ranking
>> property set.
>>
>> Thanks
>> João Ferreira
>>
>
>
>
> -- 
> Cheers, Stuart


Re: Service Rankings

Posted by Stuart McCulloch <mc...@gmail.com>.
2009/5/25 João Ferreira <jt...@gmail.com>

> Hi
>
> I think i found a bug with service rankings since the comparator method
> of service reference isn't being called. I placed a breakpoint in the
> method and got no stop.


you'll need to provide more details like which version of Felix you're using
and
where you're setting the breakpoint (in trunk the ServiceReference.compareTo
implementation is actually in ServiceRegistrationImpl.java:452)

also it depends how you're getting the service - if you use the bundle
context
method "getServiceReference(String clazz)" this definitely uses compareTo
- see the "getBestServiceReference" utility method in BundleContextImpl:271

but if you're using a high-level framework like iPOJO then it might be using
its
own implementation of the ranking algorithm to sort services (the compareTo
method in ServiceReference only appeared in r4.1 of the OSGi spec, before
that the service ordering was defined in the spec but there was no compareTo
method defined in the ServiceReference interface)

Could someone confirm this? I'm creating the services with ipojo but i
> dont think thats the prob since the services have the service.ranking
> property set.
>
> Thanks
> João Ferreira
>



-- 
Cheers, Stuart