knopflerfish / knopflerfish.org

Knopflerfish OSGi Service Platform. OSGi run-time container and SDK source code repo
http://www.knopflerfish.org
BSD 3-Clause "New" or "Revised" License
33 stars 11 forks source link

Using target property filters may cause SCR to give incorrect errors for circular component chains #43

Open chlarsson opened 6 years ago

chlarsson commented 6 years ago

The following SCR service.xml fill produce an incorrect error for a circular component chain.

A complete test example will be checked into the branch of the same name as this issue.

<?xml version="1.0" encoding="UTF-8"?>

<components>

  <component name="org.knopflerfish.bundle.componentFilter_testA"
         immediate="true"
             xmlns="http://www.osgi.org/xmlns/scr/v1.0.0">
    <implementation
       class="org.knopflerfish.bundle.componentFilter_test.GeneralComponentImplA"/>

    <service>
      <provide
         interface="org.knopflerfish.service.componentFilter_test.GeneralComponent"/>
    </service>

    <property name="actionName" value="A" />

    <reference  name = "org.knopflerfish.service.componentFilter_test.OtherComponent"
        interface = "org.knopflerfish.service.componentFilter_test.OtherComponent"
        bind = "setOtherComponent"
        policy="static"
        cardinality="1..1"
        />

  </component>

  <component name="org.knopflerfish.bundle.componentFilter_testB"
         immediate="true"
             xmlns="http://www.osgi.org/xmlns/scr/v1.0.0">

    <implementation
       class="org.knopflerfish.bundle.componentFilter_test.GeneralComponentImplB"/>

    <service>
      <provide
         interface="org.knopflerfish.service.componentFilter_test.GeneralComponent"/>
    </service>

    <property name="actionName" value="B" /> 

    <reference  name = "org.knopflerfish.service.componentFilter_test.GeneralComponent"
        interface = "org.knopflerfish.service.componentFilter_test.GeneralComponent"
        target = "(actionName=A)"
        bind = "setGeneralComponentImplA"
        policy="static"
        cardinality="1..1"
        />

  </component>

</components>

When removing the reference dependency to the OtherComponent, which is non-existing, the example above works as expected. I..e. it is only when the filtered target component is not available the problem occurs.