Search code examples
osgiblueprint-osgi

Blueprint mandatory dependancy to mandatory dependency


Please help me with one problem. I have an osgi bundle. Blueprint config looks like this

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

    <bean class="test.SomeBean">
        <argument>
            <reference-list availability="mandatory" member-type="service-object" interface="test.Service1"/>
        </argument>
    </bean>

    <service interface="test.Service1">
        <bean class="test.Service1Impl">
            <argument>
                <reference-list availability="mandatory" member-type="service-object" interface="test.Service2"/>
            </argument>
        </bean>
    </service>

    <service interface="test.Service2">
        <bean class="test.Service2Impl"/>
    </service>

</blueprint>

After deploy I get a java.util.concurrent.TimeoutException. If I move Service2 declaration to another bundle or change availability to optional all work fine. Why?


Solution

  • The reason is that you depend on a service that you also offer. BLueprint can not do this for mandatory services.

    The reason is that whenever blueprint hits a mandatory reference it makes sure to resolve the dependency before commencing. Only when all mandatory references are resolved the services of the context will be published.