Results 1 to 7 of 7

Thread: About Ranking Attribute

  1. #1
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,791

    Default About Ranking Attribute

    Hello

    In The ranking Attribute section

    has this text

    When registering a service with the service registry, you may optionally specify a service ranking (see section 5.2.5 of the OSGi Service Platform Core Specification). When a bundle looks up a service in the service registry, given two or more matching services the one with the highest ranking will be returned.
    Ok I would have

    Code:
    <service ref="beanToBeExported" 
                 interface="com.xyz.MyServiceInterface"
                 ranking="1"/>
    .....
    and in other bundle
    <service ref="beanToBeExported" 
                 interface="com.xyz.MyServiceInterface"
                 ranking="2"/>
    Ok if a X bundle need work with "beanToBeExported",
    according with the text the second is chosen (ranking2),

    but what happens if I have an old bundle and is mandatory
    use the first version? How to say for that bundle, use ranking 1?

    Am I missing something?

    Thanks in advanced
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    If you want to select a certain service, you can always use the service filter to select certain services based on properties.
    See http://www.osgi.org/javadoc/r4v41/or...rk/Filter.html for more information:

    Code:
    <osgi:reference filter="(service.ranking=2)" ...>
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,791

    Default

    Hello Costin

    Thanks for the reply and solution
    But I see that this approach is mandatory in any bundle that needs keep reference to the low service

    I mean if I have 50 X bundles that depends of an alfa service , and after that I create 5 Y bundles and a new alfa service (ranking2)
    I must update the old 50 X bundles to keep the reference for the first alfa service and of course
    the 5 Y bundles should work with the alfa service ranking 2

    Am I correct?




    Best Regards
    Last edited by dr_pompeii; Jun 15th, 2009 at 07:54 PM.
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I'm not sure what you're asking. In DM 1.2, single services rebind if a better candidate appears - if that's unwanted you could use service properties to differentiate between them.
    In 2.0, we are introducing a new parameter, (currently called sticky) which can turn on/off this behaviour if it's undesirable.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,791

    Default

    Hello Costin

    Thanks again for your time and reply

    I'm not sure what you're asking.
    Again my english is not well

    I mean this (If I am wrong pls correct me)

    For instance
    I have a bundle called "A" and has this
    Code:
    <service ref="beanToBeExported" interface="com.xyz.MyServiceInterface" />
    see that ranking doesnt exists yet

    and other bundle called "B" that has this
    Code:
    <osgi:reference id="beanToBeExported" interface="com.xyz.MyServiceInterface"
    and furthermore "B1","B2" with the same code that above

    Until here bundles "B" "B1" "B2" must work with service from "A"

    After a time I create a bundle called A1 but with this
    Code:
    <service ref="beanToBeExported" 
                 interface="com.xyz.MyServiceInterface"
                 ranking="2"
     />
    and again other bundle called "C" that has this
    Code:
    <osgi:reference id="beanToBeExported" interface="com.xyz.MyServiceInterface"
    According with the documentation about ranking attirbute
    bundle "C" should work with service of bundle "A1"

    However with this new bundle A1 with its ranking attributte it affects to my previous bundles (B,B1,B2) because: bundle "A" has no the ranking attributte,
    but bundle "A1" yes, bundles "B" "B1" "B2" now should work with "A1",
    am I right?

    But If I want keep my old rule which is
    bundles "B" "B1" "B2" must work with service from "A" ,
    I must use <osgi:reference filter="(service.ranking=1)" ...>
    for each Bundle B and after this therefore I must go to bundle "A" and add ranking="1" ?
    Am I correct?

    Now Imagine the situation if I 50 bundles of type B
    Is mandatory change the code adding the filter right for all them right?

    I hope you see my point now

    Now according with your last explanation, your new solutions how could resolve this situation

    Thanks in advanced
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  6. #6
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    service rankings are nothing more then a predefined filter attribute. They are used by the framework to decide what service to pick when only one is request and multiple are found (see the spec for an in-depth explanation) but in the end, they are just properties.
    My point is that, the rules that apply to ldap filter matching, apply here as well. If you don't specify an attribute, it is ignored - if you do, then this will affect the number of services retrieved.

    My proposal was to use service.ranking as a deciding factor between two services based on its special meaning in the OSGi platform. You can specify it on the client as you suggested, but if you don't, since the OSGi spec specifies that when multiple services are found, the one with the highest ranking must be returned, you can use this as a deciding factor while keeping the client configuration intact.

    Of course, you can be declarative about it and specify this (or any other property that makes sense for you) in both the client and the server.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  7. #7
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,791

    Default

    Hello Costin

    thanks a lot for the reply

    My point is that, the rules that apply to ldap filter matching, apply here as well. If you don't specify an attribute, it is ignored - if you do, then this will affect the number of services retrieved.
    Ok

    My proposal was to use service.ranking as a deciding factor between two services based on its special meaning in the OSGi platform.
    Ok

    In 2.0, we are introducing a new parameter, (currently called sticky) which can turn on/off this behaviour if it's undesirable.
    I hope see such documentation

    Best Regards
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •