Results 1 to 3 of 3

Thread: Making two services that consume each other?

  1. #1
    Join Date
    Sep 2010
    Posts
    6

    Default Making two services that consume each other?

    Hi...

    Im new to Spring DM...

    Im working on converting an existing spring MVC project to a set of bundles.

    Now i want to know if its posible to have 2 bundles A and B where

    A injects one type of service into B and
    B injects another service into A

    So far i've not found any work arounds to this problem

    thx in advance

  2. #2
    Join Date
    Nov 2010
    Posts
    4

    Default

    Hi folsgaard,
    I think what you describe is possible.
    You can have Bundle A exposing service A, and using service B; and Bundle B exposing service B and using service A.
    This will work if one of the service import is declared as optional, so that, when you deploy the bundles on the platform, the dependency constraints can be resolved.

    The spring dm files will look like :
    Bundle A file :
    Code:
    <bean name="A" class="ServiceA">
        <property name="b" ref="serviceB">
    </bean>
    <osgi:reference interface="IServiceB" id="serviceB" cardinality="0..1"/>
    <osgi:service interface="IServiceA" ref="A"/>
    Bundle B file :
    Code:
    <bean name="B" class="ServiceB">
        <property name="a" ref="serviceA">
    </bean>
    <osgi:reference interface="IServiceA" id="serviceA"/>
    <osgi:service interface="IServiceB" ref="B"/>
    In this case, you need to start Bundle A before Bundle B. The reference to service B being optional, bundle A will be able to start, and then, Bundle B will be able to start also (as service A is available).

    Hope this helped.

    Regards,
    Lorie.

  3. #3
    Join Date
    Sep 2010
    Posts
    6

    Default

    thx... that was exactly what i had in mind.

Posting Permissions

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