You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2013/02/18 09:07:15 UTC

[jira] [Closed] (FELIX-3332) SCR annotations @Activate @Deactivate @Modified in outer classes also affect nested classes, annotations in nested classes are ignored

     [ https://issues.apache.org/jira/browse/FELIX-3332?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Carsten Ziegeler closed FELIX-3332.
-----------------------------------

    
> 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.2, maven-scr-plugin-1.7.4
>            Reporter: Daniel Faber
>            Assignee: Carsten Ziegeler
>            Priority: Minor
>             Fix For: maven-scr-plugin-1.10.0, scr ant task 1.4.0, scr generator 1.4.0
>
>
> 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
For more information on JIRA, see: http://www.atlassian.com/software/jira