SCR annotations @Activate @Deactivate @Modified in outer classes also affect 
nested classes, annotations in nested classes are ignored
--------------------------------------------------------------------------------------------------------------------------------------

                 Key: FELIX-3332
                 URL: https://issues.apache.org/jira/browse/FELIX-3332
             Project: Felix
          Issue Type: Bug
          Components: Maven SCR Plugin
    Affects Versions: maven-scr-plugin-1.7.4, maven-scr-plugin-1.7.2
            Reporter: Daniel Faber
            Priority: Minor


When maven-scr-plugin processes components that are implemented as nested 
classes, SCR annotations @Activate @Deactivate @Modified in these nested 
classes are ignored.  Annotations in the outer class are used instead:


import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;

@Component
public class Outer {

        @Activate
        private void activateOuter() {
        }

        @Component
        public static class Nested1 {
        }

        @Component
        public static class Nested2 {

                @Activate
                private void activateNested2() {
                }

        }

}


results in this component description:


<?xml version="1.0" encoding="UTF-8"?>
<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0";>
    <scr:component enabled="true" name="Outer" activate="activateOuter">
        <implementation class="Outer"/>
        <property name="service.pid" value="Outer"/>
    </scr:component>
    <scr:component enabled="true" name="Outer$Nested1" activate="activateOuter">
        <implementation class="Outer$Nested1"/>
        <property name="service.pid" value="Outer$Nested1"/>
    </scr:component>
    <scr:component enabled="true" name="Outer$Nested2" activate="activateOuter">
        <implementation class="Outer$Nested2"/>
        <property name="service.pid" value="Outer$Nested2"/>
    </scr:component>
</components>


All components have an activate="activateOuter" attribute.  Similar problems 
occur if the outer class is not a component or does not have an @Activate 
annotation:


public class Outer {

        @Component
        public static class Nested {

                @Activate
                private void activateNested() {
                }

        }

}

Here the activate attribute is missing:

<?xml version="1.0" encoding="UTF-8"?>
<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0";>
    <scr:component enabled="true" name="Outer$Nested">
        <implementation class="Outer$Nested"/>
        <property name="service.pid" value="Outer$Nested"/>
    </scr:component>
</components>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to